web/wp-content/plugins/all-in-one-seo-pack/pclzip.lib.php
author hurons@caf4f556-3d62-0410-8435-a86758001935
Wed, 23 Dec 2009 17:55:33 +0000
branchwordpress
changeset 109 03b0d1493584
permissions -rw-r--r--
wordpress 2.8 () with the following extensions : - add-to-any - categories page - Event calendar (a custom version for IRI-Theme) - Executable PHP widget - FD feedburner - ggis subscribe - Google Xml site maple - post of current category - page redirection - related post by category AND IRI-Theme
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
109
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     1
<?php
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     2
// --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     3
// PhpConcept Library - Zip Module 2.5
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     4
// --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     5
// License GNU/LGPL - Vincent Blavet - March 2006
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     6
// http://www.phpconcept.net
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     7
// --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     8
//
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     9
// Presentation :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    10
//   PclZip is a PHP library that manage ZIP archives.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    11
//   So far tests show that archives generated by PclZip are readable by
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    12
//   WinZip application and other tools.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    13
//
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    14
// Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    15
//   See readme.txt and http://www.phpconcept.net
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    16
//
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    17
// Warning :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    18
//   This library and the associated files are non commercial, non professional
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    19
//   work.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    20
//   It should not have unexpected results. However if any damage is caused by
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    21
//   this software the author can not be responsible.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    22
//   The use of this software is at the risk of the user.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    23
//
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    24
// --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    25
// $Id: pclzip.lib.php,v 1.44 2006/03/08 21:23:59 vblavet Exp $
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    26
// --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    27
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    28
  // ----- Constants
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    29
  define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    30
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    31
  define( 'PCLZIP_SEPARATOR', ',' );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    32
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    33
  define( 'PCLZIP_ERROR_EXTERNAL', 0 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    34
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    35
  define( 'PCLZIP_TEMPORARY_DIR', '' );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    36
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    37
// --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    38
// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    39
// --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    40
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    41
  // ----- Global variables
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    42
  $g_pclzip_version = "2.5";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    43
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    44
  define( 'PCLZIP_ERR_USER_ABORTED', 2 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    45
  define( 'PCLZIP_ERR_NO_ERROR', 0 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    46
  define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    47
  define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    48
  define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    49
  define( 'PCLZIP_ERR_MISSING_FILE', -4 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    50
  define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    51
  define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    52
  define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    53
  define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    54
  define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    55
  define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    56
  define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    57
  define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    58
  define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    59
  define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    60
  define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    61
  define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    62
  define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    63
  define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    64
  define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    65
  define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    66
  define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    67
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    68
  // ----- Options values
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    69
  define( 'PCLZIP_OPT_PATH', 77001 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    70
  define( 'PCLZIP_OPT_ADD_PATH', 77002 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    71
  define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    72
  define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    73
  define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    74
  define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    75
  define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    76
  define( 'PCLZIP_OPT_BY_NAME', 77008 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    77
  define( 'PCLZIP_OPT_BY_INDEX', 77009 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    78
  define( 'PCLZIP_OPT_BY_EREG', 77010 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    79
  define( 'PCLZIP_OPT_BY_PREG', 77011 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    80
  define( 'PCLZIP_OPT_COMMENT', 77012 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    81
  define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    82
  define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    83
  define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    84
  define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    85
  define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    86
  // Having big trouble with crypt. Need to multiply 2 long int
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    87
  // which is not correctly supported by PHP ...
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    88
  //define( 'PCLZIP_OPT_CRYPT', 77018 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    89
  define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    90
  
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    91
  // ----- File description attributes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    92
  define( 'PCLZIP_ATT_FILE_NAME', 79001 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    93
  define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    94
  define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    95
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    96
  // ----- Call backs values
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    97
  define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    98
  define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    99
  define( 'PCLZIP_CB_PRE_ADD', 78003 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   100
  define( 'PCLZIP_CB_POST_ADD', 78004 );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   101
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   102
  class PclZip
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   103
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   104
    // ----- Filename of the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   105
    var $zipname = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   106
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   107
    // ----- File descriptor of the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   108
    var $zip_fd = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   109
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   110
    // ----- Internal error handling
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   111
    var $error_code = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   112
    var $error_string = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   113
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   114
    // ----- Current status of the magic_quotes_runtime
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   115
    // This value store the php configuration for magic_quotes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   116
    // The class can then disable the magic_quotes and reset it after
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   117
    var $magic_quotes_status;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   118
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   119
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   120
  // Function : PclZip()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   121
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   122
  //   Creates a PclZip object and set the name of the associated Zip archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   123
  //   filename.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   124
  //   Note that no real action is taken, if the archive does not exist it is not
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   125
  //   created. Use create() for that.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   126
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   127
  function PclZip($p_zipname)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   128
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   129
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   130
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   131
    // ----- Tests the zlib
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   132
    if (!function_exists('gzopen'))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   133
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   134
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   135
      die('Abort '.basename(__FILE__).' : Missing zlib extensions');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   136
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   137
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   138
    // ----- Set the attributes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   139
    $this->zipname = $p_zipname;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   140
    $this->zip_fd = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   141
    $this->magic_quotes_status = -1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   142
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   143
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   144
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   145
    return;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   146
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   147
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   148
  function create($p_filelist)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   149
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   150
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ...");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   151
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   152
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   153
    // ----- Reset the error handler
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   154
    $this->privErrorReset();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   155
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   156
    // ----- Set default values
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   157
    $v_options = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   158
    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   159
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   160
    // ----- Look for variable options arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   161
    $v_size = func_num_args();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   162
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   163
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   164
    // ----- Look for arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   165
    if ($v_size > 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   166
      // ----- Get the arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   167
      $v_arg_list = func_get_args();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   168
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   169
      // ----- Remove from the options list the first argument
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   170
      array_shift($v_arg_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   171
      $v_size--;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   172
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   173
      // ----- Look for first arg
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   174
      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   175
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   176
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   177
        // ----- Parse the options
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   178
        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   179
                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   180
                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   181
                                                   PCLZIP_OPT_ADD_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   182
                                                   PCLZIP_CB_PRE_ADD => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   183
                                                   PCLZIP_CB_POST_ADD => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   184
                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   185
                                                   PCLZIP_OPT_COMMENT => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   186
                                                   //, PCLZIP_OPT_CRYPT => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   187
                                             ));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   188
        if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   189
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   190
          return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   191
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   192
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   193
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   194
      // ----- Look for 2 args
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   195
      // Here we need to support the first historic synopsis of the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   196
      // method.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   197
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   198
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   199
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   200
        // ----- Get the first argument
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   201
        $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   202
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   203
        // ----- Look for the optional second argument
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   204
        if ($v_size == 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   205
          $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   206
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   207
        else if ($v_size > 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   208
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   209
		                       "Invalid number / type of arguments");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   210
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   211
          return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   212
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   213
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   214
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   215
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   216
    // ----- Init
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   217
    $v_string_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   218
    $v_att_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   219
    $v_filedescr_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   220
    $p_result_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   221
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   222
    // ----- Look if the $p_filelist is really an array
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   223
    if (is_array($p_filelist)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   224
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   225
      // ----- Look if the first element is also an array
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   226
      //       This will mean that this is a file description entry
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   227
      if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   228
        $v_att_list = $p_filelist;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   229
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   230
      
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   231
      // ----- The list is a list of string names
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   232
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   233
        $v_string_list = $p_filelist;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   234
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   235
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   236
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   237
    // ----- Look if the $p_filelist is a string
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   238
    else if (is_string($p_filelist)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   239
      // ----- Create a list from the string
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   240
      $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   241
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   242
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   243
    // ----- Invalid variable type for $p_filelist
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   244
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   245
      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   246
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   247
      return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   248
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   249
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   250
    // ----- Reformat the string list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   251
    if (sizeof($v_string_list) != 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   252
      foreach ($v_string_list as $v_string) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   253
        if ($v_string != '') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   254
          $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   255
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   256
        else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   257
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Ignore an empty filename");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   258
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   259
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   260
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   261
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   262
    // ----- For each file in the list check the attributes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   263
    $v_supported_attributes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   264
    = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   265
             ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   266
             ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   267
						);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   268
    foreach ($v_att_list as $v_entry) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   269
      $v_result = $this->privFileDescrParseAtt($v_entry,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   270
                                               $v_filedescr_list[],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   271
                                               $v_options,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   272
                                               $v_supported_attributes);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   273
      if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   274
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   275
        return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   276
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   277
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   278
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   279
    // ----- Expand the filelist (expand directories)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   280
    $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   281
    if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   282
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   283
      return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   284
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   285
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   286
    // ----- Call the create fct
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   287
    $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   288
    if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   289
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   290
      return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   291
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   292
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   293
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   294
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   295
    return $p_result_list;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   296
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   297
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   298
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   299
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   300
  // Function :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   301
  //   add($p_filelist, $p_add_dir="", $p_remove_dir="")
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   302
  //   add($p_filelist, $p_option, $p_option_value, ...)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   303
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   304
  //   This method supports two synopsis. The first one is historical.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   305
  //   This methods add the list of files in an existing archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   306
  //   If a file with the same name already exists, it is added at the end of the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   307
  //   archive, the first one is still present.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   308
  //   If the archive does not exist, it is created.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   309
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   310
  //   $p_filelist : An array containing file or directory names, or
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   311
  //                 a string containing one filename or one directory name, or
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   312
  //                 a string containing a list of filenames and/or directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   313
  //                 names separated by spaces.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   314
  //   $p_add_dir : A path to add before the real path of the archived file,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   315
  //                in order to have it memorized in the archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   316
  //   $p_remove_dir : A path to remove from the real path of the file to archive,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   317
  //                   in order to have a shorter path memorized in the archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   318
  //                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   319
  //                   is removed first, before $p_add_dir is added.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   320
  // Options :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   321
  //   PCLZIP_OPT_ADD_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   322
  //   PCLZIP_OPT_REMOVE_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   323
  //   PCLZIP_OPT_REMOVE_ALL_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   324
  //   PCLZIP_OPT_COMMENT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   325
  //   PCLZIP_OPT_ADD_COMMENT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   326
  //   PCLZIP_OPT_PREPEND_COMMENT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   327
  //   PCLZIP_CB_PRE_ADD :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   328
  //   PCLZIP_CB_POST_ADD :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   329
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   330
  //   0 on failure,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   331
  //   The list of the added files, with a status of the add action.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   332
  //   (see PclZip::listContent() for list entry format)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   333
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   334
  function add($p_filelist)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   335
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   336
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ...");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   337
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   338
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   339
    // ----- Reset the error handler
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   340
    $this->privErrorReset();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   341
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   342
    // ----- Set default values
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   343
    $v_options = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   344
    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   345
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   346
    // ----- Look for variable options arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   347
    $v_size = func_num_args();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   348
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   349
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   350
    // ----- Look for arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   351
    if ($v_size > 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   352
      // ----- Get the arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   353
      $v_arg_list = func_get_args();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   354
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   355
      // ----- Remove form the options list the first argument
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   356
      array_shift($v_arg_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   357
      $v_size--;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   358
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   359
      // ----- Look for first arg
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   360
      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   361
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   362
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   363
        // ----- Parse the options
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   364
        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   365
                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   366
                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   367
                                                   PCLZIP_OPT_ADD_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   368
                                                   PCLZIP_CB_PRE_ADD => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   369
                                                   PCLZIP_CB_POST_ADD => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   370
                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   371
                                                   PCLZIP_OPT_COMMENT => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   372
                                                   PCLZIP_OPT_ADD_COMMENT => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   373
                                                   PCLZIP_OPT_PREPEND_COMMENT => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   374
                                                   //, PCLZIP_OPT_CRYPT => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   375
												   ));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   376
        if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   377
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   378
          return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   379
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   380
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   381
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   382
      // ----- Look for 2 args
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   383
      // Here we need to support the first historic synopsis of the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   384
      // method.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   385
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   386
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   387
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   388
        // ----- Get the first argument
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   389
        $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   390
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   391
        // ----- Look for the optional second argument
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   392
        if ($v_size == 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   393
          $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   394
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   395
        else if ($v_size > 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   396
          // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   397
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   398
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   399
          // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   400
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   401
          return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   402
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   403
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   404
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   405
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   406
    // ----- Init
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   407
    $v_string_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   408
    $v_att_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   409
    $v_filedescr_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   410
    $p_result_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   411
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   412
    // ----- Look if the $p_filelist is really an array
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   413
    if (is_array($p_filelist)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   414
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   415
      // ----- Look if the first element is also an array
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   416
      //       This will mean that this is a file description entry
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   417
      if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   418
        $v_att_list = $p_filelist;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   419
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   420
      
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   421
      // ----- The list is a list of string names
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   422
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   423
        $v_string_list = $p_filelist;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   424
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   425
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   426
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   427
    // ----- Look if the $p_filelist is a string
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   428
    else if (is_string($p_filelist)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   429
      // ----- Create a list from the string
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   430
      $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   431
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   432
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   433
    // ----- Invalid variable type for $p_filelist
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   434
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   435
      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   436
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   437
      return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   438
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   439
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   440
    // ----- Reformat the string list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   441
    if (sizeof($v_string_list) != 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   442
      foreach ($v_string_list as $v_string) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   443
        $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   444
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   445
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   446
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   447
    // ----- For each file in the list check the attributes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   448
    $v_supported_attributes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   449
    = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   450
             ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   451
             ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   452
						);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   453
    foreach ($v_att_list as $v_entry) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   454
      $v_result = $this->privFileDescrParseAtt($v_entry,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   455
                                               $v_filedescr_list[],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   456
                                               $v_options,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   457
                                               $v_supported_attributes);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   458
      if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   459
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   460
        return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   461
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   462
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   463
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   464
    // ----- Expand the filelist (expand directories)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   465
    $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   466
    if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   467
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   468
      return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   469
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   470
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   471
    // ----- Call the create fct
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   472
    $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   473
    if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   474
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   475
      return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   476
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   477
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   478
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   479
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   480
    return $p_result_list;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   481
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   482
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   483
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   484
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   485
  // Function : listContent()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   486
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   487
  //   This public method, gives the list of the files and directories, with their
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   488
  //   properties.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   489
  //   The properties of each entries in the list are (used also in other functions) :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   490
  //     filename : Name of the file. For a create or add action it is the filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   491
  //                given by the user. For an extract function it is the filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   492
  //                of the extracted file.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   493
  //     stored_filename : Name of the file / directory stored in the archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   494
  //     size : Size of the stored file.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   495
  //     compressed_size : Size of the file's data compressed in the archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   496
  //                       (without the headers overhead)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   497
  //     mtime : Last known modification date of the file (UNIX timestamp)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   498
  //     comment : Comment associated with the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   499
  //     folder : true | false
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   500
  //     index : index of the file in the archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   501
  //     status : status of the action (depending of the action) :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   502
  //              Values are :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   503
  //                ok : OK !
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   504
  //                filtered : the file / dir is not extracted (filtered by user)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   505
  //                already_a_directory : the file can not be extracted because a
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   506
  //                                      directory with the same name already exists
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   507
  //                write_protected : the file can not be extracted because a file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   508
  //                                  with the same name already exists and is
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   509
  //                                  write protected
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   510
  //                newer_exist : the file was not extracted because a newer file exists
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   511
  //                path_creation_fail : the file is not extracted because the folder
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   512
  //                                     does not exists and can not be created
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   513
  //                write_error : the file was not extracted because there was a
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   514
  //                              error while writing the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   515
  //                read_error : the file was not extracted because there was a error
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   516
  //                             while reading the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   517
  //                invalid_header : the file was not extracted because of an archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   518
  //                                 format error (bad file header)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   519
  //   Note that each time a method can continue operating when there
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   520
  //   is an action error on a file, the error is only logged in the file status.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   521
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   522
  //   0 on an unrecoverable failure,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   523
  //   The list of the files in the archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   524
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   525
  function listContent()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   526
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   527
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   528
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   529
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   530
    // ----- Reset the error handler
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   531
    $this->privErrorReset();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   532
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   533
    // ----- Check archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   534
    if (!$this->privCheckFormat()) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   535
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   536
      return(0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   537
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   538
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   539
    // ----- Call the extracting fct
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   540
    $p_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   541
    if (($v_result = $this->privList($p_list)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   542
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   543
      unset($p_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   544
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   545
      return(0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   546
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   547
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   548
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   549
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   550
    return $p_list;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   551
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   552
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   553
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   554
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   555
  // Function :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   556
  //   extract($p_path="./", $p_remove_path="")
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   557
  //   extract([$p_option, $p_option_value, ...])
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   558
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   559
  //   This method supports two synopsis. The first one is historical.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   560
  //   This method extract all the files / directories from the archive to the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   561
  //   folder indicated in $p_path.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   562
  //   If you want to ignore the 'root' part of path of the memorized files
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   563
  //   you can indicate this in the optional $p_remove_path parameter.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   564
  //   By default, if a newer file with the same name already exists, the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   565
  //   file is not extracted.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   566
  //
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   567
  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   568
  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   569
  //   at the end of the path value of PCLZIP_OPT_PATH.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   570
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   571
  //   $p_path : Path where the files and directories are to be extracted
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   572
  //   $p_remove_path : First part ('root' part) of the memorized path
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   573
  //                    (if any similar) to remove while extracting.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   574
  // Options :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   575
  //   PCLZIP_OPT_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   576
  //   PCLZIP_OPT_ADD_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   577
  //   PCLZIP_OPT_REMOVE_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   578
  //   PCLZIP_OPT_REMOVE_ALL_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   579
  //   PCLZIP_CB_PRE_EXTRACT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   580
  //   PCLZIP_CB_POST_EXTRACT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   581
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   582
  //   0 or a negative value on failure,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   583
  //   The list of the extracted files, with a status of the action.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   584
  //   (see PclZip::listContent() for list entry format)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   585
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   586
  function extract()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   587
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   588
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   589
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   590
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   591
    // ----- Reset the error handler
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   592
    $this->privErrorReset();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   593
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   594
    // ----- Check archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   595
    if (!$this->privCheckFormat()) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   596
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   597
      return(0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   598
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   599
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   600
    // ----- Set default values
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   601
    $v_options = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   602
//    $v_path = "./";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   603
    $v_path = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   604
    $v_remove_path = "";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   605
    $v_remove_all_path = false;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   606
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   607
    // ----- Look for variable options arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   608
    $v_size = func_num_args();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   609
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   610
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   611
    // ----- Default values for option
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   612
    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   613
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   614
    // ----- Look for arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   615
    if ($v_size > 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   616
      // ----- Get the arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   617
      $v_arg_list = func_get_args();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   618
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   619
      // ----- Look for first arg
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   620
      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   621
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   622
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   623
        // ----- Parse the options
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   624
        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   625
                                            array (PCLZIP_OPT_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   626
                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   627
                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   628
                                                   PCLZIP_OPT_ADD_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   629
                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   630
                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   631
                                                   PCLZIP_OPT_SET_CHMOD => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   632
                                                   PCLZIP_OPT_BY_NAME => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   633
                                                   PCLZIP_OPT_BY_EREG => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   634
                                                   PCLZIP_OPT_BY_PREG => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   635
                                                   PCLZIP_OPT_BY_INDEX => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   636
                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   637
                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   638
                                                   PCLZIP_OPT_REPLACE_NEWER => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   639
                                                   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   640
                                                   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   641
												    ));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   642
        if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   643
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   644
          return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   645
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   646
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   647
        // ----- Set the arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   648
        if (isset($v_options[PCLZIP_OPT_PATH])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   649
          $v_path = $v_options[PCLZIP_OPT_PATH];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   650
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   651
        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   652
          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   653
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   654
        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   655
          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   656
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   657
        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   658
          // ----- Check for '/' in last path char
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   659
          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   660
            $v_path .= '/';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   661
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   662
          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   663
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   664
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   665
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   666
      // ----- Look for 2 args
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   667
      // Here we need to support the first historic synopsis of the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   668
      // method.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   669
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   670
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   671
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   672
        // ----- Get the first argument
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   673
        $v_path = $v_arg_list[0];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   674
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   675
        // ----- Look for the optional second argument
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   676
        if ($v_size == 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   677
          $v_remove_path = $v_arg_list[1];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   678
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   679
        else if ($v_size > 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   680
          // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   681
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   682
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   683
          // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   684
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   685
          return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   686
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   687
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   688
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   689
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   690
    // ----- Trace
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   691
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   692
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   693
    // ----- Call the extracting fct
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   694
    $p_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   695
    $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   696
	                                     $v_remove_all_path, $v_options);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   697
    if ($v_result < 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   698
      unset($p_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   699
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   700
      return(0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   701
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   702
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   703
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   704
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   705
    return $p_list;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   706
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   707
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   708
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   709
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   710
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   711
  // Function :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   712
  //   extractByIndex($p_index, $p_path="./", $p_remove_path="")
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   713
  //   extractByIndex($p_index, [$p_option, $p_option_value, ...])
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   714
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   715
  //   This method supports two synopsis. The first one is historical.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   716
  //   This method is doing a partial extract of the archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   717
  //   The extracted files or folders are identified by their index in the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   718
  //   archive (from 0 to n).
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   719
  //   Note that if the index identify a folder, only the folder entry is
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   720
  //   extracted, not all the files included in the archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   721
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   722
  //   $p_index : A single index (integer) or a string of indexes of files to
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   723
  //              extract. The form of the string is "0,4-6,8-12" with only numbers
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   724
  //              and '-' for range or ',' to separate ranges. No spaces or ';'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   725
  //              are allowed.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   726
  //   $p_path : Path where the files and directories are to be extracted
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   727
  //   $p_remove_path : First part ('root' part) of the memorized path
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   728
  //                    (if any similar) to remove while extracting.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   729
  // Options :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   730
  //   PCLZIP_OPT_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   731
  //   PCLZIP_OPT_ADD_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   732
  //   PCLZIP_OPT_REMOVE_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   733
  //   PCLZIP_OPT_REMOVE_ALL_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   734
  //   PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   735
  //     not as files.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   736
  //     The resulting content is in a new field 'content' in the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   737
  //     structure.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   738
  //     This option must be used alone (any other options are ignored).
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   739
  //   PCLZIP_CB_PRE_EXTRACT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   740
  //   PCLZIP_CB_POST_EXTRACT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   741
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   742
  //   0 on failure,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   743
  //   The list of the extracted files, with a status of the action.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   744
  //   (see PclZip::listContent() for list entry format)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   745
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   746
  //function extractByIndex($p_index, options...)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   747
function extractByIndex($p_index)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   748
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   749
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ...");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   750
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   751
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   752
    // ----- Reset the error handler
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   753
    $this->privErrorReset();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   754
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   755
    // ----- Check archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   756
    if (!$this->privCheckFormat()) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   757
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   758
      return(0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   759
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   760
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   761
    // ----- Set default values
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   762
    $v_options = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   763
//    $v_path = "./";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   764
    $v_path = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   765
    $v_remove_path = "";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   766
    $v_remove_all_path = false;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   767
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   768
    // ----- Look for variable options arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   769
    $v_size = func_num_args();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   770
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   771
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   772
    // ----- Default values for option
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   773
    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   774
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   775
    // ----- Look for arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   776
    if ($v_size > 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   777
      // ----- Get the arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   778
      $v_arg_list = func_get_args();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   779
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   780
      // ----- Remove form the options list the first argument
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   781
      array_shift($v_arg_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   782
      $v_size--;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   783
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   784
      // ----- Look for first arg
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   785
      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   786
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   787
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   788
        // ----- Parse the options
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   789
        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   790
                                            array (PCLZIP_OPT_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   791
                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   792
                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   793
                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   794
                                                   PCLZIP_OPT_ADD_PATH => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   795
                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   796
                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   797
                                                   PCLZIP_OPT_SET_CHMOD => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   798
                                                   PCLZIP_OPT_REPLACE_NEWER => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   799
                                                   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   800
                                                   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   801
												   ));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   802
        if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   803
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   804
          return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   805
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   806
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   807
        // ----- Set the arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   808
        if (isset($v_options[PCLZIP_OPT_PATH])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   809
          $v_path = $v_options[PCLZIP_OPT_PATH];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   810
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   811
        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   812
          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   813
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   814
        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   815
          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   816
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   817
        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   818
          // ----- Check for '/' in last path char
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   819
          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   820
            $v_path .= '/';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   821
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   822
          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   823
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   824
        if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   825
          $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   826
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set.");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   827
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   828
        else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   829
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set.");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   830
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   831
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   832
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   833
      // ----- Look for 2 args
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   834
      // Here we need to support the first historic synopsis of the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   835
      // method.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   836
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   837
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   838
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   839
        // ----- Get the first argument
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   840
        $v_path = $v_arg_list[0];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   841
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   842
        // ----- Look for the optional second argument
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   843
        if ($v_size == 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   844
          $v_remove_path = $v_arg_list[1];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   845
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   846
        else if ($v_size > 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   847
          // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   848
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   849
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   850
          // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   851
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   852
          return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   853
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   854
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   855
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   856
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   857
    // ----- Trace
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   858
    //--(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')."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   859
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   860
    // ----- Trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   861
    // Here I want to reuse extractByRule(), so I need to parse the $p_index
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   862
    // with privParseOptions()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   863
    $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   864
    $v_options_trick = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   865
    $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   866
                                        array (PCLZIP_OPT_BY_INDEX => 'optional' ));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   867
    if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   868
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   869
        return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   870
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   871
    $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   872
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   873
    // ----- Call the extracting fct
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   874
    if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   875
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   876
        return(0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   877
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   878
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   879
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   880
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   881
    return $p_list;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   882
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   883
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   884
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   885
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   886
  // Function :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   887
  //   delete([$p_option, $p_option_value, ...])
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   888
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   889
  //   This method removes files from the archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   890
  //   If no parameters are given, then all the archive is emptied.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   891
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   892
  //   None or optional arguments.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   893
  // Options :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   894
  //   PCLZIP_OPT_BY_INDEX :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   895
  //   PCLZIP_OPT_BY_NAME :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   896
  //   PCLZIP_OPT_BY_EREG : 
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   897
  //   PCLZIP_OPT_BY_PREG :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   898
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   899
  //   0 on failure,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   900
  //   The list of the files which are still present in the archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   901
  //   (see PclZip::listContent() for list entry format)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   902
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   903
  function delete()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   904
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   905
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   906
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   907
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   908
    // ----- Reset the error handler
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   909
    $this->privErrorReset();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   910
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   911
    // ----- Check archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   912
    if (!$this->privCheckFormat()) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   913
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   914
      return(0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   915
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   916
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   917
    // ----- Set default values
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   918
    $v_options = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   919
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   920
    // ----- Look for variable options arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   921
    $v_size = func_num_args();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   922
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   923
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   924
    // ----- Look for arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   925
    if ($v_size > 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   926
      // ----- Get the arguments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   927
      $v_arg_list = func_get_args();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   928
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   929
      // ----- Parse the options
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   930
      $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   931
                                        array (PCLZIP_OPT_BY_NAME => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   932
                                               PCLZIP_OPT_BY_EREG => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   933
                                               PCLZIP_OPT_BY_PREG => 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   934
                                               PCLZIP_OPT_BY_INDEX => 'optional' ));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   935
      if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   936
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   937
          return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   938
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   939
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   940
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   941
    // ----- Magic quotes trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   942
    $this->privDisableMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   943
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   944
    // ----- Call the delete fct
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   945
    $v_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   946
    if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   947
      $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   948
      unset($v_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   949
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   950
      return(0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   951
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   952
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   953
    // ----- Magic quotes trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   954
    $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   955
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   956
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   957
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   958
    return $v_list;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   959
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   960
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   961
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   962
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   963
  // Function : deleteByIndex()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   964
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   965
  //   ***** Deprecated *****
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   966
  //   delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   967
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   968
  function deleteByIndex($p_index)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   969
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   970
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   971
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   972
    $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   973
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   974
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   975
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   976
    return $p_list;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   977
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   978
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   979
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   980
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   981
  // Function : properties()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   982
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   983
  //   This method gives the properties of the archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   984
  //   The properties are :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   985
  //     nb : Number of files in the archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   986
  //     comment : Comment associated with the archive file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   987
  //     status : not_exist, ok
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   988
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   989
  //   None
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   990
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   991
  //   0 on failure,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   992
  //   An array with the archive properties.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   993
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   994
  function properties()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   995
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   996
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   997
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   998
    // ----- Reset the error handler
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   999
    $this->privErrorReset();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1000
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1001
    // ----- Magic quotes trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1002
    $this->privDisableMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1003
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1004
    // ----- Check archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1005
    if (!$this->privCheckFormat()) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1006
      $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1007
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1008
      return(0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1009
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1010
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1011
    // ----- Default properties
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1012
    $v_prop = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1013
    $v_prop['comment'] = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1014
    $v_prop['nb'] = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1015
    $v_prop['status'] = 'not_exist';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1016
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1017
    // ----- Look if file exists
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1018
    if (@is_file($this->zipname))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1019
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1020
      // ----- Open the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1021
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1022
      if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1023
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1024
        $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1025
        
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1026
        // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1027
        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1028
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1029
        // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1030
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1031
        return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1032
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1033
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1034
      // ----- Read the central directory informations
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1035
      $v_central_dir = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1036
      if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1037
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1038
        $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1039
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1040
        return 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1041
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1042
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1043
      // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1044
      $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1045
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1046
      // ----- Set the user attributes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1047
      $v_prop['comment'] = $v_central_dir['comment'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1048
      $v_prop['nb'] = $v_central_dir['entries'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1049
      $v_prop['status'] = 'ok';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1050
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1051
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1052
    // ----- Magic quotes trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1053
    $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1054
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1055
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1056
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1057
    return $v_prop;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1058
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1059
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1060
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1061
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1062
  // Function : duplicate()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1063
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1064
  //   This method creates an archive by copying the content of an other one. If
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1065
  //   the archive already exist, it is replaced by the new one without any warning.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1066
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1067
  //   $p_archive : The filename of a valid archive, or
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1068
  //                a valid PclZip object.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1069
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1070
  //   1 on success.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1071
  //   0 or a negative value on error (error code).
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1072
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1073
  function duplicate($p_archive)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1074
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1075
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1076
    $v_result = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1077
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1078
    // ----- Reset the error handler
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1079
    $this->privErrorReset();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1080
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1081
    // ----- Look if the $p_archive is a PclZip object
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1082
    if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1083
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1084
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1085
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1086
      // ----- Duplicate the archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1087
      $v_result = $this->privDuplicate($p_archive->zipname);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1088
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1089
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1090
    // ----- Look if the $p_archive is a string (so a filename)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1091
    else if (is_string($p_archive))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1092
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1093
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$p_archive'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1094
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1095
      // ----- Check that $p_archive is a valid zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1096
      // TBC : Should also check the archive format
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1097
      if (!is_file($p_archive)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1098
        // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1099
        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1100
        $v_result = PCLZIP_ERR_MISSING_FILE;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1101
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1102
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1103
        // ----- Duplicate the archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1104
        $v_result = $this->privDuplicate($p_archive);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1105
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1106
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1107
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1108
    // ----- Invalid variable
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1109
    else
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1110
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1111
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1112
      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1113
      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1114
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1115
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1116
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1117
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1118
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1119
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1120
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1121
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1122
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1123
  // Function : merge()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1124
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1125
  //   This method merge the $p_archive_to_add archive at the end of the current
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1126
  //   one ($this).
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1127
  //   If the archive ($this) does not exist, the merge becomes a duplicate.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1128
  //   If the $p_archive_to_add archive does not exist, the merge is a success.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1129
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1130
  //   $p_archive_to_add : It can be directly the filename of a valid zip archive,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1131
  //                       or a PclZip object archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1132
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1133
  //   1 on success,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1134
  //   0 or negative values on error (see below).
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1135
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1136
  function merge($p_archive_to_add)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1137
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1138
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1139
    $v_result = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1140
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1141
    // ----- Reset the error handler
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1142
    $this->privErrorReset();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1143
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1144
    // ----- Check archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1145
    if (!$this->privCheckFormat()) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1146
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1147
      return(0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1148
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1149
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1150
    // ----- Look if the $p_archive_to_add is a PclZip object
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1151
    if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1152
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1153
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1154
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1155
      // ----- Merge the archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1156
      $v_result = $this->privMerge($p_archive_to_add);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1157
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1158
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1159
    // ----- Look if the $p_archive_to_add is a string (so a filename)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1160
    else if (is_string($p_archive_to_add))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1161
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1162
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1163
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1164
      // ----- Create a temporary archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1165
      $v_object_archive = new PclZip($p_archive_to_add);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1166
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1167
      // ----- Merge the archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1168
      $v_result = $this->privMerge($v_object_archive);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1169
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1170
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1171
    // ----- Invalid variable
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1172
    else
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1173
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1174
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1175
      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1176
      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1177
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1178
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1179
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1180
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1181
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1182
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1183
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1184
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1185
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1186
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1187
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1188
  // Function : errorCode()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1189
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1190
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1191
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1192
  function errorCode()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1193
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1194
    if (PCLZIP_ERROR_EXTERNAL == 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1195
      return(PclErrorCode());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1196
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1197
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1198
      return($this->error_code);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1199
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1200
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1201
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1202
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1203
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1204
  // Function : errorName()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1205
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1206
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1207
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1208
  function errorName($p_with_code=false)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1209
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1210
    $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1211
                      PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1212
                      PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1213
                      PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1214
                      PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1215
                      PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1216
                      PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1217
                      PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1218
                      PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1219
                      PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1220
                      PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1221
                      PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1222
                      PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1223
                      PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1224
                      PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1225
                      PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1226
                      PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1227
                      PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1228
                      PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1229
                      ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1230
                      ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1231
                    );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1232
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1233
    if (isset($v_name[$this->error_code])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1234
      $v_value = $v_name[$this->error_code];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1235
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1236
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1237
      $v_value = 'NoName';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1238
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1239
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1240
    if ($p_with_code) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1241
      return($v_value.' ('.$this->error_code.')');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1242
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1243
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1244
      return($v_value);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1245
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1246
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1247
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1248
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1249
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1250
  // Function : errorInfo()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1251
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1252
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1253
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1254
  function errorInfo($p_full=false)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1255
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1256
    if (PCLZIP_ERROR_EXTERNAL == 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1257
      return(PclErrorString());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1258
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1259
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1260
      if ($p_full) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1261
        return($this->errorName(true)." : ".$this->error_string);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1262
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1263
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1264
        return($this->error_string." [code ".$this->error_code."]");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1265
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1266
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1267
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1268
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1269
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1270
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1271
// --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1272
// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1273
// *****                                                        *****
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1274
// *****       THESES FUNCTIONS MUST NOT BE USED DIRECTLY       *****
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1275
// --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1276
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1277
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1278
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1279
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1280
  // Function : privCheckFormat()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1281
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1282
  //   This method check that the archive exists and is a valid zip archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1283
  //   Several level of check exists. (futur)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1284
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1285
  //   $p_level : Level of check. Default 0.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1286
  //              0 : Check the first bytes (magic codes) (default value))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1287
  //              1 : 0 + Check the central directory (futur)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1288
  //              2 : 1 + Check each file header (futur)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1289
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1290
  //   true on success,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1291
  //   false on error, the error code is set.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1292
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1293
  function privCheckFormat($p_level=0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1294
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1295
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1296
    $v_result = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1297
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1298
	// ----- Reset the file system cache
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1299
    clearstatcache();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1300
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1301
    // ----- Reset the error handler
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1302
    $this->privErrorReset();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1303
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1304
    // ----- Look if the file exits
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1305
    if (!is_file($this->zipname)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1306
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1307
      PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1308
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1309
      return(false);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1310
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1311
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1312
    // ----- Check that the file is readeable
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1313
    if (!is_readable($this->zipname)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1314
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1315
      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1316
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1317
      return(false);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1318
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1319
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1320
    // ----- Check the magic code
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1321
    // TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1322
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1323
    // ----- Check the central header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1324
    // TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1325
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1326
    // ----- Check each file header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1327
    // TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1328
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1329
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1330
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1331
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1332
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1333
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1334
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1335
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1336
  // Function : privParseOptions()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1337
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1338
  //   This internal methods reads the variable list of arguments ($p_options_list,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1339
  //   $p_size) and generate an array with the options and values ($v_result_list).
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1340
  //   $v_requested_options contains the options that can be present and those that
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1341
  //   must be present.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1342
  //   $v_requested_options is an array, with the option value as key, and 'optional',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1343
  //   or 'mandatory' as value.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1344
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1345
  //   See above.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1346
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1347
  //   1 on success.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1348
  //   0 on failure.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1349
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1350
  function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1351
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1352
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1353
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1354
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1355
    // ----- Read the options
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1356
    $i=0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1357
    while ($i<$p_size) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1358
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1359
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1360
      // ----- Check if the option is supported
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1361
      if (!isset($v_requested_options[$p_options_list[$i]])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1362
        // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1363
        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1364
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1365
        // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1366
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1367
        return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1368
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1369
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1370
      // ----- Look for next option
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1371
      switch ($p_options_list[$i]) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1372
        // ----- Look for options that request a path value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1373
        case PCLZIP_OPT_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1374
        case PCLZIP_OPT_REMOVE_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1375
        case PCLZIP_OPT_ADD_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1376
          // ----- Check the number of parameters
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1377
          if (($i+1) >= $p_size) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1378
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1379
            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1380
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1381
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1382
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1383
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1384
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1385
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1386
          // ----- Get the value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1387
          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1388
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1389
          $i++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1390
        break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1391
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1392
        case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1393
          // ----- Check the number of parameters
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1394
          if (($i+1) >= $p_size) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1395
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1396
            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1397
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1398
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1399
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1400
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1401
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1402
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1403
          // ----- Get the value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1404
          if (   is_string($p_options_list[$i+1])
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1405
              && ($p_options_list[$i+1] != '')) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1406
            $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1407
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1408
            $i++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1409
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1410
          else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1411
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." set with an empty value is ignored.");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1412
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1413
        break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1414
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1415
        // ----- Look for options that request an array of string for value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1416
        case PCLZIP_OPT_BY_NAME :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1417
          // ----- Check the number of parameters
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1418
          if (($i+1) >= $p_size) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1419
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1420
            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1421
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1422
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1423
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1424
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1425
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1426
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1427
          // ----- Get the value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1428
          if (is_string($p_options_list[$i+1])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1429
              $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1430
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1431
          else if (is_array($p_options_list[$i+1])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1432
              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1433
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1434
          else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1435
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1436
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1437
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1438
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1439
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1440
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1441
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1442
          ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1443
          $i++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1444
        break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1445
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1446
        // ----- Look for options that request an EREG or PREG expression
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1447
        case PCLZIP_OPT_BY_EREG :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1448
        case PCLZIP_OPT_BY_PREG :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1449
        //case PCLZIP_OPT_CRYPT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1450
          // ----- Check the number of parameters
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1451
          if (($i+1) >= $p_size) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1452
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1453
            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1454
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1455
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1456
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1457
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1458
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1459
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1460
          // ----- Get the value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1461
          if (is_string($p_options_list[$i+1])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1462
              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1463
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1464
          else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1465
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1466
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1467
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1468
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1469
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1470
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1471
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1472
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1473
          $i++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1474
        break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1475
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1476
        // ----- Look for options that takes a string
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1477
        case PCLZIP_OPT_COMMENT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1478
        case PCLZIP_OPT_ADD_COMMENT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1479
        case PCLZIP_OPT_PREPEND_COMMENT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1480
          // ----- Check the number of parameters
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1481
          if (($i+1) >= $p_size) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1482
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1483
            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1484
			                     "Missing parameter value for option '"
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1485
								 .PclZipUtilOptionText($p_options_list[$i])
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1486
								 ."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1487
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1488
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1489
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1490
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1491
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1492
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1493
          // ----- Get the value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1494
          if (is_string($p_options_list[$i+1])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1495
              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1496
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1497
          else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1498
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1499
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1500
			                     "Wrong parameter value for option '"
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1501
								 .PclZipUtilOptionText($p_options_list[$i])
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1502
								 ."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1503
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1504
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1505
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1506
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1507
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1508
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1509
          $i++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1510
        break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1511
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1512
        // ----- Look for options that request an array of index
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1513
        case PCLZIP_OPT_BY_INDEX :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1514
          // ----- Check the number of parameters
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1515
          if (($i+1) >= $p_size) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1516
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1517
            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1518
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1519
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1520
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1521
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1522
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1523
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1524
          // ----- Get the value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1525
          $v_work_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1526
          if (is_string($p_options_list[$i+1])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1527
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a string '".$p_options_list[$i+1]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1528
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1529
              // ----- Remove spaces
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1530
              $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1531
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1532
              // ----- Parse items
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1533
              $v_work_list = explode(",", $p_options_list[$i+1]);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1534
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1535
          else if (is_integer($p_options_list[$i+1])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1536
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an integer '".$p_options_list[$i+1]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1537
              $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1538
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1539
          else if (is_array($p_options_list[$i+1])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1540
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1541
              $v_work_list = $p_options_list[$i+1];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1542
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1543
          else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1544
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1545
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1546
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1547
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1548
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1549
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1550
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1551
          
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1552
          // ----- Reduce the index list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1553
          // each index item in the list must be a couple with a start and
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1554
          // an end value : [0,3], [5-5], [8-10], ...
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1555
          // ----- Check the format of each item
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1556
          $v_sort_flag=false;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1557
          $v_sort_value=0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1558
          for ($j=0; $j<sizeof($v_work_list); $j++) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1559
              // ----- Explode the item
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1560
              $v_item_list = explode("-", $v_work_list[$j]);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1561
              $v_size_item_list = sizeof($v_item_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1562
              
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1563
              // ----- TBC : Here we might check that each item is a
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1564
              // real integer ...
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1565
              
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1566
              // ----- Look for single value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1567
              if ($v_size_item_list == 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1568
                  // ----- Set the option value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1569
                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1570
                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1571
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1572
              elseif ($v_size_item_list == 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1573
                  // ----- Set the option value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1574
                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1575
                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1576
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1577
              else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1578
                  // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1579
                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1580
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1581
                  // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1582
                  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1583
                  return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1584
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1585
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1586
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extracted index item = [".$v_result_list[$p_options_list[$i]][$j]['start'].",".$v_result_list[$p_options_list[$i]][$j]['end']."]");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1587
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1588
              // ----- Look for list sort
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1589
              if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1590
                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The list should be sorted ...");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1591
                  $v_sort_flag=true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1592
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1593
                  // ----- TBC : An automatic sort should be writen ...
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1594
                  // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1595
                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1596
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1597
                  // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1598
                  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1599
                  return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1600
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1601
              $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1602
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1603
          
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1604
          // ----- Sort the items
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1605
          if ($v_sort_flag) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1606
              // TBC : To Be Completed
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1607
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "List sorting is not yet write ...");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1608
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1609
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1610
          // ----- Next option
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1611
          $i++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1612
        break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1613
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1614
        // ----- Look for options that request no value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1615
        case PCLZIP_OPT_REMOVE_ALL_PATH :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1616
        case PCLZIP_OPT_EXTRACT_AS_STRING :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1617
        case PCLZIP_OPT_NO_COMPRESSION :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1618
        case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1619
        case PCLZIP_OPT_REPLACE_NEWER :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1620
        case PCLZIP_OPT_STOP_ON_ERROR :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1621
          $v_result_list[$p_options_list[$i]] = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1622
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1623
        break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1624
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1625
        // ----- Look for options that request an octal value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1626
        case PCLZIP_OPT_SET_CHMOD :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1627
          // ----- Check the number of parameters
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1628
          if (($i+1) >= $p_size) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1629
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1630
            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1631
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1632
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1633
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1634
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1635
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1636
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1637
          // ----- Get the value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1638
          $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1639
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1640
          $i++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1641
        break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1642
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1643
        // ----- Look for options that request a call-back
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1644
        case PCLZIP_CB_PRE_EXTRACT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1645
        case PCLZIP_CB_POST_EXTRACT :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1646
        case PCLZIP_CB_PRE_ADD :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1647
        case PCLZIP_CB_POST_ADD :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1648
        /* for futur use
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1649
        case PCLZIP_CB_PRE_DELETE :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1650
        case PCLZIP_CB_POST_DELETE :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1651
        case PCLZIP_CB_PRE_LIST :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1652
        case PCLZIP_CB_POST_LIST :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1653
        */
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1654
          // ----- Check the number of parameters
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1655
          if (($i+1) >= $p_size) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1656
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1657
            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1658
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1659
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1660
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1661
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1662
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1663
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1664
          // ----- Get the value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1665
          $v_function_name = $p_options_list[$i+1];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1666
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1667
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1668
          // ----- Check that the value is a valid existing function
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1669
          if (!function_exists($v_function_name)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1670
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1671
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1672
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1673
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1674
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1675
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1676
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1677
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1678
          // ----- Set the attribute
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1679
          $v_result_list[$p_options_list[$i]] = $v_function_name;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1680
          $i++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1681
        break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1682
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1683
        default :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1684
          // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1685
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1686
		                       "Unknown parameter '"
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1687
							   .$p_options_list[$i]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1688
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1689
          // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1690
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1691
          return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1692
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1693
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1694
      // ----- Next options
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1695
      $i++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1696
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1697
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1698
    // ----- Look for mandatory options
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1699
    if ($v_requested_options !== false) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1700
      for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1701
        // ----- Look for mandatory option
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1702
        if ($v_requested_options[$key] == 'mandatory') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1703
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1704
          // ----- Look if present
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1705
          if (!isset($v_result_list[$key])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1706
            // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1707
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1708
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1709
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1710
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1711
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1712
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1713
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1714
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1715
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1716
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1717
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1718
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1719
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1720
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1721
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1722
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1723
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1724
  // Function : privFileDescrParseAtt()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1725
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1726
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1727
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1728
  //   1 on success.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1729
  //   0 on failure.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1730
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1731
  function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1732
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1733
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrParseAtt", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1734
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1735
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1736
    // ----- For each file in the list check the attributes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1737
    foreach ($p_file_list as $v_key => $v_value) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1738
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1739
      // ----- Check if the option is supported
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1740
      if (!isset($v_requested_options[$v_key])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1741
        // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1742
        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1743
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1744
        // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1745
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1746
        return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1747
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1748
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1749
      // ----- Look for attribute
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1750
      switch ($v_key) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1751
        case PCLZIP_ATT_FILE_NAME :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1752
          if (!is_string($v_value)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1753
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1754
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1755
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1756
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1757
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1758
          $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1759
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1760
          
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1761
          if ($p_filedescr['filename'] == '') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1762
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1763
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1764
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1765
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1766
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1767
        break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1768
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1769
        case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1770
          if (!is_string($v_value)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1771
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1772
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1773
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1774
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1775
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1776
          $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1777
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1778
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1779
          if ($p_filedescr['new_short_name'] == '') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1780
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1781
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1782
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1783
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1784
        break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1785
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1786
        case PCLZIP_ATT_FILE_NEW_FULL_NAME :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1787
          if (!is_string($v_value)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1788
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1789
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1790
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1791
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1792
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1793
          $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1794
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1795
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1796
          if ($p_filedescr['new_full_name'] == '') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1797
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1798
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1799
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1800
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1801
        break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1802
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1803
        default :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1804
          // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1805
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1806
		                           "Unknown parameter '".$v_key."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1807
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1808
          // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1809
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1810
          return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1811
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1812
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1813
      // ----- Look for mandatory options
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1814
      if ($v_requested_options !== false) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1815
        for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1816
          // ----- Look for mandatory option
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1817
          if ($v_requested_options[$key] == 'mandatory') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1818
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1819
            // ----- Look if present
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1820
            if (!isset($p_file_list[$key])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1821
              PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1822
              //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1823
              return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1824
            }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1825
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1826
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1827
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1828
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1829
    // end foreach
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1830
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1831
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1832
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1833
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1834
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1835
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1836
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1837
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1838
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1839
  // Function : privFileDescrExpand()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1840
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1841
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1842
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1843
  //   1 on success.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1844
  //   0 on failure.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1845
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1846
  function privFileDescrExpand(&$p_filedescr_list, &$p_options)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1847
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1848
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrExpand", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1849
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1850
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1851
    // ----- Create a result list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1852
    $v_result_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1853
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1854
    // ----- Look each entry
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1855
    for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1856
      // ----- Get filedescr
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1857
      $v_descr = $p_filedescr_list[$i];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1858
      
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1859
      // ----- Reduce the filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1860
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filedescr before reduction :'".$v_descr['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1861
      $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1862
      $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1863
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filedescr after reduction :'".$v_descr['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1864
      
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1865
      // ----- Get type of descr
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1866
      if (!file_exists($v_descr['filename'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1867
        // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1868
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_descr['filename']."' does not exists");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1869
        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exists");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1870
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1871
        // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1872
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1873
        return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1874
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1875
      if (@is_file($v_descr['filename'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1876
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a file");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1877
        $v_descr['type'] = 'file';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1878
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1879
      else if (@is_dir($v_descr['filename'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1880
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a folder");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1881
        $v_descr['type'] = 'folder';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1882
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1883
      else if (@is_link($v_descr['filename'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1884
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : link");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1885
        // skip
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1886
        continue;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1887
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1888
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1889
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : unknown type");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1890
        // skip
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1891
        continue;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1892
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1893
      
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1894
      // ----- Calculate the stored filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1895
      $this->privCalculateStoredFilename($v_descr, $p_options);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1896
      
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1897
      // ----- Add the descriptor in result list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1898
      $v_result_list[sizeof($v_result_list)] = $v_descr;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1899
      
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1900
      // ----- Look for folder
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1901
      if ($v_descr['type'] == 'folder') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1902
        // ----- List of items in folder
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1903
        $v_dirlist_descr = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1904
        $v_dirlist_nb = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1905
        if ($v_folder_handler = @opendir($v_descr['filename'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1906
          while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1907
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for '".$v_item_handler."' in the directory");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1908
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1909
            // ----- Skip '.' and '..'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1910
            if (($v_item_handler == '.') || ($v_item_handler == '..')) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1911
                continue;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1912
            }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1913
            
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1914
            // ----- Compose the full filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1915
            $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1916
            
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1917
            // ----- Look for different stored filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1918
            // Because the name of the folder was changed, the name of the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1919
            // files/sub-folders also change
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1920
            if ($v_descr['stored_filename'] != $v_descr['filename']) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1921
              $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1922
            }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1923
      
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1924
            $v_dirlist_nb++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1925
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1926
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1927
        else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1928
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to open dir '".$v_descr['filename']."' in read mode. Skipped.");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1929
          // TBC : unable to open folder in read mode
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1930
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1931
        
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1932
        // ----- Expand each element of the list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1933
        if ($v_dirlist_nb != 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1934
          // ----- Expand
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1935
          if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1936
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1937
            return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1938
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1939
          
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1940
          // ----- Concat the resulting list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1941
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Merging result list (size '".sizeof($v_result_list)."') with dirlist (size '".sizeof($v_dirlist_descr)."')");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1942
          $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1943
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "merged result list is size '".sizeof($v_result_list)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1944
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1945
        else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1946
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Nothing in this folder to expand.");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1947
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1948
          
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1949
        // ----- Free local array
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1950
        unset($v_dirlist_descr);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1951
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1952
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1953
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1954
    // ----- Get the result list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1955
    $p_filedescr_list = $v_result_list;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1956
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1957
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1958
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1959
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1960
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1961
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1962
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1963
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1964
  // Function : privCreate()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1965
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1966
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1967
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1968
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1969
  function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1970
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1971
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1972
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1973
    $v_list_detail = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1974
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1975
    // ----- Magic quotes trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1976
    $this->privDisableMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1977
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1978
    // ----- Open the file in write mode
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1979
    if (($v_result = $this->privOpenFd('wb')) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1980
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1981
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1982
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1983
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1984
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1985
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1986
    // ----- Add the list of files
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1987
    $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1988
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1989
    // ----- Close
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1990
    $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1991
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1992
    // ----- Magic quotes trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1993
    $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1994
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1995
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1996
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1997
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1998
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1999
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2000
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2001
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2002
  // Function : privAdd()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2003
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2004
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2005
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2006
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2007
  function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2008
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2009
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2010
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2011
    $v_list_detail = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2012
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2013
    // ----- Look if the archive exists or is empty
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2014
    if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2015
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2016
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it.");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2017
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2018
      // ----- Do a create
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2019
      $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2020
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2021
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2022
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2023
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2024
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2025
    // ----- Magic quotes trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2026
    $this->privDisableMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2027
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2028
    // ----- Open the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2029
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2030
    if (($v_result=$this->privOpenFd('rb')) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2031
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2032
      // ----- Magic quotes trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2033
      $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2034
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2035
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2036
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2037
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2038
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2039
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2040
    // ----- Read the central directory informations
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2041
    $v_central_dir = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2042
    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2043
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2044
      $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2045
      $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2046
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2047
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2048
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2049
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2050
    // ----- Go to beginning of File
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2051
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2052
    @rewind($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2053
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2054
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2055
    // ----- Creates a temporay file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2056
    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2057
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2058
    // ----- Open the temporary file in write mode
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2059
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2060
    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2061
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2062
      $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2063
      $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2064
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2065
      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2066
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2067
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2068
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2069
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2070
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2071
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2072
    // ----- Copy the files from the archive to the temporary file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2073
    // TBC : Here I should better append the file and go back to erase the central dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2074
    $v_size = $v_central_dir['offset'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2075
    while ($v_size != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2076
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2077
      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2078
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2079
      $v_buffer = fread($this->zip_fd, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2080
      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2081
      $v_size -= $v_read_size;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2082
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2083
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2084
    // ----- Swap the file descriptor
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2085
    // Here is a trick : I swap the temporary fd with the zip fd, in order to use
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2086
    // the following methods on the temporary fil and not the real archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2087
    $v_swap = $this->zip_fd;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2088
    $this->zip_fd = $v_zip_temp_fd;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2089
    $v_zip_temp_fd = $v_swap;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2090
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2091
    // ----- Add the files
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2092
    $v_header_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2093
    if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2094
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2095
      fclose($v_zip_temp_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2096
      $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2097
      @unlink($v_zip_temp_name);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2098
      $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2099
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2100
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2101
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2102
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2103
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2104
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2105
    // ----- Store the offset of the central dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2106
    $v_offset = @ftell($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2107
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2108
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2109
    // ----- Copy the block of file headers from the old archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2110
    $v_size = $v_central_dir['size'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2111
    while ($v_size != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2112
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2113
      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2114
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2115
      $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2116
      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2117
      $v_size -= $v_read_size;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2118
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2119
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2120
    // ----- Create the Central Dir files header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2121
    for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2122
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2123
      // ----- Create the file header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2124
      if ($v_header_list[$i]['status'] == 'ok') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2125
        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2126
          fclose($v_zip_temp_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2127
          $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2128
          @unlink($v_zip_temp_name);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2129
          $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2130
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2131
          // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2132
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2133
          return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2134
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2135
        $v_count++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2136
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2137
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2138
      // ----- Transform the header to a 'usable' info
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2139
      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2140
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2141
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2142
    // ----- Zip file comment
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2143
    $v_comment = $v_central_dir['comment'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2144
    if (isset($p_options[PCLZIP_OPT_COMMENT])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2145
      $v_comment = $p_options[PCLZIP_OPT_COMMENT];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2146
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2147
    if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2148
      $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2149
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2150
    if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2151
      $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2152
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2153
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2154
    // ----- Calculate the size of the central header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2155
    $v_size = @ftell($this->zip_fd)-$v_offset;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2156
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2157
    // ----- Create the central dir footer
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2158
    if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2159
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2160
      // ----- Reset the file list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2161
      unset($v_header_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2162
      $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2163
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2164
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2165
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2166
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2167
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2168
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2169
    // ----- Swap back the file descriptor
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2170
    $v_swap = $this->zip_fd;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2171
    $this->zip_fd = $v_zip_temp_fd;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2172
    $v_zip_temp_fd = $v_swap;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2173
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2174
    // ----- Close
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2175
    $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2176
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2177
    // ----- Close the temporary file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2178
    @fclose($v_zip_temp_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2179
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2180
    // ----- Magic quotes trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2181
    $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2182
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2183
    // ----- Delete the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2184
    // TBC : I should test the result ...
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2185
    @unlink($this->zipname);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2186
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2187
    // ----- Rename the temporary file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2188
    // TBC : I should test the result ...
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2189
    //@rename($v_zip_temp_name, $this->zipname);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2190
    PclZipUtilRename($v_zip_temp_name, $this->zipname);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2191
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2192
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2193
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2194
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2195
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2196
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2197
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2198
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2199
  // Function : privOpenFd()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2200
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2201
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2202
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2203
  function privOpenFd($p_mode)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2204
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2205
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$p_mode);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2206
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2207
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2208
    // ----- Look if already open
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2209
    if ($this->zip_fd != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2210
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2211
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2212
      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2213
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2214
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2215
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2216
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2217
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2218
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2219
    // ----- Open the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2220
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2221
    if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2222
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2223
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2224
      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2225
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2226
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2227
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2228
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2229
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2230
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2231
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2232
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2233
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2234
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2235
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2236
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2237
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2238
  // Function : privCloseFd()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2239
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2240
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2241
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2242
  function privCloseFd()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2243
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2244
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2245
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2246
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2247
    if ($this->zip_fd != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2248
      @fclose($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2249
    $this->zip_fd = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2250
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2251
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2252
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2253
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2254
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2255
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2256
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2257
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2258
  // Function : privAddList()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2259
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2260
  //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2261
  //   different from the real path of the file. This is usefull if you want to have PclTar
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2262
  //   running in any directory, and memorize relative path from an other directory.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2263
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2264
  //   $p_list : An array containing the file or directory names to add in the tar
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2265
  //   $p_result_list : list of added files with their properties (specially the status field)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2266
  //   $p_add_dir : Path to add in the filename path archived
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2267
  //   $p_remove_dir : Path to remove in the filename path archived
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2268
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2269
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2270
//  function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2271
  function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2272
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2273
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2274
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2275
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2276
    // ----- Add the files
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2277
    $v_header_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2278
    if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2279
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2280
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2281
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2282
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2283
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2284
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2285
    // ----- Store the offset of the central dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2286
    $v_offset = @ftell($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2287
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2288
    // ----- Create the Central Dir files header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2289
    for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2290
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2291
      // ----- Create the file header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2292
      if ($v_header_list[$i]['status'] == 'ok') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2293
        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2294
          // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2295
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2296
          return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2297
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2298
        $v_count++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2299
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2300
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2301
      // ----- Transform the header to a 'usable' info
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2302
      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2303
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2304
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2305
    // ----- Zip file comment
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2306
    $v_comment = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2307
    if (isset($p_options[PCLZIP_OPT_COMMENT])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2308
      $v_comment = $p_options[PCLZIP_OPT_COMMENT];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2309
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2310
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2311
    // ----- Calculate the size of the central header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2312
    $v_size = @ftell($this->zip_fd)-$v_offset;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2313
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2314
    // ----- Create the central dir footer
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2315
    if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2316
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2317
      // ----- Reset the file list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2318
      unset($v_header_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2319
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2320
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2321
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2322
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2323
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2324
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2325
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2326
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2327
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2328
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2329
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2330
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2331
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2332
  // Function : privAddFileList()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2333
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2334
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2335
  //   $p_filedescr_list : An array containing the file description 
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2336
  //                      or directory names to add in the zip
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2337
  //   $p_result_list : list of added files with their properties (specially the status field)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2338
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2339
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2340
  function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2341
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2342
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "filedescr_list");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2343
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2344
    $v_header = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2345
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2346
    // ----- Recuperate the current number of elt in list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2347
    $v_nb = sizeof($p_result_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2348
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have ".$v_nb." elements");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2349
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2350
    // ----- Loop on the files
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2351
    for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2352
      // ----- Format the filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2353
      $p_filedescr_list[$j]['filename']
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2354
      = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2355
      
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2356
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file '".$p_filedescr_list[$j]['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2357
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2358
      // ----- Skip empty file names
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2359
      // TBC : Can this be possible ? not checked in DescrParseAtt ?
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2360
      if ($p_filedescr_list[$j]['filename'] == "") {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2361
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Skip empty filename");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2362
        continue;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2363
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2364
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2365
      // ----- Check the filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2366
      if (!file_exists($p_filedescr_list[$j]['filename'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2367
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_filedescr_list[$j]['filename']."' does not exists");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2368
        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exists");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2369
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2370
        return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2371
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2372
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2373
      // ----- Look if it is a file or a dir with no all path remove option
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2374
      if (   (is_file($p_filedescr_list[$j]['filename']))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2375
          || (   is_dir($p_filedescr_list[$j]['filename'])
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2376
              && (   !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2377
                  || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2378
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2379
        // ----- Add the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2380
        $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2381
                                       $p_options);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2382
        if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2383
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2384
          return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2385
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2386
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2387
        // ----- Store the file infos
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2388
        $p_result_list[$v_nb++] = $v_header;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2389
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2390
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2391
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have ".$v_nb." elements");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2392
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2393
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2394
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2395
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2396
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2397
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2398
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2399
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2400
  // Function : privAddFile()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2401
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2402
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2403
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2404
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2405
  function privAddFile($p_filedescr, &$p_header, &$p_options)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2406
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2407
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='".$p_filedescr['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2408
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2409
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2410
    // ----- Working variable
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2411
    $p_filename = $p_filedescr['filename'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2412
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2413
    // TBC : Already done in the fileAtt check ... ?
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2414
    if ($p_filename == "") {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2415
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2416
      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2417
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2418
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2419
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2420
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2421
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2422
  
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2423
    // ----- Look for a stored different filename 
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2424
    if (isset($p_filedescr['stored_filename'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2425
      $v_stored_filename = $p_filedescr['stored_filename'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2426
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is NOT the same "'.$v_stored_filename.'"');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2427
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2428
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2429
      $v_stored_filename = $p_filedescr['stored_filename'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2430
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is the same');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2431
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2432
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2433
    // ----- Set the file properties
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2434
    clearstatcache();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2435
    $p_header['version'] = 20;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2436
    $p_header['version_extracted'] = 10;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2437
    $p_header['flag'] = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2438
    $p_header['compression'] = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2439
    $p_header['mtime'] = filemtime($p_filename);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2440
    $p_header['crc'] = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2441
    $p_header['compressed_size'] = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2442
    $p_header['size'] = filesize($p_filename);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2443
    $p_header['filename_len'] = strlen($p_filename);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2444
    $p_header['extra_len'] = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2445
    $p_header['comment_len'] = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2446
    $p_header['disk'] = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2447
    $p_header['internal'] = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2448
//    $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2449
    $p_header['external'] = (is_file($p_filename)?0x00000000:0x00000010);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2450
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header external extension '".sprintf("0x%X",$p_header['external'])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2451
    $p_header['offset'] = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2452
    $p_header['filename'] = $p_filename;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2453
    $p_header['stored_filename'] = $v_stored_filename;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2454
    $p_header['extra'] = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2455
    $p_header['comment'] = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2456
    $p_header['status'] = 'ok';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2457
    $p_header['index'] = -1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2458
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2459
    // ----- Look for pre-add callback
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2460
    if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2461
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2462
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2463
      // ----- Generate a local information
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2464
      $v_local_header = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2465
      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2466
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2467
      // ----- Call the callback
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2468
      // Here I do not use call_user_func() because I need to send a reference to the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2469
      // header.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2470
      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2471
      if ($v_result == 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2472
        // ----- Change the file status
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2473
        $p_header['status'] = "skipped";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2474
        $v_result = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2475
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2476
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2477
      // ----- Update the informations
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2478
      // Only some fields can be modified
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2479
      if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2480
        $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2481
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_header['stored_filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2482
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2483
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2484
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2485
    // ----- Look for empty stored filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2486
    if ($p_header['stored_filename'] == "") {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2487
      $p_header['status'] = "filtered";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2488
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2489
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2490
    // ----- Check the path length
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2491
    if (strlen($p_header['stored_filename']) > 0xFF) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2492
      $p_header['status'] = 'filename_too_long';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2493
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2494
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2495
    // ----- Look if no error, or file not skipped
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2496
    if ($p_header['status'] == 'ok') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2497
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2498
      // ----- Look for a file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2499
      if (is_file($p_filename))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2500
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2501
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2502
        // ----- Open the source file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2503
        if (($v_file = @fopen($p_filename, "rb")) == 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2504
          PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2505
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2506
          return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2507
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2508
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2509
        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2510
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2511
          // ----- Read the file content
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2512
          $v_content_compressed = @fread($v_file, $p_header['size']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2513
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2514
          // ----- Calculate the CRC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2515
          $p_header['crc'] = @crc32($v_content_compressed);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2516
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2517
          // ----- Set header parameters
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2518
          $p_header['compressed_size'] = $p_header['size'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2519
          $p_header['compression'] = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2520
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2521
        else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2522
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2523
          // ----- Read the file content
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2524
          $v_content = @fread($v_file, $p_header['size']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2525
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2526
          // ----- Calculate the CRC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2527
          $p_header['crc'] = @crc32($v_content);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2528
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2529
          // ----- Compress the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2530
          $v_content_compressed = @gzdeflate($v_content);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2531
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2532
          // ----- Set header parameters
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2533
          $p_header['compressed_size'] = strlen($v_content_compressed);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2534
          $p_header['compression'] = 8;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2535
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2536
        
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2537
        // ----- Look for encryption
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2538
        /*
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2539
        if ((isset($p_options[PCLZIP_OPT_CRYPT]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2540
		    && ($p_options[PCLZIP_OPT_CRYPT] != "")) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2541
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File need to be crypted ....");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2542
          
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2543
          // Should be a random header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2544
          $v_header = 'xxxxxxxxxxxx';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2545
	      $v_content_compressed = PclZipUtilZipEncrypt($v_content_compressed,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2546
		                                           $p_header['compressed_size'],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2547
	                                               $v_header,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2548
												   $p_header['crc'],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2549
												   "test");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2550
												   
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2551
          $p_header['compressed_size'] += 12;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2552
          $p_header['flag'] = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2553
          
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2554
          // ----- Add the header to the data
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2555
          $v_content_compressed = $v_header.$v_content_compressed;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2556
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size after header : ".strlen($v_content_compressed)."");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2557
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2558
        */
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2559
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2560
        // ----- Call the header generation
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2561
        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2562
          @fclose($v_file);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2563
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2564
          return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2565
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2566
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2567
        // ----- Write the compressed (or not) content
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2568
        @fwrite($this->zip_fd, 
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2569
		            $v_content_compressed, $p_header['compressed_size']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2570
        
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2571
        // ----- Close the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2572
        @fclose($v_file);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2573
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2574
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2575
      // ----- Look for a directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2576
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2577
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a folder");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2578
        // ----- Look for directory last '/'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2579
        if (@substr($p_header['stored_filename'], -1) != '/') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2580
          $p_header['stored_filename'] .= '/';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2581
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2582
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2583
        // ----- Set the file properties
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2584
        $p_header['size'] = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2585
        //$p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2586
        $p_header['external'] = 0x00000010;   // Value for a folder : to be checked
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2587
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2588
        // ----- Call the header generation
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2589
        if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2590
        {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2591
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2592
          return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2593
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2594
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2595
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2596
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2597
    // ----- Look for post-add callback
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2598
    if (isset($p_options[PCLZIP_CB_POST_ADD])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2599
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2600
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2601
      // ----- Generate a local information
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2602
      $v_local_header = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2603
      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2604
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2605
      // ----- Call the callback
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2606
      // Here I do not use call_user_func() because I need to send a reference to the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2607
      // header.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2608
      eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2609
      if ($v_result == 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2610
        // ----- Ignored
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2611
        $v_result = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2612
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2613
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2614
      // ----- Update the informations
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2615
      // Nothing can be modified
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2616
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2617
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2618
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2619
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2620
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2621
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2622
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2623
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2624
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2625
  // Function : privCalculateStoredFilename()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2626
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2627
  //   Based on file descriptor properties and global options, this method
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2628
  //   calculate the filename that will be stored in the archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2629
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2630
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2631
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2632
  function privCalculateStoredFilename(&$p_filedescr, &$p_options)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2633
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2634
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCalculateStoredFilename", "filename='".$p_filedescr['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2635
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2636
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2637
    // ----- Working variables
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2638
    $p_filename = $p_filedescr['filename'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2639
    if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2640
      $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2641
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2642
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2643
      $p_add_dir = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2644
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2645
    if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2646
      $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2647
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2648
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2649
      $p_remove_dir = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2650
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2651
    if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2652
      $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2653
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2654
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2655
      $p_remove_all_dir = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2656
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2657
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2658
    // ----- Look for full name change
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2659
    if (isset($p_filedescr['new_full_name'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2660
      $v_stored_filename = $p_filedescr['new_full_name'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2661
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing full name of '".$p_filename."' for '".$v_stored_filename."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2662
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2663
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2664
    // ----- Look for path and/or short name change
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2665
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2666
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2667
      // ----- Look for short name change
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2668
      if (isset($p_filedescr['new_short_name'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2669
        $v_path_info = pathinfo($p_filename);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2670
        $v_dir = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2671
        if ($v_path_info['dirname'] != '') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2672
          $v_dir = $v_path_info['dirname'].'/';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2673
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2674
        $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2675
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing short name of '".$p_filename."' for '".$v_stored_filename."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2676
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2677
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2678
        // ----- Calculate the stored filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2679
        $v_stored_filename = $p_filename;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2680
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2681
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2682
      // ----- Look for all path to remove
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2683
      if ($p_remove_all_dir) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2684
        $v_stored_filename = basename($p_filename);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2685
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove all path selected change '".$p_filename."' for '".$v_stored_filename."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2686
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2687
      // ----- Look for partial path remove
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2688
      else if ($p_remove_dir != "") {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2689
        if (substr($p_remove_dir, -1) != '/')
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2690
          $p_remove_dir .= "/";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2691
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2692
        if (   (substr($p_filename, 0, 2) == "./")
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2693
            || (substr($p_remove_dir, 0, 2) == "./")) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2694
            
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2695
          if (   (substr($p_filename, 0, 2) == "./")
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2696
              && (substr($p_remove_dir, 0, 2) != "./")) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2697
            $p_remove_dir = "./".$p_remove_dir;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2698
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2699
          if (   (substr($p_filename, 0, 2) != "./")
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2700
              && (substr($p_remove_dir, 0, 2) == "./")) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2701
            $p_remove_dir = substr($p_remove_dir, 2);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2702
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2703
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2704
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2705
        $v_compare = PclZipUtilPathInclusion($p_remove_dir,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2706
                                             $v_stored_filename);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2707
        if ($v_compare > 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2708
          if ($v_compare == 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2709
            $v_stored_filename = "";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2710
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2711
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2712
          else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2713
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$v_stored_filename'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2714
            $v_stored_filename = substr($v_stored_filename,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2715
                                        strlen($p_remove_dir));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2716
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Result is '$v_stored_filename'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2717
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2718
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2719
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2720
      // ----- Look for path to add
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2721
      if ($p_add_dir != "") {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2722
        if (substr($p_add_dir, -1) == "/")
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2723
          $v_stored_filename = $p_add_dir.$v_stored_filename;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2724
        else
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2725
          $v_stored_filename = $p_add_dir."/".$v_stored_filename;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2726
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2727
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2728
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2729
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2730
    // ----- Filename (reduce the path of stored name)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2731
    $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2732
    $p_filedescr['stored_filename'] = $v_stored_filename;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2733
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Stored filename will be '".$p_filedescr['stored_filename']."', strlen ".strlen($p_filedescr['stored_filename']));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2734
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2735
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2736
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2737
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2738
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2739
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2740
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2741
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2742
  // Function : privWriteFileHeader()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2743
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2744
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2745
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2746
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2747
  function privWriteFileHeader(&$p_header)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2748
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2749
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2750
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2751
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2752
    // ----- Store the offset position of the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2753
    $p_header['offset'] = ftell($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2754
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2755
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2756
    // ----- Transform UNIX mtime to DOS format mdate/mtime
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2757
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2758
    $v_date = getdate($p_header['mtime']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2759
    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2760
    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2761
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2762
    // ----- Packed data
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2763
    $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2764
	                      $p_header['version_extracted'], $p_header['flag'],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2765
                          $p_header['compression'], $v_mtime, $v_mdate,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2766
                          $p_header['crc'], $p_header['compressed_size'],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2767
						  $p_header['size'],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2768
                          strlen($p_header['stored_filename']),
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2769
						  $p_header['extra_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2770
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2771
    // ----- Write the first 148 bytes of the header in the archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2772
    fputs($this->zip_fd, $v_binary_data, 30);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2773
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2774
    // ----- Write the variable fields
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2775
    if (strlen($p_header['stored_filename']) != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2776
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2777
      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2778
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2779
    if ($p_header['extra_len'] != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2780
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2781
      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2782
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2783
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2784
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2785
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2786
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2787
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2788
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2789
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2790
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2791
  // Function : privWriteCentralFileHeader()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2792
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2793
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2794
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2795
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2796
  function privWriteCentralFileHeader(&$p_header)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2797
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2798
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2799
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2800
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2801
    // TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2802
    //for(reset($p_header); $key = key($p_header); next($p_header)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2803
    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2804
    //}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2805
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2806
    // ----- Transform UNIX mtime to DOS format mdate/mtime
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2807
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2808
    $v_date = getdate($p_header['mtime']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2809
    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2810
    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2811
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2812
    // ----- Packed data
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2813
    $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2814
	                      $p_header['version'], $p_header['version_extracted'],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2815
                          $p_header['flag'], $p_header['compression'],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2816
						  $v_mtime, $v_mdate, $p_header['crc'],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2817
                          $p_header['compressed_size'], $p_header['size'],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2818
                          strlen($p_header['stored_filename']),
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2819
						  $p_header['extra_len'], $p_header['comment_len'],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2820
                          $p_header['disk'], $p_header['internal'],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2821
						  $p_header['external'], $p_header['offset']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2822
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2823
    // ----- Write the 42 bytes of the header in the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2824
    fputs($this->zip_fd, $v_binary_data, 46);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2825
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2826
    // ----- Write the variable fields
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2827
    if (strlen($p_header['stored_filename']) != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2828
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2829
      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2830
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2831
    if ($p_header['extra_len'] != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2832
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2833
      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2834
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2835
    if ($p_header['comment_len'] != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2836
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2837
      fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2838
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2839
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2840
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2841
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2842
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2843
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2844
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2845
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2846
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2847
  // Function : privWriteCentralHeader()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2848
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2849
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2850
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2851
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2852
  function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2853
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2854
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$p_comment.'"');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2855
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2856
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2857
    // ----- Packed data
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2858
    $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2859
	                      $p_nb_entries, $p_size,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2860
						  $p_offset, strlen($p_comment));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2861
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2862
    // ----- Write the 22 bytes of the header in the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2863
    fputs($this->zip_fd, $v_binary_data, 22);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2864
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2865
    // ----- Write the variable fields
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2866
    if (strlen($p_comment) != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2867
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2868
      fputs($this->zip_fd, $p_comment, strlen($p_comment));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2869
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2870
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2871
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2872
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2873
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2874
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2875
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2876
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2877
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2878
  // Function : privList()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2879
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2880
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2881
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2882
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2883
  function privList(&$p_list)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2884
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2885
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2886
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2887
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2888
    // ----- Magic quotes trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2889
    $this->privDisableMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2890
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2891
    // ----- Open the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2892
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2893
    if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2894
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2895
      // ----- Magic quotes trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2896
      $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2897
      
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2898
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2899
      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2900
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2901
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2902
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2903
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2904
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2905
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2906
    // ----- Read the central directory informations
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2907
    $v_central_dir = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2908
    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2909
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2910
      $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2911
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2912
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2913
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2914
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2915
    // ----- Go to beginning of Central Dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2916
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2917
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2918
    @rewind($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2919
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2920
    if (@fseek($this->zip_fd, $v_central_dir['offset']))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2921
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2922
      $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2923
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2924
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2925
      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2926
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2927
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2928
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2929
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2930
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2931
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2932
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2933
    // ----- Read each entry
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2934
    for ($i=0; $i<$v_central_dir['entries']; $i++)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2935
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2936
      // ----- Read the file header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2937
      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2938
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2939
        $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2940
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2941
        return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2942
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2943
      $v_header['index'] = $i;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2944
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2945
      // ----- Get the only interesting attributes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2946
      $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2947
      unset($v_header);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2948
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2949
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2950
    // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2951
    $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2952
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2953
    // ----- Magic quotes trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2954
    $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2955
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2956
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2957
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2958
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2959
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2960
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2961
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2962
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2963
  // Function : privConvertHeader2FileInfo()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2964
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2965
  //   This function takes the file informations from the central directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2966
  //   entries and extract the interesting parameters that will be given back.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2967
  //   The resulting file infos are set in the array $p_info
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2968
  //     $p_info['filename'] : Filename with full path. Given by user (add),
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2969
  //                           extracted in the filesystem (extract).
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2970
  //     $p_info['stored_filename'] : Stored filename in the archive.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2971
  //     $p_info['size'] = Size of the file.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2972
  //     $p_info['compressed_size'] = Compressed size of the file.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2973
  //     $p_info['mtime'] = Last modification date of the file.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2974
  //     $p_info['comment'] = Comment associated with the file.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2975
  //     $p_info['folder'] = true/false : indicates if the entry is a folder or not.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2976
  //     $p_info['status'] = status of the action on the file.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2977
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2978
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2979
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2980
  function privConvertHeader2FileInfo($p_header, &$p_info)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2981
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2982
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2983
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2984
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2985
    // ----- Get the interesting attributes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2986
    $p_info['filename'] = $p_header['filename'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2987
    $p_info['stored_filename'] = $p_header['stored_filename'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2988
    $p_info['size'] = $p_header['size'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2989
    $p_info['compressed_size'] = $p_header['compressed_size'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2990
    $p_info['mtime'] = $p_header['mtime'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2991
    $p_info['comment'] = $p_header['comment'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2992
    $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2993
    $p_info['index'] = $p_header['index'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2994
    $p_info['status'] = $p_header['status'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2995
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2996
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2997
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2998
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2999
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3000
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3001
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3002
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3003
  // Function : privExtractByRule()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3004
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3005
  //   Extract a file or directory depending of rules (by index, by name, ...)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3006
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3007
  //   $p_file_list : An array where will be placed the properties of each
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3008
  //                  extracted file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3009
  //   $p_path : Path to add while writing the extracted files
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3010
  //   $p_remove_path : Path to remove (from the file memorized path) while writing the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3011
  //                    extracted files. If the path does not match the file path,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3012
  //                    the file is extracted with its memorized path.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3013
  //                    $p_remove_path does not apply to 'list' mode.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3014
  //                    $p_path and $p_remove_path are commulative.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3015
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3016
  //   1 on success,0 or less on error (see error code list)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3017
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3018
  function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3019
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3020
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3021
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3022
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3023
    // ----- Magic quotes trick
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3024
    $this->privDisableMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3025
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3026
    // ----- Check the path
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3027
    if (   ($p_path == "")
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3028
	    || (   (substr($p_path, 0, 1) != "/")
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3029
		    && (substr($p_path, 0, 3) != "../")
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3030
			&& (substr($p_path,1,2)!=":/")))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3031
      $p_path = "./".$p_path;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3032
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3033
    // ----- Reduce the path last (and duplicated) '/'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3034
    if (($p_path != "./") && ($p_path != "/"))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3035
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3036
      // ----- Look for the path end '/'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3037
      while (substr($p_path, -1) == "/")
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3038
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3039
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3040
        $p_path = substr($p_path, 0, strlen($p_path)-1);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3041
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3042
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3043
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3044
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3045
    // ----- Look for path to remove format (should end by /)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3046
    if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3047
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3048
      $p_remove_path .= '/';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3049
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3050
    $p_remove_path_size = strlen($p_remove_path);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3051
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3052
    // ----- Open the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3053
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3054
    if (($v_result = $this->privOpenFd('rb')) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3055
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3056
      $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3057
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3058
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3059
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3060
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3061
    // ----- Read the central directory informations
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3062
    $v_central_dir = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3063
    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3064
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3065
      // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3066
      $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3067
      $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3068
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3069
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3070
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3071
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3072
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3073
    // ----- Start at beginning of Central Dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3074
    $v_pos_entry = $v_central_dir['offset'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3075
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3076
    // ----- Read each entry
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3077
    $j_start = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3078
    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3079
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3080
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3081
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3082
      // ----- Read next Central dir entry
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3083
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3084
      @rewind($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3085
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3086
      if (@fseek($this->zip_fd, $v_pos_entry))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3087
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3088
        // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3089
        $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3090
        $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3091
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3092
        // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3093
        PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3094
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3095
        // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3096
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3097
        return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3098
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3099
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3100
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3101
      // ----- Read the file header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3102
      $v_header = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3103
      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3104
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3105
        // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3106
        $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3107
        $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3108
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3109
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3110
        return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3111
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3112
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3113
      // ----- Store the index
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3114
      $v_header['index'] = $i;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3115
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3116
      // ----- Store the file position
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3117
      $v_pos_entry = ftell($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3118
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3119
      // ----- Look for the specific extract rules
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3120
      $v_extract = false;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3121
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3122
      // ----- Look for extract by name rule
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3123
      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3124
          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3125
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3126
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3127
          // ----- Look if the filename is in the list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3128
          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3129
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3130
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3131
              // ----- Look for a directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3132
              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3133
                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3134
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3135
                  // ----- Look if the directory is in the filename path
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3136
                  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3137
                      && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3138
                      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3139
                      $v_extract = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3140
                  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3141
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3142
              // ----- Look for a filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3143
              elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3144
                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3145
                  $v_extract = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3146
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3147
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3148
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3149
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3150
      // ----- Look for extract by ereg rule
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3151
      else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3152
               && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3153
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3154
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3155
          if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3156
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3157
              $v_extract = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3158
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3159
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3160
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3161
      // ----- Look for extract by preg rule
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3162
      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3163
               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3164
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3165
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3166
          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3167
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3168
              $v_extract = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3169
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3170
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3171
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3172
      // ----- Look for extract by index rule
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3173
      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3174
               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3175
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3176
          
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3177
          // ----- Look if the index is in the list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3178
          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3179
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3180
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3181
              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3182
                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3183
                  $v_extract = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3184
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3185
              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3186
                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3187
                  $j_start = $j+1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3188
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3189
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3190
              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3191
                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3192
                  break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3193
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3194
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3195
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3196
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3197
      // ----- Look for no rule, which means extract all the archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3198
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3199
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3200
          $v_extract = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3201
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3202
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3203
	  // ----- Check compression method
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3204
	  if (   ($v_extract)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3205
	      && (   ($v_header['compression'] != 8)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3206
		      && ($v_header['compression'] != 0))) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3207
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported compression method (".$v_header['compression'].")");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3208
          $v_header['status'] = 'unsupported_compression';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3209
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3210
          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3211
          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3212
		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3213
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3214
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3215
              $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3216
              
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3217
              PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3218
			                       "Filename '".$v_header['stored_filename']."' is "
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3219
				  	    	  	   ."compressed by an unsupported compression "
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3220
				  	    	  	   ."method (".$v_header['compression'].") ");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3221
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3222
              //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3223
              return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3224
		  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3225
	  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3226
	  
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3227
	  // ----- Check encrypted files
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3228
	  if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3229
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported file encryption");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3230
          $v_header['status'] = 'unsupported_encryption';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3231
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3232
          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3233
          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3234
		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3235
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3236
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3237
              $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3238
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3239
              PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3240
			                       "Unsupported encryption for "
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3241
				  	    	  	   ." filename '".$v_header['stored_filename']
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3242
								   ."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3243
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3244
              //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3245
              return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3246
		  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3247
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3248
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3249
      // ----- Look for real extraction
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3250
      if (($v_extract) && ($v_header['status'] != 'ok')) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3251
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "No need for extract");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3252
          $v_result = $this->privConvertHeader2FileInfo($v_header,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3253
		                                        $p_file_list[$v_nb_extracted++]);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3254
          if ($v_result != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3255
              $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3256
              $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3257
              //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3258
              return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3259
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3260
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3261
          $v_extract = false;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3262
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3263
      
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3264
      // ----- Look for real extraction
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3265
      if ($v_extract)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3266
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3267
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3268
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3269
        // ----- Go to the file position
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3270
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3271
        @rewind($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3272
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3273
        if (@fseek($this->zip_fd, $v_header['offset']))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3274
        {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3275
          // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3276
          $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3277
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3278
          $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3279
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3280
          // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3281
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3282
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3283
          // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3284
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3285
          return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3286
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3287
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3288
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3289
        // ----- Look for extraction as string
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3290
        if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3291
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3292
          // ----- Extracting the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3293
          $v_result1 = $this->privExtractFileAsString($v_header, $v_string);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3294
          if ($v_result1 < 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3295
            $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3296
            $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3297
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3298
            return $v_result1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3299
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3300
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3301
          // ----- Get the only interesting attributes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3302
          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3303
          {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3304
            // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3305
            $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3306
            $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3307
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3308
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3309
            return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3310
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3311
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3312
          // ----- Set the file content
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3313
          $p_file_list[$v_nb_extracted]['content'] = $v_string;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3314
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3315
          // ----- Next extracted file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3316
          $v_nb_extracted++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3317
          
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3318
          // ----- Look for user callback abort
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3319
          if ($v_result1 == 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3320
          	break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3321
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3322
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3323
        // ----- Look for extraction in standard output
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3324
        elseif (   (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3325
		        && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3326
          // ----- Extracting the file in standard output
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3327
          $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3328
          if ($v_result1 < 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3329
            $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3330
            $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3331
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3332
            return $v_result1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3333
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3334
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3335
          // ----- Get the only interesting attributes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3336
          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3337
            $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3338
            $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3339
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3340
            return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3341
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3342
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3343
          // ----- Look for user callback abort
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3344
          if ($v_result1 == 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3345
          	break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3346
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3347
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3348
        // ----- Look for normal extraction
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3349
        else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3350
          // ----- Extracting the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3351
          $v_result1 = $this->privExtractFile($v_header,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3352
		                                      $p_path, $p_remove_path,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3353
											  $p_remove_all_path,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3354
											  $p_options);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3355
          if ($v_result1 < 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3356
            $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3357
            $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3358
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3359
            return $v_result1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3360
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3361
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3362
          // ----- Get the only interesting attributes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3363
          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3364
          {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3365
            // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3366
            $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3367
            $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3368
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3369
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3370
            return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3371
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3372
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3373
          // ----- Look for user callback abort
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3374
          if ($v_result1 == 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3375
          	break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3376
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3377
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3378
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3379
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3380
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3381
    // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3382
    $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3383
    $this->privSwapBackMagicQuotes();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3384
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3385
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3386
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3387
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3388
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3389
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3390
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3391
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3392
  // Function : privExtractFile()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3393
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3394
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3395
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3396
  //
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3397
  // 1 : ... ?
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3398
  // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3399
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3400
  function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3401
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3402
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3403
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3404
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3405
    // ----- Read the file header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3406
    if (($v_result = $this->privReadFileHeader($v_header)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3407
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3408
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3409
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3410
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3411
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3412
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3413
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3414
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3415
    // ----- Check that the file header is coherent with $p_entry info
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3416
    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3417
        // TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3418
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3419
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3420
    // ----- Look for all path to remove
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3421
    if ($p_remove_all_path == true) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3422
        // ----- Look for folder entry that not need to be extracted
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3423
        if (($p_entry['external']&0x00000010)==0x00000010) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3424
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The entry is a folder : need to be filtered");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3425
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3426
            $p_entry['status'] = "filtered";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3427
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3428
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3429
            return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3430
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3431
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3432
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "All path is removed");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3433
        // ----- Get the basename of the path
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3434
        $p_entry['filename'] = basename($p_entry['filename']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3435
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3436
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3437
    // ----- Look for path to remove
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3438
    else if ($p_remove_path != "")
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3439
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3440
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look for some path to remove");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3441
      if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3442
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3443
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3444
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3445
        // ----- Change the file status
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3446
        $p_entry['status'] = "filtered";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3447
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3448
        // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3449
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3450
        return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3451
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3452
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3453
      $p_remove_path_size = strlen($p_remove_path);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3454
      if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3455
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3456
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3457
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3458
        // ----- Remove the path
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3459
        $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3460
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3461
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3462
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3463
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3464
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3465
    // ----- Add the path
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3466
    if ($p_path != '') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3467
      $p_entry['filename'] = $p_path."/".$p_entry['filename'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3468
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3469
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3470
    // ----- Check a base_dir_restriction
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3471
    if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3472
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Check the extract directory restriction");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3473
      $v_inclusion
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3474
      = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3475
                                $p_entry['filename']); 
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3476
      if ($v_inclusion == 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3477
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_EXTRACT_DIR_RESTRICTION is selected, file is outside restriction");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3478
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3479
        PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3480
			                     "Filename '".$p_entry['filename']."' is "
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3481
								 ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3482
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3483
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3484
        return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3485
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3486
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3487
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3488
    // ----- Look for pre-extract callback
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3489
    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3490
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3491
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3492
      // ----- Generate a local information
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3493
      $v_local_header = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3494
      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3495
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3496
      // ----- Call the callback
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3497
      // Here I do not use call_user_func() because I need to send a reference to the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3498
      // header.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3499
      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3500
      if ($v_result == 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3501
        // ----- Change the file status
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3502
        $p_entry['status'] = "skipped";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3503
        $v_result = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3504
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3505
      
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3506
      // ----- Look for abort result
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3507
      if ($v_result == 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3508
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3509
        // ----- This status is internal and will be changed in 'skipped'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3510
        $p_entry['status'] = "aborted";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3511
      	$v_result = PCLZIP_ERR_USER_ABORTED;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3512
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3513
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3514
      // ----- Update the informations
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3515
      // Only some fields can be modified
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3516
      $p_entry['filename'] = $v_local_header['filename'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3517
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3518
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3519
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3520
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3521
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3522
    // ----- Look if extraction should be done
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3523
    if ($p_entry['status'] == 'ok') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3524
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3525
    // ----- Look for specific actions while the file exist
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3526
    if (file_exists($p_entry['filename']))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3527
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3528
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3529
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3530
      // ----- Look if file is a directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3531
      if (is_dir($p_entry['filename']))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3532
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3533
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3534
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3535
        // ----- Change the file status
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3536
        $p_entry['status'] = "already_a_directory";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3537
        
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3538
        // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3539
        // For historical reason first PclZip implementation does not stop
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3540
        // when this kind of error occurs.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3541
        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3542
		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3543
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3544
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3545
            PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3546
			                     "Filename '".$p_entry['filename']."' is "
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3547
								 ."already used by an existing directory");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3548
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3549
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3550
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3551
		}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3552
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3553
      // ----- Look if file is write protected
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3554
      else if (!is_writeable($p_entry['filename']))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3555
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3556
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3557
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3558
        // ----- Change the file status
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3559
        $p_entry['status'] = "write_protected";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3560
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3561
        // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3562
        // For historical reason first PclZip implementation does not stop
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3563
        // when this kind of error occurs.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3564
        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3565
		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3566
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3567
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3568
            PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3569
			                     "Filename '".$p_entry['filename']."' exists "
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3570
								 ."and is write protected");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3571
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3572
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3573
            return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3574
		}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3575
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3576
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3577
      // ----- Look if the extracted file is older
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3578
      else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3579
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3580
        //--(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']).")");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3581
        // ----- Change the file status
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3582
        if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3583
		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3584
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_REPLACE_NEWER is selected, file will be replaced");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3585
		}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3586
		else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3587
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be replaced");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3588
            $p_entry['status'] = "newer_exist";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3589
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3590
            // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3591
            // For historical reason first PclZip implementation does not stop
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3592
            // when this kind of error occurs.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3593
            if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3594
		        && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3595
                //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3596
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3597
                PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3598
			             "Newer version of '".$p_entry['filename']."' exists "
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3599
					    ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3600
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3601
                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3602
                return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3603
		    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3604
		}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3605
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3606
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3607
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is older than the extrated one - will be replaced by the extracted one (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3608
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3609
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3610
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3611
    // ----- Check the directory availability and create it if necessary
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3612
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3613
      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3614
        $v_dir_to_check = $p_entry['filename'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3615
      else if (!strstr($p_entry['filename'], "/"))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3616
        $v_dir_to_check = "";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3617
      else
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3618
        $v_dir_to_check = dirname($p_entry['filename']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3619
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3620
      if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3621
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3622
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3623
        // ----- Change the file status
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3624
        $p_entry['status'] = "path_creation_fail";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3625
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3626
        // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3627
        ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3628
        //return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3629
        $v_result = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3630
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3631
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3632
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3633
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3634
    // ----- Look if extraction should be done
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3635
    if ($p_entry['status'] == 'ok') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3636
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3637
      // ----- Do the extraction (if not a folder)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3638
      if (!(($p_entry['external']&0x00000010)==0x00000010))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3639
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3640
        // ----- Look for not compressed file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3641
        if ($p_entry['compression'] == 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3642
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3643
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3644
		  // ----- Opening destination file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3645
          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3646
          {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3647
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3648
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3649
            // ----- Change the file status
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3650
            $p_entry['status'] = "write_error";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3651
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3652
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3653
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3654
            return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3655
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3656
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3657
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read '".$p_entry['size']."' bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3658
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3659
          // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3660
          $v_size = $p_entry['compressed_size'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3661
          while ($v_size != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3662
          {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3663
            $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3664
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3665
            $v_buffer = @fread($this->zip_fd, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3666
            /* Try to speed up the code
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3667
            $v_binary_data = pack('a'.$v_read_size, $v_buffer);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3668
            @fwrite($v_dest_file, $v_binary_data, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3669
            */
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3670
            @fwrite($v_dest_file, $v_buffer, $v_read_size);            
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3671
            $v_size -= $v_read_size;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3672
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3673
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3674
          // ----- Closing the destination file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3675
          fclose($v_dest_file);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3676
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3677
          // ----- Change the file mtime
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3678
          touch($p_entry['filename'], $p_entry['mtime']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3679
          
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3680
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3681
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3682
        else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3683
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (Compression method ".$p_entry['compression'].")");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3684
          // ----- TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3685
          // Need to be finished
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3686
          if (($p_entry['flag'] & 1) == 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3687
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File is encrypted");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3688
            /*
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3689
              // ----- Read the encryption header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3690
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read 12 encryption header bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3691
              $v_encryption_header = @fread($this->zip_fd, 12);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3692
              
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3693
              // ----- Read the encrypted & compressed file in a buffer
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3694
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".($p_entry['compressed_size']-12)."' compressed & encrypted bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3695
              $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']-12);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3696
              
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3697
              // ----- Decrypt the buffer
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3698
              $this->privDecrypt($v_encryption_header, $v_buffer,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3699
			                     $p_entry['compressed_size']-12, $p_entry['crc']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3700
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Buffer is '".$v_buffer."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3701
              */
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3702
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3703
          else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3704
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".$p_entry['compressed_size']."' compressed bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3705
              // ----- Read the compressed file in a buffer (one shot)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3706
              $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3707
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3708
          
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3709
          // ----- Decompress the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3710
          $v_file_content = @gzinflate($v_buffer);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3711
          unset($v_buffer);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3712
          if ($v_file_content === FALSE) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3713
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to inflate compressed file");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3714
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3715
            // ----- Change the file status
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3716
            // TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3717
            $p_entry['status'] = "error";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3718
            
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3719
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3720
            return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3721
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3722
          
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3723
          // ----- Opening destination file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3724
          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3725
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3726
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3727
            // ----- Change the file status
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3728
            $p_entry['status'] = "write_error";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3729
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3730
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3731
            return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3732
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3733
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3734
          // ----- Write the uncompressed data
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3735
          @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3736
          unset($v_file_content);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3737
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3738
          // ----- Closing the destination file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3739
          @fclose($v_dest_file);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3740
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3741
          // ----- Change the file mtime
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3742
          @touch($p_entry['filename'], $p_entry['mtime']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3743
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3744
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3745
        // ----- Look for chmod option
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3746
        if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3747
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3748
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3749
          // ----- Change the mode of the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3750
          @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3751
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3752
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3753
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3754
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3755
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3756
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3757
	// ----- Change abort status
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3758
	if ($p_entry['status'] == "aborted") {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3759
      $p_entry['status'] = "skipped";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3760
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3761
	
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3762
    // ----- Look for post-extract callback
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3763
    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3764
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3765
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3766
      // ----- Generate a local information
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3767
      $v_local_header = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3768
      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3769
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3770
      // ----- Call the callback
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3771
      // Here I do not use call_user_func() because I need to send a reference to the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3772
      // header.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3773
      eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3774
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3775
      // ----- Look for abort result
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3776
      if ($v_result == 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3777
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3778
      	$v_result = PCLZIP_ERR_USER_ABORTED;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3779
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3780
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3781
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3782
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3783
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3784
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3785
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3786
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3787
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3788
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3789
  // Function : privExtractFileInOutput()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3790
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3791
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3792
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3793
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3794
  function privExtractFileInOutput(&$p_entry, &$p_options)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3795
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3796
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileInOutput', "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3797
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3798
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3799
    // ----- Read the file header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3800
    if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3801
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3802
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3803
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3804
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3805
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3806
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3807
    // ----- Check that the file header is coherent with $p_entry info
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3808
    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3809
        // TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3810
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3811
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3812
    // ----- Look for pre-extract callback
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3813
    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3814
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3815
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3816
      // ----- Generate a local information
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3817
      $v_local_header = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3818
      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3819
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3820
      // ----- Call the callback
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3821
      // Here I do not use call_user_func() because I need to send a reference to the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3822
      // header.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3823
      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3824
      if ($v_result == 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3825
        // ----- Change the file status
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3826
        $p_entry['status'] = "skipped";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3827
        $v_result = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3828
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3829
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3830
      // ----- Look for abort result
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3831
      if ($v_result == 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3832
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3833
        // ----- This status is internal and will be changed in 'skipped'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3834
        $p_entry['status'] = "aborted";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3835
      	$v_result = PCLZIP_ERR_USER_ABORTED;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3836
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3837
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3838
      // ----- Update the informations
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3839
      // Only some fields can be modified
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3840
      $p_entry['filename'] = $v_local_header['filename'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3841
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3842
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3843
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3844
    // ----- Trace
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3845
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3846
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3847
    // ----- Look if extraction should be done
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3848
    if ($p_entry['status'] == 'ok') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3849
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3850
      // ----- Do the extraction (if not a folder)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3851
      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3852
        // ----- Look for not compressed file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3853
        if ($p_entry['compressed_size'] == $p_entry['size']) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3854
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3855
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3856
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3857
          // ----- Read the file in a buffer (one shot)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3858
          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3859
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3860
          // ----- Send the file to the output
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3861
          echo $v_buffer;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3862
          unset($v_buffer);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3863
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3864
        else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3865
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3866
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3867
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3868
          // ----- Read the compressed file in a buffer (one shot)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3869
          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3870
          
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3871
          // ----- Decompress the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3872
          $v_file_content = gzinflate($v_buffer);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3873
          unset($v_buffer);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3874
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3875
          // ----- Send the file to the output
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3876
          echo $v_file_content;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3877
          unset($v_file_content);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3878
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3879
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3880
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3881
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3882
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3883
	// ----- Change abort status
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3884
	if ($p_entry['status'] == "aborted") {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3885
      $p_entry['status'] = "skipped";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3886
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3887
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3888
    // ----- Look for post-extract callback
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3889
    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3890
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3891
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3892
      // ----- Generate a local information
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3893
      $v_local_header = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3894
      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3895
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3896
      // ----- Call the callback
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3897
      // Here I do not use call_user_func() because I need to send a reference to the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3898
      // header.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3899
      eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3900
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3901
      // ----- Look for abort result
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3902
      if ($v_result == 2) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3903
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3904
      	$v_result = PCLZIP_ERR_USER_ABORTED;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3905
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3906
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3907
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3908
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3909
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3910
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3911
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3912
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3913
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3914
  // Function : privExtractFileAsString()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3915
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3916
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3917
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3918
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3919
  function privExtractFileAsString(&$p_entry, &$p_string)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3920
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3921
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3922
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3923
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3924
    // ----- Read the file header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3925
    $v_header = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3926
    if (($v_result = $this->privReadFileHeader($v_header)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3927
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3928
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3929
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3930
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3931
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3932
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3933
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3934
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3935
    // ----- Check that the file header is coherent with $p_entry info
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3936
    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3937
        // TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3938
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3939
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3940
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3941
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3942
    // ----- Do the extraction (if not a folder)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3943
    if (!(($p_entry['external']&0x00000010)==0x00000010))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3944
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3945
      // ----- Look for not compressed file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3946
//      if ($p_entry['compressed_size'] == $p_entry['size'])
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3947
      if ($p_entry['compression'] == 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3948
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3949
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3950
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3951
        // ----- Reading the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3952
        $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3953
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3954
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3955
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (compression method '".$p_entry['compression']."')");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3956
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3957
        // ----- Reading the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3958
        $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3959
        
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3960
        // ----- Decompress the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3961
        if (($p_string = @gzinflate($v_data)) === FALSE) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3962
            // TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3963
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3964
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3965
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3966
      // ----- Trace
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3967
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3968
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3969
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3970
        // TBC : error : can not extract a folder in a string
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3971
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3972
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3973
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3974
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3975
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3976
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3977
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3978
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3979
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3980
  // Function : privReadFileHeader()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3981
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3982
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3983
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3984
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3985
  function privReadFileHeader(&$p_header)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3986
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3987
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3988
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3989
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3990
    // ----- Read the 4 bytes signature
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3991
    $v_binary_data = @fread($this->zip_fd, 4);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3992
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3993
    $v_data = unpack('Vid', $v_binary_data);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3994
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3995
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3996
    // ----- Check signature
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3997
    if ($v_data['id'] != 0x04034b50)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3998
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3999
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4000
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4001
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4002
      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4003
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4004
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4005
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4006
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4007
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4008
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4009
    // ----- Read the first 42 bytes of the header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4010
    $v_binary_data = fread($this->zip_fd, 26);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4011
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4012
    // ----- Look for invalid block size
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4013
    if (strlen($v_binary_data) != 26)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4014
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4015
      $p_header['filename'] = "";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4016
      $p_header['status'] = "invalid_header";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4017
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4018
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4019
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4020
      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4021
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4022
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4023
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4024
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4025
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4026
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4027
    // ----- Extract the values
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4028
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4029
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4030
    $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4031
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4032
    // ----- Get filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4033
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4034
    $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4035
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4036
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4037
    // ----- Get extra_fields
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4038
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4039
    if ($v_data['extra_len'] != 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4040
      $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4041
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4042
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4043
      $p_header['extra'] = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4044
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4045
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4046
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4047
    // ----- Extract properties
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4048
    $p_header['version_extracted'] = $v_data['version'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4049
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : ('.$p_header['version_extracted'].') \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4050
    $p_header['compression'] = $v_data['compression'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4051
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.$p_header['compression'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4052
    $p_header['size'] = $v_data['size'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4053
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4054
    $p_header['compressed_size'] = $v_data['compressed_size'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4055
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4056
    $p_header['crc'] = $v_data['crc'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4057
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4058
    $p_header['flag'] = $v_data['flag'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4059
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4060
    $p_header['filename_len'] = $v_data['filename_len'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4061
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename_len : \''.$p_header['filename_len'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4062
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4063
    // ----- Recuperate date in UNIX format
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4064
    $p_header['mdate'] = $v_data['mdate'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4065
    $p_header['mtime'] = $v_data['mtime'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4066
    if ($p_header['mdate'] && $p_header['mtime'])
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4067
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4068
      // ----- Extract time
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4069
      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4070
      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4071
      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4072
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4073
      // ----- Extract date
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4074
      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4075
      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4076
      $v_day = $p_header['mdate'] & 0x001F;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4077
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4078
      // ----- Get UNIX date format
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4079
      $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4080
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4081
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4082
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4083
    else
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4084
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4085
      $p_header['mtime'] = time();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4086
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4087
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4088
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4089
    // TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4090
    //for(reset($v_data); $key = key($v_data); next($v_data)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4091
    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4092
    //}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4093
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4094
    // ----- Set the stored filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4095
    $p_header['stored_filename'] = $p_header['filename'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4096
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4097
    // ----- Set the status field
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4098
    $p_header['status'] = "ok";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4099
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4100
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4101
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4102
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4103
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4104
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4105
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4106
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4107
  // Function : privReadCentralFileHeader()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4108
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4109
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4110
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4111
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4112
  function privReadCentralFileHeader(&$p_header)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4113
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4114
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4115
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4116
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4117
    // ----- Read the 4 bytes signature
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4118
    $v_binary_data = @fread($this->zip_fd, 4);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4119
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4120
    $v_data = unpack('Vid', $v_binary_data);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4121
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4122
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4123
    // ----- Check signature
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4124
    if ($v_data['id'] != 0x02014b50)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4125
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4126
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4127
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4128
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4129
      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4130
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4131
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4132
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4133
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4134
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4135
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4136
    // ----- Read the first 42 bytes of the header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4137
    $v_binary_data = fread($this->zip_fd, 42);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4138
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4139
    // ----- Look for invalid block size
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4140
    if (strlen($v_binary_data) != 42)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4141
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4142
      $p_header['filename'] = "";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4143
      $p_header['status'] = "invalid_header";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4144
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4145
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4146
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4147
      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4148
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4149
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4150
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4151
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4152
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4153
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4154
    // ----- Extract the values
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4155
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4156
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4157
    $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);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4158
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4159
    // ----- Get filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4160
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4161
    if ($p_header['filename_len'] != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4162
      $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4163
    else
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4164
      $p_header['filename'] = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4165
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4166
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4167
    // ----- Get extra
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4168
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4169
    if ($p_header['extra_len'] != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4170
      $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4171
    else
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4172
      $p_header['extra'] = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4173
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4174
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4175
    // ----- Get comment
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4176
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4177
    if ($p_header['comment_len'] != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4178
      $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4179
    else
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4180
      $p_header['comment'] = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4181
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4182
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4183
    // ----- Extract properties
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4184
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4185
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4186
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4187
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4188
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4189
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4190
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4191
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4192
    // ----- Recuperate date in UNIX format
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4193
    if ($p_header['mdate'] && $p_header['mtime'])
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4194
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4195
      // ----- Extract time
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4196
      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4197
      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4198
      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4199
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4200
      // ----- Extract date
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4201
      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4202
      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4203
      $v_day = $p_header['mdate'] & 0x001F;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4204
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4205
      // ----- Get UNIX date format
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4206
      $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4207
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4208
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4209
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4210
    else
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4211
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4212
      $p_header['mtime'] = time();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4213
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4214
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4215
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4216
    // ----- Set the stored filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4217
    $p_header['stored_filename'] = $p_header['filename'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4218
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4219
    // ----- Set default status to ok
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4220
    $p_header['status'] = 'ok';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4221
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4222
    // ----- Look if it is a directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4223
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4224
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "External (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".(($p_header['external']&0x00000010)==0x00000010?'is a folder':'is a file').')');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4225
    if (substr($p_header['filename'], -1) == '/') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4226
      //$p_header['external'] = 0x41FF0010;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4227
      $p_header['external'] = 0x00000010;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4228
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.sprintf("Ox%04X", $p_header['external']).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4229
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4230
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4231
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4232
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4233
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4234
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4235
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4236
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4237
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4238
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4239
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4240
  // Function : privCheckFileHeaders()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4241
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4242
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4243
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4244
  //   1 on success,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4245
  //   0 on error;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4246
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4247
  function privCheckFileHeaders(&$p_local_header, &$p_central_header)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4248
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4249
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFileHeaders", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4250
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4251
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4252
	// ----- Check the static values
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4253
	// TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4254
	if ($p_local_header['filename'] != $p_central_header['filename']) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4255
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename" : TBC To Be Completed');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4256
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4257
	if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4258
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "version_extracted" : TBC To Be Completed');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4259
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4260
	if ($p_local_header['flag'] != $p_central_header['flag']) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4261
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "flag" : TBC To Be Completed');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4262
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4263
	if ($p_local_header['compression'] != $p_central_header['compression']) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4264
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "compression" : TBC To Be Completed');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4265
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4266
	if ($p_local_header['mtime'] != $p_central_header['mtime']) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4267
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "mtime" : TBC To Be Completed');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4268
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4269
	if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4270
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename_len" : TBC To Be Completed');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4271
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4272
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4273
	// ----- Look for flag bit 3
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4274
	if (($p_local_header['flag'] & 8) == 8) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4275
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Purpose bit flag bit 3 set !');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4276
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'File size, compression size and crc found in central header');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4277
        $p_local_header['size'] = $p_central_header['size'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4278
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_local_header['size'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4279
        $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4280
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_local_header['compressed_size'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4281
        $p_local_header['crc'] = $p_central_header['crc'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4282
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_local_header['crc']).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4283
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4284
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4285
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4286
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4287
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4288
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4289
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4290
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4291
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4292
  // Function : privReadEndCentralDir()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4293
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4294
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4295
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4296
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4297
  function privReadEndCentralDir(&$p_central_dir)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4298
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4299
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4300
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4301
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4302
    // ----- Go to the end of the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4303
    $v_size = filesize($this->zipname);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4304
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4305
    @fseek($this->zip_fd, $v_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4306
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4307
    if (@ftell($this->zip_fd) != $v_size)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4308
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4309
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4310
      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4311
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4312
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4313
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4314
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4315
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4316
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4317
    // ----- First try : look if this is an archive with no commentaries (most of the time)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4318
    // in this case the end of central dir is at 22 bytes of the file end
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4319
    $v_found = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4320
    if ($v_size > 26) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4321
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4322
      @fseek($this->zip_fd, $v_size-22);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4323
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4324
      if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4325
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4326
        // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4327
        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4328
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4329
        // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4330
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4331
        return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4332
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4333
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4334
      // ----- Read for bytes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4335
      $v_binary_data = @fread($this->zip_fd, 4);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4336
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4337
      $v_data = @unpack('Vid', $v_binary_data);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4338
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4339
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4340
      // ----- Check signature
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4341
      if ($v_data['id'] == 0x06054b50) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4342
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position.");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4343
        $v_found = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4344
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4345
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4346
      $v_pos = ftell($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4347
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4348
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4349
    // ----- Go back to the maximum possible size of the Central Dir End Record
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4350
    if (!$v_found) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4351
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4352
      $v_maximum_size = 65557; // 0xFFFF + 22;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4353
      if ($v_maximum_size > $v_size)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4354
        $v_maximum_size = $v_size;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4355
      @fseek($this->zip_fd, $v_size-$v_maximum_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4356
      if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4357
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4358
        // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4359
        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4360
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4361
        // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4362
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4363
        return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4364
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4365
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4366
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4367
      // ----- Read byte per byte in order to find the signature
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4368
      $v_pos = ftell($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4369
      $v_bytes = 0x00000000;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4370
      while ($v_pos < $v_size)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4371
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4372
        // ----- Read a byte
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4373
        $v_byte = @fread($this->zip_fd, 1);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4374
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4375
        // -----  Add the byte
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4376
        $v_bytes = ($v_bytes << 8) | Ord($v_byte);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4377
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4378
        // ----- Compare the bytes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4379
        if ($v_bytes == 0x504b0506)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4380
        {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4381
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4382
          $v_pos++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4383
          break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4384
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4385
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4386
        $v_pos++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4387
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4388
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4389
      // ----- Look if not found end of central dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4390
      if ($v_pos == $v_size)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4391
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4392
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4393
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4394
        // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4395
        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4396
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4397
        // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4398
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4399
        return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4400
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4401
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4402
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4403
    // ----- Read the first 18 bytes of the header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4404
    $v_binary_data = fread($this->zip_fd, 18);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4405
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4406
    // ----- Look for invalid block size
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4407
    if (strlen($v_binary_data) != 18)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4408
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4409
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4410
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4411
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4412
      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4413
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4414
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4415
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4416
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4417
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4418
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4419
    // ----- Extract the values
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4420
    ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4421
    ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4422
    $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4423
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4424
    // ----- Check the global size
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4425
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4426
    if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4427
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The central dir is not at the end of the archive. Some trailing bytes exists after the archive.");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4428
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4429
	  // ----- Removed in release 2.2 see readme file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4430
	  // The check of the file size is a little too strict.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4431
	  // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4432
	  // While decrypted, zip has training 0 bytes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4433
	  if (0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4434
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4435
      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4436
	                       'The central dir is not at the end of the archive.'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4437
						   .' Some trailing bytes exists after the archive.');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4438
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4439
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4440
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4441
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4442
	  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4443
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4444
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4445
    // ----- Get comment
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4446
    if ($v_data['comment_size'] != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4447
      $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4448
    else
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4449
      $p_central_dir['comment'] = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4450
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4451
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4452
    $p_central_dir['entries'] = $v_data['entries'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4453
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4454
    $p_central_dir['disk_entries'] = $v_data['disk_entries'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4455
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4456
    $p_central_dir['offset'] = $v_data['offset'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4457
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4458
    $p_central_dir['size'] = $v_data['size'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4459
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4460
    $p_central_dir['disk'] = $v_data['disk'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4461
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4462
    $p_central_dir['disk_start'] = $v_data['disk_start'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4463
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\'');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4464
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4465
    // TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4466
    //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4467
    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4468
    //}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4469
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4470
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4471
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4472
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4473
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4474
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4475
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4476
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4477
  // Function : privDeleteByRule()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4478
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4479
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4480
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4481
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4482
  function privDeleteByRule(&$p_result_list, &$p_options)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4483
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4484
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4485
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4486
    $v_list_detail = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4487
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4488
    // ----- Open the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4489
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4490
    if (($v_result=$this->privOpenFd('rb')) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4491
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4492
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4493
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4494
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4495
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4496
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4497
    // ----- Read the central directory informations
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4498
    $v_central_dir = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4499
    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4500
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4501
      $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4502
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4503
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4504
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4505
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4506
    // ----- Go to beginning of File
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4507
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4508
    @rewind($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4509
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4510
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4511
    // ----- Scan all the files
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4512
    // ----- Start at beginning of Central Dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4513
    $v_pos_entry = $v_central_dir['offset'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4514
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4515
    @rewind($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4516
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4517
    if (@fseek($this->zip_fd, $v_pos_entry))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4518
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4519
      // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4520
      $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4521
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4522
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4523
      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4524
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4525
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4526
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4527
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4528
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4529
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4530
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4531
    // ----- Read each entry
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4532
    $v_header_list = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4533
    $j_start = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4534
    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4535
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4536
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$i')");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4537
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4538
      // ----- Read the file header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4539
      $v_header_list[$v_nb_extracted] = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4540
      if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4541
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4542
        // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4543
        $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4544
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4545
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4546
        return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4547
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4548
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4549
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4550
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4551
      // ----- Store the index
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4552
      $v_header_list[$v_nb_extracted]['index'] = $i;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4553
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4554
      // ----- Look for the specific extract rules
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4555
      $v_found = false;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4556
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4557
      // ----- Look for extract by name rule
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4558
      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4559
          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4560
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4561
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4562
          // ----- Look if the filename is in the list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4563
          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4564
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4565
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4566
              // ----- Look for a directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4567
              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4568
                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4569
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4570
                  // ----- Look if the directory is in the filename path
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4571
                  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4572
                      && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4573
                      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4574
                      $v_found = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4575
                  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4576
                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4577
                          && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4578
                      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4579
                      $v_found = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4580
                  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4581
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4582
              // ----- Look for a filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4583
              elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4584
                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4585
                  $v_found = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4586
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4587
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4588
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4589
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4590
      // ----- Look for extract by ereg rule
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4591
      else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4592
               && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4593
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4594
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4595
          if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4596
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4597
              $v_found = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4598
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4599
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4600
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4601
      // ----- Look for extract by preg rule
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4602
      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4603
               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4604
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4605
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4606
          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4607
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4608
              $v_found = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4609
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4610
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4611
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4612
      // ----- Look for extract by index rule
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4613
      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4614
               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4615
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4616
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4617
          // ----- Look if the index is in the list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4618
          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4619
              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4620
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4621
              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4622
                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4623
                  $v_found = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4624
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4625
              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4626
                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4627
                  $j_start = $j+1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4628
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4629
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4630
              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4631
                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4632
                  break;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4633
              }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4634
          }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4635
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4636
      else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4637
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "No argument mean remove all file");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4638
      	$v_found = true;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4639
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4640
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4641
      // ----- Look for deletion
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4642
      if ($v_found)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4643
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4644
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4645
        unset($v_header_list[$v_nb_extracted]);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4646
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4647
      else
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4648
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4649
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4650
        $v_nb_extracted++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4651
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4652
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4653
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4654
    // ----- Look if something need to be deleted
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4655
    if ($v_nb_extracted > 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4656
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4657
        // ----- Creates a temporay file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4658
        $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4659
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4660
        // ----- Creates a temporary zip archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4661
        $v_temp_zip = new PclZip($v_zip_temp_name);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4662
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4663
        // ----- Open the temporary zip file in write mode
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4664
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4665
        if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4666
            $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4667
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4668
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4669
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4670
            return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4671
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4672
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4673
        // ----- Look which file need to be kept
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4674
        for ($i=0; $i<sizeof($v_header_list); $i++) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4675
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Keep entry index '$i' : '".$v_header_list[$i]['filename']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4676
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4677
            // ----- Calculate the position of the header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4678
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset='". $v_header_list[$i]['offset']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4679
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4680
            @rewind($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4681
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4682
            if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4683
                // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4684
                $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4685
                $v_temp_zip->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4686
                @unlink($v_zip_temp_name);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4687
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4688
                // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4689
                PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4690
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4691
                // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4692
                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4693
                return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4694
            }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4695
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4696
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4697
            // ----- Read the file header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4698
            $v_local_header = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4699
            if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4700
                // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4701
                $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4702
                $v_temp_zip->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4703
                @unlink($v_zip_temp_name);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4704
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4705
                // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4706
                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4707
                return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4708
            }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4709
            
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4710
            // ----- Check that local file header is same as central file header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4711
            if ($this->privCheckFileHeaders($v_local_header,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4712
			                                $v_header_list[$i]) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4713
                // TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4714
            }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4715
            unset($v_local_header);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4716
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4717
            // ----- Write the file header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4718
            if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4719
                // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4720
                $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4721
                $v_temp_zip->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4722
                @unlink($v_zip_temp_name);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4723
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4724
                // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4725
                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4726
                return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4727
            }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4728
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4729
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4730
            // ----- Read/write the data block
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4731
            if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4732
                // ----- Close the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4733
                $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4734
                $v_temp_zip->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4735
                @unlink($v_zip_temp_name);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4736
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4737
                // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4738
                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4739
                return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4740
            }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4741
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4742
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4743
        // ----- Store the offset of the central dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4744
        $v_offset = @ftell($v_temp_zip->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4745
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4746
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4747
        // ----- Re-Create the Central Dir files header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4748
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4749
        for ($i=0; $i<sizeof($v_header_list); $i++) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4750
            // ----- Create the file header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4751
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset of file : ".$v_header_list[$i]['offset']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4752
            if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4753
                $v_temp_zip->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4754
                $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4755
                @unlink($v_zip_temp_name);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4756
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4757
                // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4758
                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4759
                return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4760
            }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4761
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4762
            // ----- Transform the header to a 'usable' info
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4763
            $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4764
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4765
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4766
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4767
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4768
        // ----- Zip file comment
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4769
        $v_comment = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4770
        if (isset($p_options[PCLZIP_OPT_COMMENT])) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4771
          $v_comment = $p_options[PCLZIP_OPT_COMMENT];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4772
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4773
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4774
        // ----- Calculate the size of the central header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4775
        $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4776
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4777
        // ----- Create the central dir footer
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4778
        if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4779
            // ----- Reset the file list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4780
            unset($v_header_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4781
            $v_temp_zip->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4782
            $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4783
            @unlink($v_zip_temp_name);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4784
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4785
            // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4786
            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4787
            return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4788
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4789
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4790
        // ----- Close
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4791
        $v_temp_zip->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4792
        $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4793
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4794
        // ----- Delete the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4795
        // TBC : I should test the result ...
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4796
        @unlink($this->zipname);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4797
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4798
        // ----- Rename the temporary file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4799
        // TBC : I should test the result ...
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4800
        //@rename($v_zip_temp_name, $this->zipname);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4801
        PclZipUtilRename($v_zip_temp_name, $this->zipname);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4802
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4803
        // ----- Destroy the temporary archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4804
        unset($v_temp_zip);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4805
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4806
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4807
    // ----- Remove every files : reset the file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4808
    else if ($v_central_dir['entries'] != 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4809
        $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4810
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4811
        if (($v_result = $this->privOpenFd('wb')) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4812
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4813
          return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4814
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4815
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4816
        if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4817
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4818
          return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4819
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4820
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4821
        $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4822
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4823
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4824
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4825
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4826
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4827
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4828
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4829
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4830
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4831
  // Function : privDirCheck()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4832
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4833
  //   Check if a directory exists, if not it creates it and all the parents directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4834
  //   which may be useful.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4835
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4836
  //   $p_dir : Directory path to check.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4837
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4838
  //    1 : OK
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4839
  //   -1 : Unable to create directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4840
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4841
  function privDirCheck($p_dir, $p_is_dir=false)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4842
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4843
    $v_result = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4844
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4845
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4846
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4847
    // ----- Remove the final '/'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4848
    if (($p_is_dir) && (substr($p_dir, -1)=='/'))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4849
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4850
      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4851
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4852
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4853
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4854
    // ----- Check the directory availability
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4855
    if ((is_dir($p_dir)) || ($p_dir == ""))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4856
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4857
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4858
      return 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4859
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4860
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4861
    // ----- Extract parent directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4862
    $p_parent_dir = dirname($p_dir);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4863
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4864
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4865
    // ----- Just a check
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4866
    if ($p_parent_dir != $p_dir)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4867
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4868
      // ----- Look for parent directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4869
      if ($p_parent_dir != "")
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4870
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4871
        if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4872
        {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4873
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4874
          return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4875
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4876
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4877
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4878
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4879
    // ----- Create the directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4880
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4881
    if (!@mkdir($p_dir, 0777))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4882
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4883
      // ----- Error log
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4884
      PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4885
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4886
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4887
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4888
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4889
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4890
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4891
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4892
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4893
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4894
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4895
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4896
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4897
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4898
  // Function : privMerge()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4899
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4900
  //   If $p_archive_to_add does not exist, the function exit with a success result.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4901
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4902
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4903
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4904
  function privMerge(&$p_archive_to_add)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4905
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4906
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4907
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4908
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4909
    // ----- Look if the archive_to_add exists
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4910
    if (!is_file($p_archive_to_add->zipname))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4911
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4912
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge.");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4913
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4914
      // ----- Nothing to merge, so merge is a success
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4915
      $v_result = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4916
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4917
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4918
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4919
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4920
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4921
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4922
    // ----- Look if the archive exists
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4923
    if (!is_file($this->zipname))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4924
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4925
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add.");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4926
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4927
      // ----- Do a duplicate
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4928
      $v_result = $this->privDuplicate($p_archive_to_add->zipname);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4929
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4930
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4931
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4932
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4933
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4934
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4935
    // ----- Open the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4936
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4937
    if (($v_result=$this->privOpenFd('rb')) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4938
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4939
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4940
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4941
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4942
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4943
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4944
    // ----- Read the central directory informations
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4945
    $v_central_dir = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4946
    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4947
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4948
      $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4949
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4950
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4951
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4952
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4953
    // ----- Go to beginning of File
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4954
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4955
    @rewind($this->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4956
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4957
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4958
    // ----- Open the archive_to_add file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4959
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4960
    if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4961
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4962
      $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4963
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4964
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4965
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4966
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4967
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4968
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4969
    // ----- Read the central directory informations
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4970
    $v_central_dir_to_add = array();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4971
    if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4972
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4973
      $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4974
      $p_archive_to_add->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4975
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4976
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4977
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4978
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4979
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4980
    // ----- Go to beginning of File
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4981
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4982
    @rewind($p_archive_to_add->zip_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4983
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4984
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4985
    // ----- Creates a temporay file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4986
    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4987
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4988
    // ----- Open the temporary file in write mode
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4989
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4990
    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4991
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4992
      $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4993
      $p_archive_to_add->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4994
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4995
      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4996
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4997
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4998
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  4999
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5000
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5001
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5002
    // ----- Copy the files from the archive to the temporary file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5003
    // TBC : Here I should better append the file and go back to erase the central dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5004
    $v_size = $v_central_dir['offset'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5005
    while ($v_size != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5006
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5007
      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5008
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5009
      $v_buffer = fread($this->zip_fd, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5010
      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5011
      $v_size -= $v_read_size;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5012
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5013
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5014
    // ----- Copy the files from the archive_to_add into the temporary file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5015
    $v_size = $v_central_dir_to_add['offset'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5016
    while ($v_size != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5017
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5018
      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5019
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5020
      $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5021
      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5022
      $v_size -= $v_read_size;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5023
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5024
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5025
    // ----- Store the offset of the central dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5026
    $v_offset = @ftell($v_zip_temp_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5027
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5028
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5029
    // ----- Copy the block of file headers from the old archive
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5030
    $v_size = $v_central_dir['size'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5031
    while ($v_size != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5032
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5033
      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5034
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5035
      $v_buffer = @fread($this->zip_fd, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5036
      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5037
      $v_size -= $v_read_size;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5038
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5039
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5040
    // ----- Copy the block of file headers from the archive_to_add
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5041
    $v_size = $v_central_dir_to_add['size'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5042
    while ($v_size != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5043
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5044
      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5045
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5046
      $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5047
      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5048
      $v_size -= $v_read_size;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5049
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5050
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5051
    // ----- Merge the file comments
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5052
    $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5053
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5054
    // ----- Calculate the size of the (new) central header
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5055
    $v_size = @ftell($v_zip_temp_fd)-$v_offset;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5056
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5057
    // ----- Swap the file descriptor
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5058
    // Here is a trick : I swap the temporary fd with the zip fd, in order to use
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5059
    // the following methods on the temporary fil and not the real archive fd
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5060
    $v_swap = $this->zip_fd;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5061
    $this->zip_fd = $v_zip_temp_fd;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5062
    $v_zip_temp_fd = $v_swap;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5063
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5064
    // ----- Create the central dir footer
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5065
    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5066
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5067
      $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5068
      $p_archive_to_add->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5069
      @fclose($v_zip_temp_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5070
      $this->zip_fd = null;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5071
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5072
      // ----- Reset the file list
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5073
      unset($v_header_list);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5074
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5075
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5076
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5077
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5078
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5079
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5080
    // ----- Swap back the file descriptor
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5081
    $v_swap = $this->zip_fd;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5082
    $this->zip_fd = $v_zip_temp_fd;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5083
    $v_zip_temp_fd = $v_swap;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5084
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5085
    // ----- Close
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5086
    $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5087
    $p_archive_to_add->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5088
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5089
    // ----- Close the temporary file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5090
    @fclose($v_zip_temp_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5091
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5092
    // ----- Delete the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5093
    // TBC : I should test the result ...
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5094
    @unlink($this->zipname);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5095
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5096
    // ----- Rename the temporary file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5097
    // TBC : I should test the result ...
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5098
    //@rename($v_zip_temp_name, $this->zipname);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5099
    PclZipUtilRename($v_zip_temp_name, $this->zipname);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5100
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5101
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5102
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5103
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5104
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5105
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5106
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5107
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5108
  // Function : privDuplicate()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5109
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5110
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5111
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5112
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5113
  function privDuplicate($p_archive_filename)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5114
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5115
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5116
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5117
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5118
    // ----- Look if the $p_archive_filename exists
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5119
    if (!is_file($p_archive_filename))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5120
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5121
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate.");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5122
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5123
      // ----- Nothing to duplicate, so duplicate is a success.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5124
      $v_result = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5125
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5126
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5127
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5128
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5129
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5130
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5131
    // ----- Open the zip file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5132
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5133
    if (($v_result=$this->privOpenFd('wb')) != 1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5134
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5135
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5136
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5137
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5138
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5139
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5140
    // ----- Open the temporary file in write mode
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5141
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5142
    if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5143
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5144
      $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5145
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5146
      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5147
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5148
      // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5149
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5150
      return PclZip::errorCode();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5151
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5152
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5153
    // ----- Copy the files from the archive to the temporary file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5154
    // TBC : Here I should better append the file and go back to erase the central dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5155
    $v_size = filesize($p_archive_filename);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5156
    while ($v_size != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5157
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5158
      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5159
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5160
      $v_buffer = fread($v_zip_temp_fd, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5161
      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5162
      $v_size -= $v_read_size;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5163
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5164
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5165
    // ----- Close
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5166
    $this->privCloseFd();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5167
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5168
    // ----- Close the temporary file
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5169
    @fclose($v_zip_temp_fd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5170
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5171
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5172
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5173
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5174
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5175
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5176
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5177
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5178
  // Function : privErrorLog()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5179
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5180
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5181
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5182
  function privErrorLog($p_error_code=0, $p_error_string='')
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5183
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5184
    if (PCLZIP_ERROR_EXTERNAL == 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5185
      PclError($p_error_code, $p_error_string);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5186
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5187
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5188
      $this->error_code = $p_error_code;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5189
      $this->error_string = $p_error_string;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5190
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5191
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5192
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5193
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5194
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5195
  // Function : privErrorReset()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5196
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5197
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5198
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5199
  function privErrorReset()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5200
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5201
    if (PCLZIP_ERROR_EXTERNAL == 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5202
      PclErrorReset();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5203
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5204
    else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5205
      $this->error_code = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5206
      $this->error_string = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5207
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5208
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5209
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5210
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5211
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5212
  // Function : privDecrypt()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5213
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5214
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5215
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5216
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5217
  function privDecrypt($p_encryption_header, &$p_buffer, $p_size, $p_crc)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5218
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5219
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDecrypt', "size=".$p_size."");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5220
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5221
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5222
    // ----- To Be Modified ;-)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5223
    $v_pwd = "test";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5224
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5225
    $p_buffer = PclZipUtilZipDecrypt($p_buffer, $p_size, $p_encryption_header,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5226
	                                 $p_crc, $v_pwd);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5227
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5228
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5229
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5230
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5231
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5232
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5233
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5234
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5235
  // Function : privDisableMagicQuotes()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5236
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5237
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5238
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5239
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5240
  function privDisableMagicQuotes()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5241
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5242
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDisableMagicQuotes', "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5243
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5244
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5245
    // ----- Look if function exists
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5246
    if (   (!function_exists("get_magic_quotes_runtime"))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5247
	    || (!function_exists("set_magic_quotes_runtime"))) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5248
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5249
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5250
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5251
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5252
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5253
    // ----- Look if already done
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5254
    if ($this->magic_quotes_status != -1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5255
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote already disabled");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5256
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5257
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5258
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5259
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5260
	// ----- Get and memorize the magic_quote value
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5261
	$this->magic_quotes_status = @get_magic_quotes_runtime();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5262
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Current magic_quotes_runtime status is '".($this->magic_quotes_status==0?'disable':'enable')."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5263
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5264
	// ----- Disable magic_quotes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5265
	if ($this->magic_quotes_status == 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5266
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Disable magic_quotes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5267
	  @set_magic_quotes_runtime(0);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5268
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5269
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5270
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5271
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5272
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5273
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5274
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5275
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5276
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5277
  // Function : privSwapBackMagicQuotes()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5278
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5279
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5280
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5281
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5282
  function privSwapBackMagicQuotes()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5283
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5284
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privSwapBackMagicQuotes', "");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5285
    $v_result=1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5286
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5287
    // ----- Look if function exists
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5288
    if (   (!function_exists("get_magic_quotes_runtime"))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5289
	    || (!function_exists("set_magic_quotes_runtime"))) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5290
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5291
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5292
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5293
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5294
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5295
    // ----- Look if something to do
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5296
    if ($this->magic_quotes_status != -1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5297
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote not modified");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5298
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5299
      return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5300
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5301
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5302
	// ----- Swap back magic_quotes
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5303
	if ($this->magic_quotes_status == 1) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5304
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Enable back magic_quotes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5305
  	  @set_magic_quotes_runtime($this->magic_quotes_status);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5306
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5307
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5308
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5309
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5310
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5311
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5312
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5313
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5314
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5315
  // End of class
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5316
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5317
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5318
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5319
  // Function : PclZipUtilPathReduction()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5320
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5321
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5322
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5323
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5324
  function PclZipUtilPathReduction($p_dir)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5325
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5326
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5327
    $v_result = "";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5328
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5329
    // ----- Look for not empty path
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5330
    if ($p_dir != "") {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5331
      // ----- Explode path by directory names
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5332
      $v_list = explode("/", $p_dir);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5333
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5334
      // ----- Study directories from last to first
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5335
      $v_skip = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5336
      for ($i=sizeof($v_list)-1; $i>=0; $i--) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5337
        // ----- Look for current path
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5338
        if ($v_list[$i] == ".") {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5339
          // ----- Ignore this directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5340
          // Should be the first $i=0, but no check is done
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5341
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5342
        else if ($v_list[$i] == "..") {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5343
		  $v_skip++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5344
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5345
        else if ($v_list[$i] == "") {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5346
		  // ----- First '/' i.e. root slash
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5347
		  if ($i == 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5348
            $v_result = "/".$v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5349
		    if ($v_skip > 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5350
		        // ----- It is an invalid path, so the path is not modified
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5351
		        // TBC
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5352
		        $v_result = $p_dir;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5353
                //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid path is unchanged");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5354
                $v_skip = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5355
		    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5356
		  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5357
		  // ----- Last '/' i.e. indicates a directory
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5358
		  else if ($i == (sizeof($v_list)-1)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5359
            $v_result = $v_list[$i];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5360
		  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5361
		  // ----- Double '/' inside the path
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5362
		  else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5363
            // ----- Ignore only the double '//' in path,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5364
            // but not the first and last '/'
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5365
		  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5366
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5367
        else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5368
		  // ----- Look for item to skip
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5369
		  if ($v_skip > 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5370
		    $v_skip--;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5371
		  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5372
		  else {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5373
            $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5374
		  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5375
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5376
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5377
      
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5378
      // ----- Look for skip
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5379
      if ($v_skip > 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5380
        while ($v_skip > 0) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5381
            $v_result = '../'.$v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5382
            $v_skip--;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5383
        }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5384
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5385
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5386
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5387
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5388
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5389
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5390
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5391
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5392
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5393
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5394
  // Function : PclZipUtilPathInclusion()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5395
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5396
  //   This function indicates if the path $p_path is under the $p_dir tree. Or,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5397
  //   said in an other way, if the file or sub-dir $p_path is inside the dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5398
  //   $p_dir.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5399
  //   The function indicates also if the path is exactly the same as the dir.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5400
  //   This function supports path with duplicated '/' like '//', but does not
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5401
  //   support '.' or '..' statements.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5402
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5403
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5404
  //   0 if $p_path is not inside directory $p_dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5405
  //   1 if $p_path is inside directory $p_dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5406
  //   2 if $p_path is exactly the same as $p_dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5407
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5408
  function PclZipUtilPathInclusion($p_dir, $p_path)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5409
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5410
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5411
    $v_result = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5412
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5413
    // ----- Look for path beginning by ./
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5414
    if (   ($p_dir == '.')
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5415
        || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5416
      $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5417
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_dir '".$p_dir."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5418
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5419
    if (   ($p_path == '.')
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5420
        || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5421
      $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5422
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_path '".$p_path."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5423
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5424
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5425
    // ----- Explode dir and path by directory separator
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5426
    $v_list_dir = explode("/", $p_dir);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5427
    $v_list_dir_size = sizeof($v_list_dir);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5428
    $v_list_path = explode("/", $p_path);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5429
    $v_list_path_size = sizeof($v_list_path);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5430
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5431
    // ----- Study directories paths
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5432
    $i = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5433
    $j = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5434
    while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5435
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5436
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5437
      // ----- Look for empty dir (path reduction)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5438
      if ($v_list_dir[$i] == '') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5439
        $i++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5440
        continue;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5441
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5442
      if ($v_list_path[$j] == '') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5443
        $j++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5444
        continue;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5445
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5446
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5447
      // ----- Compare the items
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5448
      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5449
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5450
        $v_result = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5451
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5452
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5453
      // ----- Next items
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5454
      $i++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5455
      $j++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5456
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5457
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5458
    // ----- Look if everything seems to be the same
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5459
    if ($v_result) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5460
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5461
      // ----- Skip all the empty items
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5462
      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5463
      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5464
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5465
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5466
      if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5467
        // ----- There are exactly the same
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5468
        $v_result = 2;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5469
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5470
      else if ($i < $v_list_dir_size) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5471
        // ----- The path is shorter than the dir
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5472
        $v_result = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5473
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5474
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5475
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5476
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5477
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5478
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5479
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5480
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5481
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5482
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5483
  // Function : PclZipUtilCopyBlock()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5484
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5485
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5486
  //   $p_mode : read/write compression mode
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5487
  //             0 : src & dest normal
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5488
  //             1 : src gzip, dest normal
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5489
  //             2 : src normal, dest gzip
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5490
  //             3 : src & dest gzip
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5491
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5492
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5493
  function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5494
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5495
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5496
    $v_result = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5497
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5498
    if ($p_mode==0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5499
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5500
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src)));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5501
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest)));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5502
      while ($p_size != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5503
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5504
        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5505
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5506
        $v_buffer = @fread($p_src, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5507
        @fwrite($p_dest, $v_buffer, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5508
        $p_size -= $v_read_size;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5509
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5510
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src)));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5511
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest)));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5512
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5513
    else if ($p_mode==1)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5514
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5515
      while ($p_size != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5516
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5517
        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5518
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5519
        $v_buffer = @gzread($p_src, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5520
        @fwrite($p_dest, $v_buffer, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5521
        $p_size -= $v_read_size;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5522
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5523
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5524
    else if ($p_mode==2)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5525
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5526
      while ($p_size != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5527
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5528
        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5529
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5530
        $v_buffer = @fread($p_src, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5531
        @gzwrite($p_dest, $v_buffer, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5532
        $p_size -= $v_read_size;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5533
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5534
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5535
    else if ($p_mode==3)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5536
    {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5537
      while ($p_size != 0)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5538
      {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5539
        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5540
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5541
        $v_buffer = @gzread($p_src, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5542
        @gzwrite($p_dest, $v_buffer, $v_read_size);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5543
        $p_size -= $v_read_size;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5544
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5545
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5546
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5547
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5548
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5549
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5550
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5551
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5552
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5553
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5554
  // Function : PclZipUtilRename()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5555
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5556
  //   This function tries to do a simple rename() function. If it fails, it
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5557
  //   tries to copy the $p_src file in a new $p_dest file and then unlink the
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5558
  //   first one.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5559
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5560
  //   $p_src : Old filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5561
  //   $p_dest : New filename
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5562
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5563
  //   1 on success, 0 on failure.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5564
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5565
  function PclZipUtilRename($p_src, $p_dest)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5566
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5567
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5568
    $v_result = 1;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5569
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5570
    // ----- Try to rename the files
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5571
    if (!@rename($p_src, $p_dest)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5572
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5573
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5574
      // ----- Try to copy & unlink the src
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5575
      if (!@copy($p_src, $p_dest)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5576
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5577
        $v_result = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5578
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5579
      else if (!@unlink($p_src)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5580
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5581
        $v_result = 0;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5582
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5583
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5584
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5585
    // ----- Return
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5586
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5587
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5588
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5589
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5590
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5591
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5592
  // Function : PclZipUtilOptionText()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5593
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5594
  //   Translate option value in text. Mainly for debug purpose.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5595
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5596
  //   $p_option : the option value.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5597
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5598
  //   The option text value.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5599
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5600
  function PclZipUtilOptionText($p_option)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5601
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5602
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'");
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5603
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5604
    $v_list = get_defined_constants();
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5605
    for (reset($v_list); $v_key = key($v_list); next($v_list)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5606
	  $v_prefix = substr($v_key, 0, 10);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5607
	  if ((   ($v_prefix == 'PCLZIP_OPT')
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5608
         || ($v_prefix == 'PCLZIP_CB_')
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5609
         || ($v_prefix == 'PCLZIP_ATT'))
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5610
	      && ($v_list[$v_key] == $p_option)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5611
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5612
          return $v_key;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5613
	    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5614
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5615
    
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5616
    $v_result = 'Unknown';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5617
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5618
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5619
    return $v_result;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5620
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5621
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5622
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5623
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5624
  // Function : PclZipUtilTranslateWinPath()
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5625
  // Description :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5626
  //   Translate windows path by replacing '\' by '/' and optionally removing
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5627
  //   drive letter.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5628
  // Parameters :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5629
  //   $p_path : path to translate.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5630
  //   $p_remove_disk_letter : true | false
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5631
  // Return Values :
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5632
  //   The path translated.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5633
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5634
  function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5635
  {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5636
    if (stristr(php_uname(), 'windows')) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5637
      // ----- Look for potential disk letter
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5638
      if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5639
          $p_path = substr($p_path, $v_position+1);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5640
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5641
      // ----- Change potential windows directory separator
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5642
      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5643
          $p_path = strtr($p_path, '\\', '/');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5644
      }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5645
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5646
    return $p_path;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5647
  }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5648
  // --------------------------------------------------------------------------------
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5649
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5650
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  5651
?>