WordPress.org

Make WordPress Core

Ticket #10777: 10777.diff

File 10777.diff, 183.8 KB (added by dd32, 9 years ago)
  • wp-admin/includes/class-pclzip.php

     
    11<?php
    22// --------------------------------------------------------------------------------
    3 // PhpConcept Library - Zip Module 2.8
     3// PhpConcept Library - Zip Module 2.8.1
    44// --------------------------------------------------------------------------------
    5 // License GNU/LGPL - Vincent Blavet - March 2006
     5// License GNU/LGPL - Vincent Blavet - August 2009
    66// http://www.phpconcept.net
    77// --------------------------------------------------------------------------------
    88//
     
    2222//   The use of this software is at the risk of the user.
    2323//
    2424// --------------------------------------------------------------------------------
    25 // $Id: pclzip.lib.php,v 1.55 2009/04/22 07:38:36 vblavet Exp $
     25// $Id: pclzip.lib.php,v 1.57 2009/08/11 14:59:47 vblavet Exp $
    2626// --------------------------------------------------------------------------------
    2727
    2828  // ----- Constants
     
    8383// --------------------------------------------------------------------------------
    8484
    8585  // ----- Global variables
    86   $g_pclzip_version = "2.8";
     86  $g_pclzip_version = "2.8.1";
    8787
    8888  // ----- Error codes
    8989  //   -1 : Unable to open file in binary write mode
     
    214214  // --------------------------------------------------------------------------------
    215215  function PclZip($p_zipname)
    216216  {
    217     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname");
    218217
    219218    // ----- Tests the zlib
    220219    if (!function_exists('gzopen'))
    221220    {
    222       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing");
    223221      die('Abort '.basename(__FILE__).' : Missing zlib extensions');
    224222    }
    225223
     
    229227    $this->magic_quotes_status = -1;
    230228
    231229    // ----- Return
    232     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1);
    233230    return;
    234231  }
    235232  // --------------------------------------------------------------------------------
     
    273270  // --------------------------------------------------------------------------------
    274271  function create($p_filelist)
    275272  {
    276     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ...");
    277273    $v_result=1;
    278274
    279275    // ----- Reset the error handler
     
    285281
    286282    // ----- Look for variable options arguments
    287283    $v_size = func_num_args();
    288     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
    289284
    290285    // ----- Look for arguments
    291286    if ($v_size > 1) {
     
    298293
    299294      // ----- Look for first arg
    300295      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
    301         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
    302296
    303297        // ----- Parse the options
    304298        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
     
    315309                                                   //, PCLZIP_OPT_CRYPT => 'optional'
    316310                                             ));
    317311        if ($v_result != 1) {
    318           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    319312          return 0;
    320313        }
    321314      }
     
    324317      // Here we need to support the first historic synopsis of the
    325318      // method.
    326319      else {
    327         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
    328320
    329321        // ----- Get the first argument
    330322        $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
     
    336328        else if ($v_size > 2) {
    337329          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
    338330                                       "Invalid number / type of arguments");
    339           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    340331          return 0;
    341332        }
    342333      }
     
    375366    // ----- Invalid variable type for $p_filelist
    376367    else {
    377368      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
    378       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    379369      return 0;
    380370    }
    381371   
     
    386376          $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
    387377        }
    388378        else {
    389           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Ignore an empty filename");
    390379        }
    391380      }
    392381    }
     
    406395                                               $v_options,
    407396                                               $v_supported_attributes);
    408397      if ($v_result != 1) {
    409         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    410398        return 0;
    411399      }
    412400    }
     
    414402    // ----- Expand the filelist (expand directories)
    415403    $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
    416404    if ($v_result != 1) {
    417       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    418405      return 0;
    419406    }
    420407
    421408    // ----- Call the create fct
    422409    $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
    423410    if ($v_result != 1) {
    424       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    425411      return 0;
    426412    }
    427413
    428414    // ----- Return
    429     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
    430415    return $p_result_list;
    431416  }
    432417  // --------------------------------------------------------------------------------
     
    468453  // --------------------------------------------------------------------------------
    469454  function add($p_filelist)
    470455  {
    471     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ...");
    472456    $v_result=1;
    473457
    474458    // ----- Reset the error handler
     
    480464
    481465    // ----- Look for variable options arguments
    482466    $v_size = func_num_args();
    483     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
    484467
    485468    // ----- Look for arguments
    486469    if ($v_size > 1) {
     
    493476
    494477      // ----- Look for first arg
    495478      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
    496         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
    497479
    498480        // ----- Parse the options
    499481        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
     
    509491                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
    510492                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
    511493                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
     494
    512495                                                   //, PCLZIP_OPT_CRYPT => 'optional'
    513496                                                                                                   ));
    514497        if ($v_result != 1) {
    515           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    516498          return 0;
    517499        }
    518500      }
     
    521503      // Here we need to support the first historic synopsis of the
    522504      // method.
    523505      else {
    524         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
    525506
    526507        // ----- Get the first argument
    527508        $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
     
    535516          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
    536517
    537518          // ----- Return
    538           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    539519          return 0;
    540520        }
    541521      }
     
    574554    // ----- Invalid variable type for $p_filelist
    575555    else {
    576556      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
    577       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    578557      return 0;
    579558    }
    580559   
     
    600579                                               $v_options,
    601580                                               $v_supported_attributes);
    602581      if ($v_result != 1) {
    603         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    604582        return 0;
    605583      }
    606584    }
     
    608586    // ----- Expand the filelist (expand directories)
    609587    $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
    610588    if ($v_result != 1) {
    611       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    612589      return 0;
    613590    }
    614591
    615592    // ----- Call the create fct
    616593    $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
    617594    if ($v_result != 1) {
    618       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    619595      return 0;
    620596    }
    621597
    622598    // ----- Return
    623     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
    624599    return $p_result_list;
    625600  }
    626601  // --------------------------------------------------------------------------------
     
    668643  // --------------------------------------------------------------------------------
    669644  function listContent()
    670645  {
    671     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', "");
    672646    $v_result=1;
    673647
    674648    // ----- Reset the error handler
     
    676650
    677651    // ----- Check archive
    678652    if (!$this->privCheckFormat()) {
    679       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    680653      return(0);
    681654    }
    682655
     
    685658    if (($v_result = $this->privList($p_list)) != 1)
    686659    {
    687660      unset($p_list);
    688       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
    689661      return(0);
    690662    }
    691663
    692664    // ----- Return
    693     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
    694665    return $p_list;
    695666  }
    696667  // --------------------------------------------------------------------------------
     
    729700  // --------------------------------------------------------------------------------
    730701  function extract()
    731702  {
    732     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
    733703    $v_result=1;
    734704
    735705    // ----- Reset the error handler
     
    737707
    738708    // ----- Check archive
    739709    if (!$this->privCheckFormat()) {
    740       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    741710      return(0);
    742711    }
    743712
     
    750719
    751720    // ----- Look for variable options arguments
    752721    $v_size = func_num_args();
    753     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
    754722
    755723    // ----- Default values for option
    756724    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
     
    762730
    763731      // ----- Look for first arg
    764732      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
    765         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
    766733
    767734        // ----- Parse the options
    768735        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
     
    787754                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
    788755                                                                                                    ));
    789756        if ($v_result != 1) {
    790           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    791757          return 0;
    792758        }
    793759
     
    814780      // Here we need to support the first historic synopsis of the
    815781      // method.
    816782      else {
    817         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
    818783
    819784        // ----- Get the first argument
    820785        $v_path = $v_arg_list[0];
     
    828793          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
    829794
    830795          // ----- Return
    831           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
    832796          return 0;
    833797        }
    834798      }
     
    838802    $this->privOptionDefaultThreshold($v_options);
    839803
    840804    // ----- Trace
    841     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");
    842805
    843806    // ----- Call the extracting fct
    844807    $p_list = array();
     
    846809                                             $v_remove_all_path, $v_options);
    847810    if ($v_result < 1) {
    848811      unset($p_list);
    849       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
    850812      return(0);
    851813    }
    852814
    853815    // ----- Return
    854     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
    855816    return $p_list;
    856817  }
    857818  // --------------------------------------------------------------------------------
     
    896857  //function extractByIndex($p_index, options...)
    897858  function extractByIndex($p_index)
    898859  {
    899     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ...");
    900860    $v_result=1;
    901861
    902862    // ----- Reset the error handler
     
    904864
    905865    // ----- Check archive
    906866    if (!$this->privCheckFormat()) {
    907       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    908867      return(0);
    909868    }
    910869
     
    917876
    918877    // ----- Look for variable options arguments
    919878    $v_size = func_num_args();
    920     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
    921879
    922880    // ----- Default values for option
    923881    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
     
    933891
    934892      // ----- Look for first arg
    935893      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
    936         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
    937894
    938895        // ----- Parse the options
    939896        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
     
    953910                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
    954911                                                                                                   ));
    955912        if ($v_result != 1) {
    956           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    957913          return 0;
    958914        }
    959915
     
    976932        }
    977933        if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
    978934          $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
    979           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set.");
    980935        }
    981936        else {
    982             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set.");
    983937        }
    984938      }
    985939
     
    987941      // Here we need to support the first historic synopsis of the
    988942      // method.
    989943      else {
    990         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
    991944
    992945        // ----- Get the first argument
    993946        $v_path = $v_arg_list[0];
     
    1001954          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
    1002955
    1003956          // ----- Return
    1004           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    1005957          return 0;
    1006958        }
    1007959      }
    1008960    }
    1009961
    1010962    // ----- Trace
    1011     //--(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')."'");
    1012963
    1013964    // ----- Trick
    1014965    // Here I want to reuse extractByRule(), so I need to parse the $p_index
     
    1018969    $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
    1019970                                        array (PCLZIP_OPT_BY_INDEX => 'optional' ));
    1020971    if ($v_result != 1) {
    1021         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    1022972        return 0;
    1023973    }
    1024974    $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
     
    1028978
    1029979    // ----- Call the extracting fct
    1030980    if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
    1031         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
    1032981        return(0);
    1033982    }
    1034983
    1035984    // ----- Return
    1036     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
    1037985    return $p_list;
    1038986  }
    1039987  // --------------------------------------------------------------------------------
     
    10581006  // --------------------------------------------------------------------------------
    10591007  function delete()
    10601008  {
    1061     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", "");
    10621009    $v_result=1;
    10631010
    10641011    // ----- Reset the error handler
     
    10661013
    10671014    // ----- Check archive
    10681015    if (!$this->privCheckFormat()) {
    1069       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    10701016      return(0);
    10711017    }
    10721018
     
    10751021
    10761022    // ----- Look for variable options arguments
    10771023    $v_size = func_num_args();
    1078     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
    10791024
    10801025    // ----- Look for arguments
    10811026    if ($v_size > 0) {
     
    10891034                                               PCLZIP_OPT_BY_PREG => 'optional',
    10901035                                               PCLZIP_OPT_BY_INDEX => 'optional' ));
    10911036      if ($v_result != 1) {
    1092           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    10931037          return 0;
    10941038      }
    10951039    }
     
    11021046    if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
    11031047      $this->privSwapBackMagicQuotes();
    11041048      unset($v_list);
    1105       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
    11061049      return(0);
    11071050    }
    11081051
     
    11101053    $this->privSwapBackMagicQuotes();
    11111054
    11121055    // ----- Return
    1113     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list);
    11141056    return $v_list;
    11151057  }
    11161058  // --------------------------------------------------------------------------------
     
    11231065  // --------------------------------------------------------------------------------
    11241066  function deleteByIndex($p_index)
    11251067  {
    1126     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'");
    11271068   
    11281069    $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
    11291070
    11301071    // ----- Return
    1131     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
    11321072    return $p_list;
    11331073  }
    11341074  // --------------------------------------------------------------------------------
     
    11491089  // --------------------------------------------------------------------------------
    11501090  function properties()
    11511091  {
    1152     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", "");
    11531092
    11541093    // ----- Reset the error handler
    11551094    $this->privErrorReset();
     
    11601099    // ----- Check archive
    11611100    if (!$this->privCheckFormat()) {
    11621101      $this->privSwapBackMagicQuotes();
    1163       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    11641102      return(0);
    11651103    }
    11661104
     
    11741112    if (@is_file($this->zipname))
    11751113    {
    11761114      // ----- Open the zip file
    1177       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
    11781115      if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
    11791116      {
    11801117        $this->privSwapBackMagicQuotes();
     
    11831120        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
    11841121
    11851122        // ----- Return
    1186         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0);
    11871123        return 0;
    11881124      }
    11891125
     
    11921128      if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
    11931129      {
    11941130        $this->privSwapBackMagicQuotes();
    1195         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    11961131        return 0;
    11971132      }
    11981133
     
    12091144    $this->privSwapBackMagicQuotes();
    12101145
    12111146    // ----- Return
    1212     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop);
    12131147    return $v_prop;
    12141148  }
    12151149  // --------------------------------------------------------------------------------
     
    12281162  // --------------------------------------------------------------------------------
    12291163  function duplicate($p_archive)
    12301164  {
    1231     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", "");
    12321165    $v_result = 1;
    12331166
    12341167    // ----- Reset the error handler
     
    12371170    // ----- Look if the $p_archive is a PclZip object
    12381171    if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
    12391172    {
    1240       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'");
    12411173
    12421174      // ----- Duplicate the archive
    12431175      $v_result = $this->privDuplicate($p_archive->zipname);
     
    12461178    // ----- Look if the $p_archive is a string (so a filename)
    12471179    else if (is_string($p_archive))
    12481180    {
    1249       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$p_archive'");
    12501181
    12511182      // ----- Check that $p_archive is a valid zip file
    12521183      // TBC : Should also check the archive format
     
    12701201    }
    12711202
    12721203    // ----- Return
    1273     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    12741204    return $v_result;
    12751205  }
    12761206  // --------------------------------------------------------------------------------
     
    12911221  // --------------------------------------------------------------------------------
    12921222  function merge($p_archive_to_add)
    12931223  {
    1294     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", "");
    12951224    $v_result = 1;
    12961225
    12971226    // ----- Reset the error handler
     
    12991228
    13001229    // ----- Check archive
    13011230    if (!$this->privCheckFormat()) {
    1302       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    13031231      return(0);
    13041232    }
    13051233
    13061234    // ----- Look if the $p_archive_to_add is a PclZip object
    13071235    if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
    13081236    {
    1309       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object");
    13101237
    13111238      // ----- Merge the archive
    13121239      $v_result = $this->privMerge($p_archive_to_add);
     
    13151242    // ----- Look if the $p_archive_to_add is a string (so a filename)
    13161243    else if (is_string($p_archive_to_add))
    13171244    {
    1318       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename");
    13191245
    13201246      // ----- Create a temporary archive
    13211247      $v_object_archive = new PclZip($p_archive_to_add);
     
    13331259    }
    13341260
    13351261    // ----- Return
    1336     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    13371262    return $v_result;
    13381263  }
    13391264  // --------------------------------------------------------------------------------
     
    14481373  // --------------------------------------------------------------------------------
    14491374  function privCheckFormat($p_level=0)
    14501375  {
    1451     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", "");
    14521376    $v_result = true;
    14531377
    14541378        // ----- Reset the file system cache
     
    14611385    if (!is_file($this->zipname)) {
    14621386      // ----- Error log
    14631387      PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
    1464       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
    14651388      return(false);
    14661389    }
    14671390
     
    14691392    if (!is_readable($this->zipname)) {
    14701393      // ----- Error log
    14711394      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
    1472       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
    14731395      return(false);
    14741396    }
    14751397
     
    14831405    // TBC
    14841406
    14851407    // ----- Return
    1486     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    14871408    return $v_result;
    14881409  }
    14891410  // --------------------------------------------------------------------------------
     
    15051426  // --------------------------------------------------------------------------------
    15061427  function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
    15071428  {
    1508     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", "");
    15091429    $v_result=1;
    15101430   
    15111431    // ----- Read the options
    15121432    $i=0;
    15131433    while ($i<$p_size) {
    1514       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'");
    15151434
    15161435      // ----- Check if the option is supported
    15171436      if (!isset($v_requested_options[$p_options_list[$i]])) {
     
    15191438        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
    15201439
    15211440        // ----- Return
    1522         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    15231441        return PclZip::errorCode();
    15241442      }
    15251443
     
    15351453            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    15361454
    15371455            // ----- Return
    1538             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    15391456            return PclZip::errorCode();
    15401457          }
    15411458
    15421459          // ----- Get the value
    15431460          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
    1544           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
    15451461          $i++;
    15461462        break;
    15471463
     
    15491465          // ----- Check the number of parameters
    15501466          if (($i+1) >= $p_size) {
    15511467            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    1552             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    15531468            return PclZip::errorCode();
    15541469          }
    15551470         
    15561471          // ----- Check for incompatible options
    15571472          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
    15581473            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
    1559             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    15601474            return PclZip::errorCode();
    15611475          }
    15621476         
     
    15641478          $v_value = $p_options_list[$i+1];
    15651479          if ((!is_integer($v_value)) || ($v_value<0)) {
    15661480            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    1567             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    15681481            return PclZip::errorCode();
    15691482          }
    15701483
    15711484          // ----- Get the value (and convert it in bytes)
    15721485          $v_result_list[$p_options_list[$i]] = $v_value*1048576;
    1573           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
    15741486          $i++;
    15751487        break;
    15761488
     
    15781490          // ----- Check for incompatible options
    15791491          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
    15801492            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
    1581             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    15821493            return PclZip::errorCode();
    15831494          }
    15841495         
    15851496          $v_result_list[$p_options_list[$i]] = true;
    1586           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
    15871497        break;
    15881498
    15891499        case PCLZIP_OPT_TEMP_FILE_OFF :
    15901500          // ----- Check for incompatible options
    15911501          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
    15921502            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
    1593             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    15941503            return PclZip::errorCode();
    15951504          }
    15961505          // ----- Check for incompatible options
    15971506          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
    15981507            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
    1599             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    16001508            return PclZip::errorCode();
    16011509          }
    16021510         
    16031511          $v_result_list[$p_options_list[$i]] = true;
    1604           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
    16051512        break;
    16061513
    16071514        case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
     
    16111518            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    16121519
    16131520            // ----- Return
    1614             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    16151521            return PclZip::errorCode();
    16161522          }
    16171523
     
    16191525          if (   is_string($p_options_list[$i+1])
    16201526              && ($p_options_list[$i+1] != '')) {
    16211527            $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
    1622             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
    16231528            $i++;
    16241529          }
    16251530          else {
    1626             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." set with an empty value is ignored.");
    16271531          }
    16281532        break;
    16291533
     
    16351539            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    16361540
    16371541            // ----- Return
    1638             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    16391542            return PclZip::errorCode();
    16401543          }
    16411544
     
    16511554            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    16521555
    16531556            // ----- Return
    1654             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    16551557            return PclZip::errorCode();
    16561558          }
    1657           ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
    16581559          $i++;
    16591560        break;
    16601561
    16611562        // ----- Look for options that request an EREG or PREG expression
    16621563        case PCLZIP_OPT_BY_EREG :
     1564          // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
     1565          // to PCLZIP_OPT_BY_PREG
     1566          $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
    16631567        case PCLZIP_OPT_BY_PREG :
    16641568        //case PCLZIP_OPT_CRYPT :
    16651569          // ----- Check the number of parameters
     
    16681572            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    16691573
    16701574            // ----- Return
    1671             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    16721575            return PclZip::errorCode();
    16731576          }
    16741577
     
    16811584            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    16821585
    16831586            // ----- Return
    1684             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    16851587            return PclZip::errorCode();
    16861588          }
    1687           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
    16881589          $i++;
    16891590        break;
    16901591
     
    17011602                                                                 ."'");
    17021603
    17031604            // ----- Return
    1704             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    17051605            return PclZip::errorCode();
    17061606          }
    17071607
     
    17171617                                                                 ."'");
    17181618
    17191619            // ----- Return
    1720             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    17211620            return PclZip::errorCode();
    17221621          }
    1723           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
    17241622          $i++;
    17251623        break;
    17261624
     
    17321630            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    17331631
    17341632            // ----- Return
    1735             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    17361633            return PclZip::errorCode();
    17371634          }
    17381635
    17391636          // ----- Get the value
    17401637          $v_work_list = array();
    17411638          if (is_string($p_options_list[$i+1])) {
    1742               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a string '".$p_options_list[$i+1]."'");
    17431639
    17441640              // ----- Remove spaces
    17451641              $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
     
    17481644              $v_work_list = explode(",", $p_options_list[$i+1]);
    17491645          }
    17501646          else if (is_integer($p_options_list[$i+1])) {
    1751               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an integer '".$p_options_list[$i+1]."'");
    17521647              $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
    17531648          }
    17541649          else if (is_array($p_options_list[$i+1])) {
    1755               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array");
    17561650              $v_work_list = $p_options_list[$i+1];
    17571651          }
    17581652          else {
     
    17601654            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    17611655
    17621656            // ----- Return
    1763             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    17641657            return PclZip::errorCode();
    17651658          }
    17661659         
     
    17941687                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    17951688
    17961689                  // ----- Return
    1797                   //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    17981690                  return PclZip::errorCode();
    17991691              }
    18001692
    1801               //--(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']."]");
    18021693
    18031694              // ----- Look for list sort
    18041695              if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
    1805                   //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The list should be sorted ...");
    18061696                  $v_sort_flag=true;
    18071697
    18081698                  // ----- TBC : An automatic sort should be writen ...
     
    18101700                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    18111701
    18121702                  // ----- Return
    1813                   //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    18141703                  return PclZip::errorCode();
    18151704              }
    18161705              $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
     
    18191708          // ----- Sort the items
    18201709          if ($v_sort_flag) {
    18211710              // TBC : To Be Completed
    1822               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "List sorting is not yet write ...");
    18231711          }
    18241712
    18251713          // ----- Next option
     
    18341722        case PCLZIP_OPT_REPLACE_NEWER :
    18351723        case PCLZIP_OPT_STOP_ON_ERROR :
    18361724          $v_result_list[$p_options_list[$i]] = true;
    1837           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
    18381725        break;
    18391726
    18401727        // ----- Look for options that request an octal value
     
    18451732            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    18461733
    18471734            // ----- Return
    1848             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    18491735            return PclZip::errorCode();
    18501736          }
    18511737
    18521738          // ----- Get the value
    18531739          $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
    1854           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
    18551740          $i++;
    18561741        break;
    18571742
     
    18721757            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    18731758
    18741759            // ----- Return
    1875             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    18761760            return PclZip::errorCode();
    18771761          }
    18781762
    18791763          // ----- Get the value
    18801764          $v_function_name = $p_options_list[$i+1];
    1881           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'");
    18821765
    18831766          // ----- Check that the value is a valid existing function
    18841767          if (!function_exists($v_function_name)) {
     
    18861769            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
    18871770
    18881771            // ----- Return
    1889             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    18901772            return PclZip::errorCode();
    18911773          }
    18921774
     
    19021784                                                           .$p_options_list[$i]."'");
    19031785
    19041786          // ----- Return
    1905           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    19061787          return PclZip::errorCode();
    19071788      }
    19081789
     
    19151796      for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
    19161797        // ----- Look for mandatory option
    19171798        if ($v_requested_options[$key] == 'mandatory') {
    1918           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");
    19191799          // ----- Look if present
    19201800          if (!isset($v_result_list[$key])) {
    19211801            // ----- Error log
    19221802            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
    19231803
    19241804            // ----- Return
    1925             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    19261805            return PclZip::errorCode();
    19271806          }
    19281807        }
     
    19311810   
    19321811    // ----- Look for default values
    19331812    if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
    1934       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Calculate auto threshold");
    19351813     
    19361814    }
    19371815
    19381816    // ----- Return
    1939     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    19401817    return $v_result;
    19411818  }
    19421819  // --------------------------------------------------------------------------------
     
    19491826  // --------------------------------------------------------------------------------
    19501827  function privOptionDefaultThreshold(&$p_options)
    19511828  {
    1952     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOptionDefaultThreshold", "");
    19531829    $v_result=1;
    19541830   
    19551831    if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
    19561832        || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
    1957       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    19581833      return $v_result;
    19591834    }
    19601835   
    1961     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Create an auto-threshold for use of temporay files");
    19621836    // ----- Get 'memory_limit' configuration value
    19631837    $v_memory_limit = ini_get('memory_limit');
    19641838    $v_memory_limit = trim($v_memory_limit);
     
    19751849           
    19761850    $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
    19771851   
    1978     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Current memory usage : ".memory_get_usage(TRUE)." bytes");
    1979     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Threshold value is : ".$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]." bytes");
    19801852
    19811853    // ----- Sanity check : No threshold if value lower than 1M
    19821854    if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
    1983       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Unset the threshold (value ".$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD].") because under 1Mo sanity check)");
    19841855      unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
    19851856    }
    19861857         
    19871858    // ----- Return
    1988     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    19891859    return $v_result;
    19901860  }
    19911861  // --------------------------------------------------------------------------------
     
    20001870  // --------------------------------------------------------------------------------
    20011871  function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
    20021872  {
    2003     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrParseAtt", "");
    20041873    $v_result=1;
    20051874   
    20061875    // ----- For each file in the list check the attributes
     
    20121881        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
    20131882
    20141883        // ----- Return
    2015         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    20161884        return PclZip::errorCode();
    20171885      }
    20181886
     
    20211889        case PCLZIP_ATT_FILE_NAME :
    20221890          if (!is_string($v_value)) {
    20231891            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
    2024             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    20251892            return PclZip::errorCode();
    20261893          }
    20271894
    20281895          $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
    2029           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
    20301896         
    20311897          if ($p_filedescr['filename'] == '') {
    20321898            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
    2033             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    20341899            return PclZip::errorCode();
    20351900          }
    20361901
     
    20391904        case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
    20401905          if (!is_string($v_value)) {
    20411906            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
    2042             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    20431907            return PclZip::errorCode();
    20441908          }
    20451909
    20461910          $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
    2047           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
    20481911
    20491912          if ($p_filedescr['new_short_name'] == '') {
    20501913            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
    2051             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    20521914            return PclZip::errorCode();
    20531915          }
    20541916        break;
     
    20561918        case PCLZIP_ATT_FILE_NEW_FULL_NAME :
    20571919          if (!is_string($v_value)) {
    20581920            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
    2059             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    20601921            return PclZip::errorCode();
    20611922          }
    20621923
    20631924          $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
    2064           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
    20651925
    20661926          if ($p_filedescr['new_full_name'] == '') {
    20671927            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
    2068             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    20691928            return PclZip::errorCode();
    20701929          }
    20711930        break;
     
    20741933        case PCLZIP_ATT_FILE_COMMENT :
    20751934          if (!is_string($v_value)) {
    20761935            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
    2077             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    20781936            return PclZip::errorCode();
    20791937          }
    20801938
    20811939          $p_filedescr['comment'] = $v_value;
    2082           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
    20831940        break;
    20841941
    20851942        case PCLZIP_ATT_FILE_MTIME :
    20861943          if (!is_integer($v_value)) {
    20871944            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
    2088             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    20891945            return PclZip::errorCode();
    20901946          }
    20911947
    20921948          $p_filedescr['mtime'] = $v_value;
    2093           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
    20941949        break;
    20951950
    20961951        case PCLZIP_ATT_FILE_CONTENT :
    20971952          $p_filedescr['content'] = $v_value;
    2098           ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
    20991953        break;
    21001954
    21011955        default :
     
    21041958                                           "Unknown parameter '".$v_key."'");
    21051959
    21061960          // ----- Return
    2107           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    21081961          return PclZip::errorCode();
    21091962      }
    21101963
     
    21131966        for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
    21141967          // ----- Look for mandatory option
    21151968          if ($v_requested_options[$key] == 'mandatory') {
    2116             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");
    21171969            // ----- Look if present
    21181970            if (!isset($p_file_list[$key])) {
    21191971              PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
    2120               //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    21211972              return PclZip::errorCode();
    21221973            }
    21231974          }
     
    21281979    }
    21291980   
    21301981    // ----- Return
    2131     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    21321982    return $v_result;
    21331983  }
    21341984  // --------------------------------------------------------------------------------
     
    21491999  // --------------------------------------------------------------------------------
    21502000  function privFileDescrExpand(&$p_filedescr_list, &$p_options)
    21512001  {
    2152     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrExpand", "");
    21532002    $v_result=1;
    21542003   
    21552004    // ----- Create a result list
     
    21572006   
    21582007    // ----- Look each entry
    21592008    for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
    2160       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for file ".$i.".");
    21612009     
    21622010      // ----- Get filedescr
    21632011      $v_descr = $p_filedescr_list[$i];
    21642012     
    21652013      // ----- Reduce the filename
    2166       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filedescr before reduction :'".$v_descr['filename']."'");
    21672014      $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
    21682015      $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
    2169       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filedescr after reduction :'".$v_descr['filename']."'");
    21702016     
    21712017      // ----- Look for real file or folder
    21722018      if (file_exists($v_descr['filename'])) {
    21732019        if (@is_file($v_descr['filename'])) {
    2174           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a file");
    21752020          $v_descr['type'] = 'file';
    21762021        }
    21772022        else if (@is_dir($v_descr['filename'])) {
    2178           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a folder");
    21792023          $v_descr['type'] = 'folder';
    21802024        }
    21812025        else if (@is_link($v_descr['filename'])) {
    2182           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : link");
    21832026          // skip
    21842027          continue;
    21852028        }
    21862029        else {
    2187           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : unknown type");
    21882030          // skip
    21892031          continue;
    21902032        }
     
    21922034     
    21932035      // ----- Look for string added as file
    21942036      else if (isset($v_descr['content'])) {
    2195         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a string added as a file");
    21962037        $v_descr['type'] = 'virtual_file';
    21972038      }
    21982039     
    21992040      // ----- Missing file
    22002041      else {
    22012042        // ----- Error log
    2202         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_descr['filename']."' does not exist");
    22032043        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
    22042044
    22052045        // ----- Return
    2206         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    22072046        return PclZip::errorCode();
    22082047      }
    22092048     
     
    22202059        $v_dirlist_nb = 0;
    22212060        if ($v_folder_handler = @opendir($v_descr['filename'])) {
    22222061          while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
    2223             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for '".$v_item_handler."' in the directory");
    22242062
    22252063            // ----- Skip '.' and '..'
    22262064            if (($v_item_handler == '.') || ($v_item_handler == '..')) {
     
    22482086          @closedir($v_folder_handler);
    22492087        }
    22502088        else {
    2251           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to open dir '".$v_descr['filename']."' in read mode. Skipped.");
    22522089          // TBC : unable to open folder in read mode
    22532090        }
    22542091       
     
    22562093        if ($v_dirlist_nb != 0) {
    22572094          // ----- Expand
    22582095          if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
    2259             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    22602096            return $v_result;
    22612097          }
    22622098         
    22632099          // ----- Concat the resulting list
    2264           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Merging result list (size '".sizeof($v_result_list)."') with dirlist (size '".sizeof($v_dirlist_descr)."')");
    22652100          $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
    2266           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "merged result list is size '".sizeof($v_result_list)."'");
    22672101        }
    22682102        else {
    2269           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Nothing in this folder to expand.");
    22702103        }
    22712104         
    22722105        // ----- Free local array
     
    22782111    $p_filedescr_list = $v_result_list;
    22792112
    22802113    // ----- Return
    2281     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    22822114    return $v_result;
    22832115  }
    22842116  // --------------------------------------------------------------------------------
     
    22912123  // --------------------------------------------------------------------------------
    22922124  function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
    22932125  {
    2294     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list");
    22952126    $v_result=1;
    22962127    $v_list_detail = array();
    22972128   
     
    23022133    if (($v_result = $this->privOpenFd('wb')) != 1)
    23032134    {
    23042135      // ----- Return
    2305       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    23062136      return $v_result;
    23072137    }
    23082138
     
    23162146    $this->privSwapBackMagicQuotes();
    23172147
    23182148    // ----- Return
    2319     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    23202149    return $v_result;
    23212150  }
    23222151  // --------------------------------------------------------------------------------
     
    23292158  // --------------------------------------------------------------------------------
    23302159  function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
    23312160  {
    2332     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list");
    23332161    $v_result=1;
    23342162    $v_list_detail = array();
    23352163
    23362164    // ----- Look if the archive exists or is empty
    23372165    if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
    23382166    {
    2339       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it.");
    23402167
    23412168      // ----- Do a create
    23422169      $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
    23432170
    23442171      // ----- Return
    2345       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    23462172      return $v_result;
    23472173    }
    23482174    // ----- Magic quotes trick
    23492175    $this->privDisableMagicQuotes();
    23502176
    23512177    // ----- Open the zip file
    2352     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
    23532178    if (($v_result=$this->privOpenFd('rb')) != 1)
    23542179    {
    23552180      // ----- Magic quotes trick
    23562181      $this->privSwapBackMagicQuotes();
    23572182
    23582183      // ----- Return
    2359       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    23602184      return $v_result;
    23612185    }
    23622186
     
    23662190    {
    23672191      $this->privCloseFd();
    23682192      $this->privSwapBackMagicQuotes();
    2369       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    23702193      return $v_result;
    23712194    }
    23722195
    23732196    // ----- Go to beginning of File
    2374     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
    23752197    @rewind($this->zip_fd);
    2376     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
    23772198
    23782199    // ----- Creates a temporay file
    23792200    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
    23802201
    23812202    // ----- Open the temporary file in write mode
    2382     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
    23832203    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
    23842204    {
    23852205      $this->privCloseFd();
     
    23882208      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
    23892209
    23902210      // ----- Return
    2391       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    23922211      return PclZip::errorCode();
    23932212    }
    23942213
     
    23982217    while ($v_size != 0)
    23992218    {
    24002219      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
    2401       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
    24022220      $v_buffer = fread($this->zip_fd, $v_read_size);
    24032221      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
    24042222      $v_size -= $v_read_size;
     
    24212239      $this->privSwapBackMagicQuotes();
    24222240
    24232241      // ----- Return
    2424       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    24252242      return $v_result;
    24262243    }
    24272244
    24282245    // ----- Store the offset of the central dir
    24292246    $v_offset = @ftell($this->zip_fd);
    2430     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
    24312247
    24322248    // ----- Copy the block of file headers from the old archive
    24332249    $v_size = $v_central_dir['size'];
    24342250    while ($v_size != 0)
    24352251    {
    24362252      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
    2437       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
    24382253      $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
    24392254      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
    24402255      $v_size -= $v_read_size;
     
    24522267          $this->privSwapBackMagicQuotes();
    24532268
    24542269          // ----- Return
    2455           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    24562270          return $v_result;
    24572271        }
    24582272        $v_count++;
     
    24852299      $this->privSwapBackMagicQuotes();
    24862300
    24872301      // ----- Return
    2488       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    24892302      return $v_result;
    24902303    }
    24912304
     
    25132326    PclZipUtilRename($v_zip_temp_name, $this->zipname);
    25142327
    25152328    // ----- Return
    2516     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    25172329    return $v_result;
    25182330  }
    25192331  // --------------------------------------------------------------------------------
     
    25252337  // --------------------------------------------------------------------------------
    25262338  function privOpenFd($p_mode)
    25272339  {
    2528     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$p_mode);
    25292340    $v_result=1;
    25302341
    25312342    // ----- Look if already open
     
    25352346      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
    25362347
    25372348      // ----- Return
    2538       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    25392349      return PclZip::errorCode();
    25402350    }
    25412351
    25422352    // ----- Open the zip file
    2543     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode');
    25442353    if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
    25452354    {
    25462355      // ----- Error log
    25472356      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
    25482357
    25492358      // ----- Return
    2550       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    25512359      return PclZip::errorCode();
    25522360    }
    25532361
    25542362    // ----- Return
    2555     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    25562363    return $v_result;
    25572364  }
    25582365  // --------------------------------------------------------------------------------
     
    25642371  // --------------------------------------------------------------------------------
    25652372  function privCloseFd()
    25662373  {
    2567     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", "");
    25682374    $v_result=1;
    25692375
    25702376    if ($this->zip_fd != 0)
     
    25722378    $this->zip_fd = 0;
    25732379
    25742380    // ----- Return
    2575     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    25762381    return $v_result;
    25772382  }
    25782383  // --------------------------------------------------------------------------------
     
    25932398//  function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
    25942399  function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
    25952400  {
    2596     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list");
    25972401    $v_result=1;
    25982402
    25992403    // ----- Add the files
     
    26012405    if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
    26022406    {
    26032407      // ----- Return
    2604       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    26052408      return $v_result;
    26062409    }
    26072410
     
    26152418      if ($v_header_list[$i]['status'] == 'ok') {
    26162419        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
    26172420          // ----- Return
    2618           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    26192421          return $v_result;
    26202422        }
    26212423        $v_count++;
     
    26412443      unset($v_header_list);
    26422444
    26432445      // ----- Return
    2644       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    26452446      return $v_result;
    26462447    }
    26472448
    26482449    // ----- Return
    2649     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    26502450    return $v_result;
    26512451  }
    26522452  // --------------------------------------------------------------------------------
     
    26622462  // --------------------------------------------------------------------------------
    26632463  function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
    26642464  {
    2665     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "filedescr_list");
    26662465    $v_result=1;
    26672466    $v_header = array();
    26682467
    26692468    // ----- Recuperate the current number of elt in list
    26702469    $v_nb = sizeof($p_result_list);
    2671     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have ".$v_nb." elements");
    26722470
    26732471    // ----- Loop on the files
    26742472    for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
     
    26762474      $p_filedescr_list[$j]['filename']
    26772475      = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
    26782476     
    2679       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file '".$p_filedescr_list[$j]['filename']."'");
    26802477
    26812478      // ----- Skip empty file names
    26822479      // TBC : Can this be possible ? not checked in DescrParseAtt ?
    26832480      if ($p_filedescr_list[$j]['filename'] == "") {
    2684         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Skip empty filename");
    26852481        continue;
    26862482      }
    26872483
    26882484      // ----- Check the filename
    26892485      if (   ($p_filedescr_list[$j]['type'] != 'virtual_file')
    26902486          && (!file_exists($p_filedescr_list[$j]['filename']))) {
    2691         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
    26922487        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
    2693         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    26942488        return PclZip::errorCode();
    26952489      }
    26962490
     
    27092503        $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
    27102504                                       $p_options);
    27112505        if ($v_result != 1) {
    2712           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    27132506          return $v_result;
    27142507        }
    27152508
     
    27172510        $p_result_list[$v_nb++] = $v_header;
    27182511      }
    27192512    }
    2720     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have ".$v_nb." elements");
    27212513
    27222514    // ----- Return
    2723     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    27242515    return $v_result;
    27252516  }
    27262517  // --------------------------------------------------------------------------------
     
    27332524  // --------------------------------------------------------------------------------
    27342525  function privAddFile($p_filedescr, &$p_header, &$p_options)
    27352526  {
    2736     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='".$p_filedescr['filename']."'");
    27372527    $v_result=1;
    27382528   
    27392529    // ----- Working variable
     
    27452535      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
    27462536
    27472537      // ----- Return
    2748       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    27492538      return PclZip::errorCode();
    27502539    }
    27512540 
     
    27532542    /* TBC : Removed
    27542543    if (isset($p_filedescr['stored_filename'])) {
    27552544      $v_stored_filename = $p_filedescr['stored_filename'];
    2756       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is NOT the same "'.$v_stored_filename.'"');
    27572545    }
    27582546    else {
    27592547      $v_stored_filename = $p_filedescr['stored_filename'];
    2760       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is the same');
    27612548    }
    27622549    */
    27632550
     
    28002587      $p_header['size'] = strlen($p_filedescr['content']);
    28012588    }
    28022589   
    2803     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header external extension '".sprintf("0x%X",$p_header['external'])."'");
    28042590
    28052591    // ----- Look for filetime
    28062592    if (isset($p_filedescr['mtime'])) {
    2807       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Overload mtime value with :'".$p_filedescr['mtime']."'");
    28082593      $p_header['mtime'] = $p_filedescr['mtime'];
    28092594    }
    28102595    else if ($p_filedescr['type'] == 'virtual_file') {
    28112596      $p_header['mtime'] = time();
    2812       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Virtual file : use current time '".$p_header['mtime']."' for mtime value.");
    28132597    }
    28142598    else {
    28152599      $p_header['mtime'] = filemtime($p_filename);
     
    28272611
    28282612    // ----- Look for pre-add callback
    28292613    if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
    2830       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction");
    28312614
    28322615      // ----- Generate a local information
    28332616      $v_local_header = array();
     
    28472630      // Only some fields can be modified
    28482631      if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
    28492632        $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
    2850         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_header['stored_filename']."'");
    28512633      }
    28522634    }
    28532635
     
    28792661       
    28802662        // ----- Use "in memory" zip algo
    28812663        else {
    2882           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"In memory compression.");     
    2883           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Current memory usage : ".memory_get_usage(TRUE)." bytes");     
    2884           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Current memory peak : ".memory_get_peak_usage(TRUE)." bytes");     
    2885           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file");
    28862664
    28872665        // ----- Open the source file
    28882666        if (($v_file = @fopen($p_filename, "rb")) == 0) {
    28892667          PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
    2890           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    28912668          return PclZip::errorCode();
    28922669        }
    28932670
    28942671        // ----- Read the file content
    28952672        $v_content = @fread($v_file, $p_header['size']);
    2896         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Memory usage after reading file : ".memory_get_usage(TRUE)." bytes");     
    2897         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Memory peak after reading file : ".memory_get_peak_usage(TRUE)." bytes");     
    28982673
    28992674        // ----- Close the file
    29002675        @fclose($v_file);
     
    29042679       
    29052680        // ----- Look for no compression
    29062681        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
    2907           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed");
    29082682          // ----- Set header parameters
    29092683          $p_header['compressed_size'] = $p_header['size'];
    29102684          $p_header['compression'] = 0;
     
    29122686       
    29132687        // ----- Look for normal compression
    29142688        else {
    2915           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed");
    29162689          // ----- Compress the content
    29172690          $v_content = @gzdeflate($v_content);
    2918           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Memory usage after gzdeflate : ".memory_get_usage(TRUE)." bytes");     
    2919           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Memory peak after gzdeflate : ".memory_get_peak_usage(TRUE)." bytes");     
    29202691
    29212692          // ----- Set header parameters
    29222693          $p_header['compressed_size'] = strlen($v_content);
     
    29262697        // ----- Call the header generation
    29272698        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
    29282699          @fclose($v_file);
    2929           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    29302700          return $v_result;
    29312701        }
    29322702
     
    29402710      // ----- Look for a virtual file (a file from string)
    29412711      else if ($p_filedescr['type'] == 'virtual_file') {
    29422712         
    2943         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Add by string");
    29442713        $v_content = $p_filedescr['content'];
    29452714
    29462715        // ----- Calculate the CRC
     
    29482717       
    29492718        // ----- Look for no compression
    29502719        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
    2951           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed");
    29522720          // ----- Set header parameters
    29532721          $p_header['compressed_size'] = $p_header['size'];
    29542722          $p_header['compression'] = 0;
     
    29562724       
    29572725        // ----- Look for normal compression
    29582726        else {
    2959           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed");
    29602727          // ----- Compress the content
    29612728          $v_content = @gzdeflate($v_content);
    29622729
     
    29682735        // ----- Call the header generation
    29692736        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
    29702737          @fclose($v_file);
    2971           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    29722738          return $v_result;
    29732739        }
    29742740
     
    29782744
    29792745      // ----- Look for a directory
    29802746      else if ($p_filedescr['type'] == 'folder') {
    2981         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a folder");
    29822747        // ----- Look for directory last '/'
    29832748        if (@substr($p_header['stored_filename'], -1) != '/') {
    29842749          $p_header['stored_filename'] .= '/';
     
    29922757        // ----- Call the header generation
    29932758        if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
    29942759        {
    2995           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    29962760          return $v_result;
    29972761        }
    29982762      }
     
    30002764
    30012765    // ----- Look for post-add callback
    30022766    if (isset($p_options[PCLZIP_CB_POST_ADD])) {
    3003       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction");
    30042767
    30052768      // ----- Generate a local information
    30062769      $v_local_header = array();
     
    30202783    }
    30212784
    30222785    // ----- Return
    3023     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    30242786    return $v_result;
    30252787  }
    30262788  // --------------------------------------------------------------------------------
     
    30332795  // --------------------------------------------------------------------------------
    30342796  function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
    30352797  {
    3036     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileUsingTempFile", "filename='".$p_filedescr['filename']."'");
    30372798    $v_result=PCLZIP_ERR_NO_ERROR;
    30382799   
    30392800    // ----- Working variable
    30402801    $p_filename = $p_filedescr['filename'];
    30412802
    3042     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file");
    30432803
    30442804    // ----- Open the source file
    30452805    if (($v_file = @fopen($p_filename, "rb")) == 0) {
    30462806      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
    3047       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    30482807      return PclZip::errorCode();
    30492808    }
    30502809
     
    30532812    if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
    30542813      fclose($v_file);
    30552814      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
    3056       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    30572815      return PclZip::errorCode();
    30582816    }
    30592817
     
    30612819    $v_size = filesize($p_filename);
    30622820    while ($v_size != 0) {
    30632821      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
    3064       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read ".$v_read_size." bytes");
    30652822      $v_buffer = @fread($v_file, $v_read_size);
    30662823      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
    30672824      @gzputs($v_file_compressed, $v_buffer, $v_read_size);
     
    30732830    @gzclose($v_file_compressed);
    30742831
    30752832    // ----- Check the minimum file size
    3076     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "gzip file size ".filesize($v_gzip_temp_name));
    30772833    if (filesize($v_gzip_temp_name) < 18) {
    30782834      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
    3079       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    30802835      return PclZip::errorCode();
    30812836    }
    30822837
    30832838    // ----- Extract the compressed attributes
    30842839    if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
    30852840      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
    3086       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    30872841      return PclZip::errorCode();
    30882842    }
    30892843
     
    30922846    $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
    30932847
    30942848    // ----- Check some parameters
    3095     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[id1]='.bin2hex($v_data_header['id1']));
    3096     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[id2]='.bin2hex($v_data_header['id2']));
    3097     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[cm]='.bin2hex($v_data_header['cm']));
    3098     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[flag]='.bin2hex($v_data_header['flag']));
    3099     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[mtime]='.$v_data_header['mtime']);
    3100     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[xfl]='.bin2hex($v_data_header['xfl']));
    3101     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[os]='.bin2hex($v_data_header['os']));
    31022849    $v_data_header['os'] = bin2hex($v_data_header['os']);
    31032850
    31042851    // ----- Read the gzip file footer
    3105     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position after header ".ftell($v_file_compressed));
    31062852    @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
    3107     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position at beginning of footer ".ftell($v_file_compressed));
    31082853    $v_binary_data = @fread($v_file_compressed, 8);
    3109     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position after footer ".ftell($v_file_compressed));
    31102854    $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
    31112855
    31122856    // ----- Set the attributes
    31132857    $p_header['compression'] = ord($v_data_header['cm']);
    31142858    //$p_header['mtime'] = $v_data_header['mtime'];
    31152859    $p_header['crc'] = $v_data_footer['crc'];
    3116     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Compressed size ".(filesize($v_gzip_temp_name)-18));
    31172860    $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
    31182861
    31192862    // ----- Close the file
     
    31212864
    31222865    // ----- Call the header generation
    31232866    if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
    3124       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    31252867      return $v_result;
    31262868    }
    31272869
     
    31292871    if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
    31302872    {
    31312873      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
    3132       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    31332874      return PclZip::errorCode();
    31342875    }
    31352876
    31362877    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
    31372878    fseek($v_file_compressed, 10);
    3138     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position before reading compressed data ".ftell($v_file_compressed));
    3139     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, ' '.$p_header['compressed_size'].' bytes to read');
    31402879    $v_size = $p_header['compressed_size'];
    31412880    while ($v_size != 0)
    31422881    {
    31432882      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
    3144       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read ".$v_read_size." bytes");
    31452883      $v_buffer = @fread($v_file_compressed, $v_read_size);
    31462884      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
    31472885      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
     
    31552893    @unlink($v_gzip_temp_name);
    31562894   
    31572895    // ----- Return
    3158     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    31592896    return $v_result;
    31602897  }
    31612898  // --------------------------------------------------------------------------------
     
    31702907  // --------------------------------------------------------------------------------
    31712908  function privCalculateStoredFilename(&$p_filedescr, &$p_options)
    31722909  {
    3173     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCalculateStoredFilename", "filename='".$p_filedescr['filename']."'");
    31742910    $v_result=1;
    31752911   
    31762912    // ----- Working variables
     
    31872923    else {
    31882924      $p_remove_dir = '';
    31892925    }
    3190     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Remove path ='".$p_remove_dir."'");
    31912926    if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
    31922927      $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
    31932928    }
     
    31992934    if (isset($p_filedescr['new_full_name'])) {
    32002935      // ----- Remove drive letter if any
    32012936      $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
    3202       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing full name of '".$p_filename."' for '".$v_stored_filename."'");
    32032937    }
    32042938   
    32052939    // ----- Look for path and/or short name change
     
    32142948          $v_dir = $v_path_info['dirname'].'/';
    32152949        }
    32162950        $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
    3217         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing short name of '".$p_filename."' for '".$v_stored_filename."'");
    32182951      }
    32192952      else {
    32202953        // ----- Calculate the stored filename
     
    32242957      // ----- Look for all path to remove
    32252958      if ($p_remove_all_dir) {
    32262959        $v_stored_filename = basename($p_filename);
    3227         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove all path selected change '".$p_filename."' for '".$v_stored_filename."'");
    32282960      }
    32292961      // ----- Look for partial path remove
    32302962      else if ($p_remove_dir != "") {
    3231         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Partial path to remove");
    32322963        if (substr($p_remove_dir, -1) != '/')
    32332964          $p_remove_dir .= "/";
    32342965
     
    32502981        if ($v_compare > 0) {
    32512982          if ($v_compare == 2) {
    32522983            $v_stored_filename = "";
    3253             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder");
    32542984          }
    32552985          else {
    3256             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$v_stored_filename'");
    32572986            $v_stored_filename = substr($v_stored_filename,
    32582987                                        strlen($p_remove_dir));
    3259             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Result is '$v_stored_filename'");
    32602988          }
    32612989        }
    32622990      }
     
    32702998          $v_stored_filename = $p_add_dir.$v_stored_filename;
    32712999        else
    32723000          $v_stored_filename = $p_add_dir."/".$v_stored_filename;
    3273         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'");
    32743001      }
    32753002    }
    32763003
    32773004    // ----- Filename (reduce the path of stored name)
    32783005    $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
    32793006    $p_filedescr['stored_filename'] = $v_stored_filename;
    3280     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Stored filename will be '".$p_filedescr['stored_filename']."', strlen ".strlen($p_filedescr['stored_filename']));
    32813007   
    32823008    // ----- Return
    3283     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    32843009    return $v_result;
    32853010  }
    32863011  // --------------------------------------------------------------------------------
     
    32933018  // --------------------------------------------------------------------------------
    32943019  function privWriteFileHeader(&$p_header)
    32953020  {
    3296     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
    32973021    $v_result=1;
    32983022
    32993023    // ----- Store the offset position of the file
    33003024    $p_header['offset'] = ftell($this->zip_fd);
    3301     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']);
    33023025
    33033026    // ----- Transform UNIX mtime to DOS format mdate/mtime
    3304     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
    33053027    $v_date = getdate($p_header['mtime']);
    33063028    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
    33073029    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
     
    33293051    }
    33303052
    33313053    // ----- Return
    3332     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    33333054    return $v_result;
    33343055  }
    33353056  // --------------------------------------------------------------------------------
     
    33423063  // --------------------------------------------------------------------------------
    33433064  function privWriteCentralFileHeader(&$p_header)
    33443065  {
    3345     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
    33463066    $v_result=1;
    33473067
    33483068    // TBC
    33493069    //for(reset($p_header); $key = key($p_header); next($p_header)) {
    3350     //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);
    33513070    //}
    33523071
    33533072    // ----- Transform UNIX mtime to DOS format mdate/mtime
    3354     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
    33553073    $v_date = getdate($p_header['mtime']);
    33563074    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
    33573075    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
    33583076
    3359     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment size : \''.$p_header['comment_len'].'\'');
    33603077
    33613078    // ----- Packed data
    33623079    $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
     
    33873104    }
    33883105
    33893106    // ----- Return
    3390     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    33913107    return $v_result;
    33923108  }
    33933109  // --------------------------------------------------------------------------------
     
    34003116  // --------------------------------------------------------------------------------
    34013117  function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
    34023118  {
    3403     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$p_comment.'"');
    34043119    $v_result=1;
    34053120
    34063121    // ----- Packed data
     
    34183133    }
    34193134
    34203135    // ----- Return
    3421     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    34223136    return $v_result;
    34233137  }
    34243138  // --------------------------------------------------------------------------------
     
    34313145  // --------------------------------------------------------------------------------
    34323146  function privList(&$p_list)
    34333147  {
    3434     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list");
    34353148    $v_result=1;
    34363149
    34373150    // ----- Magic quotes trick
    34383151    $this->privDisableMagicQuotes();
    34393152
    34403153    // ----- Open the zip file
    3441     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
    34423154    if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
    34433155    {
    34443156      // ----- Magic quotes trick
     
    34483160      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
    34493161
    34503162      // ----- Return
    3451       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    34523163      return PclZip::errorCode();
    34533164    }
    34543165
     
    34573168    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
    34583169    {
    34593170      $this->privSwapBackMagicQuotes();
    3460       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    34613171      return $v_result;
    34623172    }
    34633173
    34643174    // ----- Go to beginning of Central Dir
    3465     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'");
    3466     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
    34673175    @rewind($this->zip_fd);
    3468     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
    34693176    if (@fseek($this->zip_fd, $v_central_dir['offset']))
    34703177    {
    34713178      $this->privSwapBackMagicQuotes();
     
    34743181      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
    34753182
    34763183      // ----- Return
    3477       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    34783184      return PclZip::errorCode();
    34793185    }
    3480     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
    34813186
    34823187    // ----- Read each entry
    34833188    for ($i=0; $i<$v_central_dir['entries']; $i++)
     
    34863191      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
    34873192      {
    34883193        $this->privSwapBackMagicQuotes();
    3489         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    34903194        return $v_result;
    34913195      }
    34923196      $v_header['index'] = $i;
     
    35033207    $this->privSwapBackMagicQuotes();
    35043208
    35053209    // ----- Return
    3506     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    35073210    return $v_result;
    35083211  }
    35093212  // --------------------------------------------------------------------------------
     
    35293232  // --------------------------------------------------------------------------------
    35303233  function privConvertHeader2FileInfo($p_header, &$p_info)
    35313234  {
    3532     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'");
    35333235    $v_result=1;
    35343236
    35353237    // ----- Get the interesting attributes
     
    35473249    $p_info['crc'] = $p_header['crc'];
    35483250
    35493251    // ----- Return
    3550     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    35513252    return $v_result;
    35523253  }
    35533254  // --------------------------------------------------------------------------------
     
    35703271  // --------------------------------------------------------------------------------
    35713272  function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
    35723273  {
    3573     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
    35743274    $v_result=1;
    35753275
    35763276    // ----- Magic quotes trick
     
    35893289      // ----- Look for the path end '/'
    35903290      while (substr($p_path, -1) == "/")
    35913291      {
    3592         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'");
    35933292        $p_path = substr($p_path, 0, strlen($p_path)-1);
    3594         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]");
    35953293      }
    35963294    }
    35973295
     
    36033301    $p_remove_path_size = strlen($p_remove_path);
    36043302
    36053303    // ----- Open the zip file
    3606     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
    36073304    if (($v_result = $this->privOpenFd('rb')) != 1)
    36083305    {
    36093306      $this->privSwapBackMagicQuotes();
    3610       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    36113307      return $v_result;
    36123308    }
    36133309
     
    36193315      $this->privCloseFd();
    36203316      $this->privSwapBackMagicQuotes();
    36213317
    3622       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    36233318      return $v_result;
    36243319    }
    36253320
     
    36303325    $j_start = 0;
    36313326    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
    36323327    {
    3633       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'");
    36343328
    36353329      // ----- Read next Central dir entry
    3636       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'");
    36373330      @rewind($this->zip_fd);
    3638       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($this->zip_fd)."'");
    36393331      if (@fseek($this->zip_fd, $v_pos_entry))
    36403332      {
    36413333        // ----- Close the zip file
     
    36463338        PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
    36473339
    36483340        // ----- Return
    3649         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    36503341        return PclZip::errorCode();
    36513342      }
    3652       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");
    36533343
    36543344      // ----- Read the file header
    36553345      $v_header = array();
     
    36593349        $this->privCloseFd();
    36603350        $this->privSwapBackMagicQuotes();
    36613351
    3662         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    36633352        return $v_result;
    36643353      }
    36653354
     
    36753364      // ----- Look for extract by name rule
    36763365      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
    36773366          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
    3678           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
    36793367
    36803368          // ----- Look if the filename is in the list
    36813369          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
    3682               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
    36833370
    36843371              // ----- Look for a directory
    36853372              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
    3686                   //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
    36873373
    36883374                  // ----- Look if the directory is in the filename path
    36893375                  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
    36903376                      && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
    3691                       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
    36923377                      $v_extract = true;
    36933378                  }
    36943379              }
    36953380              // ----- Look for a filename
    36963381              elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
    3697                   //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
    36983382                  $v_extract = true;
    36993383              }
    37003384          }
    37013385      }
    37023386
    37033387      // ----- Look for extract by ereg rule
     3388      // ereg() is deprecated with PHP 5.3
     3389      /*
    37043390      else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
    37053391               && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
    3706           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
    37073392
    37083393          if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
    3709               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
    37103394              $v_extract = true;
    37113395          }
    37123396      }
     3397      */
    37133398
    37143399      // ----- Look for extract by preg rule
    37153400      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
    37163401               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
    3717           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
    37183402
    37193403          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
    3720               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
    37213404              $v_extract = true;
    37223405          }
    37233406      }
     
    37253408      // ----- Look for extract by index rule
    37263409      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
    37273410               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
    3728           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
    37293411         
    37303412          // ----- Look if the index is in the list
    37313413          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
    3732               //--(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']."]");
    37333414
    37343415              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
    3735                   //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
    37363416                  $v_extract = true;
    37373417              }
    37383418              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
    3739                   //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
    37403419                  $j_start = $j+1;
    37413420              }
    37423421
    37433422              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
    3744                   //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
    37453423                  break;
    37463424              }
    37473425          }
     
    37493427
    37503428      // ----- Look for no rule, which means extract all the archive
    37513429      else {
    3752           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)");
    37533430          $v_extract = true;
    37543431      }
    37553432
     
    37573434          if (   ($v_extract)
    37583435              && (   ($v_header['compression'] != 8)
    37593436                      && ($v_header['compression'] != 0))) {
    3760           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported compression method (".$v_header['compression'].")");
    37613437          $v_header['status'] = 'unsupported_compression';
    37623438
    37633439          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
    37643440          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
    37653441                      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
    3766               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
    37673442
    37683443              $this->privSwapBackMagicQuotes();
    37693444             
     
    37723447                                                           ."compressed by an unsupported compression "
    37733448                                                           ."method (".$v_header['compression'].") ");
    37743449
    3775               //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    37763450              return PclZip::errorCode();
    37773451                  }
    37783452          }
    37793453         
    37803454          // ----- Check encrypted files
    37813455          if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
    3782           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported file encryption");
    37833456          $v_header['status'] = 'unsupported_encryption';
    37843457
    37853458          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
    37863459          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
    37873460                      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
    3788               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
    37893461
    37903462              $this->privSwapBackMagicQuotes();
    37913463
     
    37943466                                                           ." filename '".$v_header['stored_filename']
    37953467                                                                   ."'");
    37963468
    3797               //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    37983469              return PclZip::errorCode();
    37993470                  }
    38003471    }
    38013472
    38023473      // ----- Look for real extraction
    38033474      if (($v_extract) && ($v_header['status'] != 'ok')) {
    3804           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "No need for extract");
    38053475          $v_result = $this->privConvertHeader2FileInfo($v_header,
    38063476                                                        $p_file_list[$v_nb_extracted++]);
    38073477          if ($v_result != 1) {
    38083478              $this->privCloseFd();
    38093479              $this->privSwapBackMagicQuotes();
    3810               //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    38113480              return $v_result;
    38123481          }
    38133482
     
    38173486      // ----- Look for real extraction
    38183487      if ($v_extract)
    38193488      {
    3820         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'");
    38213489
    38223490        // ----- Go to the file position
    3823         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
    38243491        @rewind($this->zip_fd);
    3825         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
    38263492        if (@fseek($this->zip_fd, $v_header['offset']))
    38273493        {
    38283494          // ----- Close the zip file
     
    38343500          PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
    38353501
    38363502          // ----- Return
    3837           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    38383503          return PclZip::errorCode();
    38393504        }
    3840         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
    38413505
    38423506        // ----- Look for extraction as string
    38433507        if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
     
    38473511          if ($v_result1 < 1) {
    38483512            $this->privCloseFd();
    38493513            $this->privSwapBackMagicQuotes();
    3850             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
    38513514            return $v_result1;
    38523515          }
    38533516
     
    38583521            $this->privCloseFd();
    38593522            $this->privSwapBackMagicQuotes();
    38603523
    3861             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    38623524            return $v_result;
    38633525          }
    38643526
     
    38813543          if ($v_result1 < 1) {
    38823544            $this->privCloseFd();
    38833545            $this->privSwapBackMagicQuotes();
    3884             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
    38853546            return $v_result1;
    38863547          }
    38873548
     
    38893550          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
    38903551            $this->privCloseFd();
    38913552            $this->privSwapBackMagicQuotes();
    3892             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    38933553            return $v_result;
    38943554          }
    38953555
     
    39083568          if ($v_result1 < 1) {
    39093569            $this->privCloseFd();
    39103570            $this->privSwapBackMagicQuotes();
    3911             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
    39123571            return $v_result1;
    39133572          }
    39143573
     
    39193578            $this->privCloseFd();
    39203579            $this->privSwapBackMagicQuotes();
    39213580
    3922             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    39233581            return $v_result;
    39243582          }
    39253583
     
    39363594    $this->privSwapBackMagicQuotes();
    39373595
    39383596    // ----- Return
    3939     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    39403597    return $v_result;
    39413598  }
    39423599  // --------------------------------------------------------------------------------
     
    39523609  // --------------------------------------------------------------------------------
    39533610  function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
    39543611  {
    3955     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
    39563612    $v_result=1;
    39573613
    39583614    // ----- Read the file header
    39593615    if (($v_result = $this->privReadFileHeader($v_header)) != 1)
    39603616    {
    39613617      // ----- Return
    3962       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    39633618      return $v_result;
    39643619    }
    39653620
    3966     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
    39673621
    39683622    // ----- Check that the file header is coherent with $p_entry info
    39693623    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
     
    39743628    if ($p_remove_all_path == true) {
    39753629        // ----- Look for folder entry that not need to be extracted
    39763630        if (($p_entry['external']&0x00000010)==0x00000010) {
    3977             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The entry is a folder : need to be filtered");
    39783631
    39793632            $p_entry['status'] = "filtered";
    39803633
    3981             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    39823634            return $v_result;
    39833635        }
    39843636
    3985         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "All path is removed");
    39863637        // ----- Get the basename of the path
    39873638        $p_entry['filename'] = basename($p_entry['filename']);
    39883639    }
     
    39903641    // ----- Look for path to remove
    39913642    else if ($p_remove_path != "")
    39923643    {
    3993       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look for some path to remove");
    39943644      if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
    39953645      {
    3996         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'");
    39973646
    39983647        // ----- Change the file status
    39993648        $p_entry['status'] = "filtered";
    40003649
    40013650        // ----- Return
    4002         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    40033651        return $v_result;
    40043652      }
    40053653
    40063654      $p_remove_path_size = strlen($p_remove_path);
    40073655      if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
    40083656      {
    4009         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'");
    40103657
    40113658        // ----- Remove the path
    40123659        $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
    40133660
    4014         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'");
    40153661      }
    40163662    }
    40173663
     
    40223668   
    40233669    // ----- Check a base_dir_restriction
    40243670    if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
    4025       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Check the extract directory restriction");
    40263671      $v_inclusion
    40273672      = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
    40283673                                $p_entry['filename']);
    40293674      if ($v_inclusion == 0) {
    4030         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_EXTRACT_DIR_RESTRICTION is selected, file is outside restriction");
    40313675
    40323676        PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
    40333677                                             "Filename '".$p_entry['filename']."' is "
    40343678                                                                 ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
    40353679
    4036         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    40373680        return PclZip::errorCode();
    40383681      }
    40393682    }
    40403683
    40413684    // ----- Look for pre-extract callback
    40423685    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
    4043       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");
    40443686
    40453687      // ----- Generate a local information
    40463688      $v_local_header = array();
     
    40583700     
    40593701      // ----- Look for abort result
    40603702      if ($v_result == 2) {
    4061         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
    40623703        // ----- This status is internal and will be changed in 'skipped'
    40633704        $p_entry['status'] = "aborted";
    40643705        $v_result = PCLZIP_ERR_USER_ABORTED;
     
    40673708      // ----- Update the informations
    40683709      // Only some fields can be modified
    40693710      $p_entry['filename'] = $v_local_header['filename'];
    4070       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");
    40713711    }
    40723712
    4073     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");
    40743713
    40753714    // ----- Look if extraction should be done
    40763715    if ($p_entry['status'] == 'ok') {
     
    40783717    // ----- Look for specific actions while the file exist
    40793718    if (file_exists($p_entry['filename']))
    40803719    {
    4081       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists");
    40823720
    40833721      // ----- Look if file is a directory
    40843722      if (is_dir($p_entry['filename']))
    40853723      {
    4086         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory");
    40873724
    40883725        // ----- Change the file status
    40893726        $p_entry['status'] = "already_a_directory";
     
    40933730        // when this kind of error occurs.
    40943731        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
    40953732                    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
    4096             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
    40973733
    40983734            PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
    40993735                                             "Filename '".$p_entry['filename']."' is "
    41003736                                                                 ."already used by an existing directory");
    41013737
    4102             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    41033738            return PclZip::errorCode();
    41043739                    }
    41053740      }
    41063741      // ----- Look if file is write protected
    41073742      else if (!is_writeable($p_entry['filename']))
    41083743      {
    4109         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected");
    41103744
    41113745        // ----- Change the file status
    41123746        $p_entry['status'] = "write_protected";
     
    41163750        // when this kind of error occurs.
    41173751        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
    41183752                    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
    4119             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
    41203753
    41213754            PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
    41223755                                             "Filename '".$p_entry['filename']."' exists "
    41233756                                                                 ."and is write protected");
    41243757
    4125             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    41263758            return PclZip::errorCode();
    41273759                    }
    41283760      }
     
    41303762      // ----- Look if the extracted file is older
    41313763      else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
    41323764      {
    4133         //--(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']).")");
    41343765        // ----- Change the file status
    41353766        if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
    41363767                    && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
    4137             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_REPLACE_NEWER is selected, file will be replaced");
    41383768                  }
    41393769                    else {
    4140             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be replaced");
    41413770            $p_entry['status'] = "newer_exist";
    41423771
    41433772            // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
     
    41453774            // when this kind of error occurs.
    41463775            if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
    41473776                        && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
    4148                 //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
    41493777
    41503778                PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
    41513779                                     "Newer version of '".$p_entry['filename']."' exists "
    41523780                                            ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
    41533781
    4154                 //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    41553782                return PclZip::errorCode();
    41563783                      }
    41573784                    }
    41583785      }
    41593786      else {
    4160         //--(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']).")");
    41613787      }
    41623788    }
    41633789
     
    41713797        $v_dir_to_check = dirname($p_entry['filename']);
    41723798
    41733799        if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
    4174           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'");
    41753800 
    41763801          // ----- Change the file status
    41773802          $p_entry['status'] = "path_creation_fail";
    41783803 
    41793804          // ----- Return
    4180           ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    41813805          //return $v_result;
    41823806          $v_result = 1;
    41833807        }
     
    41923816      {
    41933817        // ----- Look for not compressed file
    41943818        if ($p_entry['compression'] == 0) {
    4195           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
    41963819
    41973820                  // ----- Opening destination file
    41983821          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
    41993822          {
    4200             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
    42013823
    42023824            // ----- Change the file status
    42033825            $p_entry['status'] = "write_error";
    42043826
    42053827            // ----- Return
    4206             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    42073828            return $v_result;
    42083829          }
    42093830
    4210           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read '".$p_entry['size']."' bytes");
    42113831
    42123832          // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
    42133833          $v_size = $p_entry['compressed_size'];
    42143834          while ($v_size != 0)
    42153835          {
    42163836            $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
    4217             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");
    42183837            $v_buffer = @fread($this->zip_fd, $v_read_size);
    42193838            /* Try to speed up the code
    42203839            $v_binary_data = pack('a'.$v_read_size, $v_buffer);
     
    42333852
    42343853        }
    42353854        else {
    4236           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (Compression method ".$p_entry['compression'].")");
    42373855          // ----- TBC
    42383856          // Need to be finished
    42393857          if (($p_entry['flag'] & 1) == 1) {
    4240             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File is encrypted");
    42413858            PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
    4242             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    42433859            return PclZip::errorCode();
    42443860          }
    42453861
     
    42583874          // ----- Look for extract in memory
    42593875          else {
    42603876
    4261             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".$p_entry['compressed_size']."' compressed bytes");
    42623877         
    42633878            // ----- Read the compressed file in a buffer (one shot)
    42643879            $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
     
    42673882            $v_file_content = @gzinflate($v_buffer);
    42683883            unset($v_buffer);
    42693884            if ($v_file_content === FALSE) {
    4270               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to inflate compressed file");
    42713885 
    42723886              // ----- Change the file status
    42733887              // TBC
    42743888              $p_entry['status'] = "error";
    42753889             
    4276               //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    42773890              return $v_result;
    42783891            }
    42793892           
    42803893            // ----- Opening destination file
    42813894            if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
    4282               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
    42833895 
    42843896              // ----- Change the file status
    42853897              $p_entry['status'] = "write_error";
    42863898 
    4287               //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    42883899              return $v_result;
    42893900            }
    42903901 
     
    43033914
    43043915        // ----- Look for chmod option
    43053916        if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
    4306           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'");
    43073917
    43083918          // ----- Change the mode of the file
    43093919          @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
    43103920        }
    43113921
    4312         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
    43133922      }
    43143923    }
    43153924
     
    43203929       
    43213930    // ----- Look for post-extract callback
    43223931    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
    4323       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");
    43243932
    43253933      // ----- Generate a local information
    43263934      $v_local_header = array();
     
    43333941
    43343942      // ----- Look for abort result
    43353943      if ($v_result == 2) {
    4336         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
    43373944        $v_result = PCLZIP_ERR_USER_ABORTED;
    43383945      }
    43393946    }
    43403947
    43413948    // ----- Return
    4342     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    43433949    return $v_result;
    43443950  }
    43453951  // --------------------------------------------------------------------------------
     
    43523958  // --------------------------------------------------------------------------------
    43533959  function privExtractFileUsingTempFile(&$p_entry, &$p_options)
    43543960  {
    4355     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileUsingTempFile', "filename='".$p_entry['filename']."'");
    43563961    $v_result=1;
    43573962       
    43583963    // ----- Creates a temporary file
     
    43603965    if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
    43613966      fclose($v_file);
    43623967      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
    4363       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    43643968      return PclZip::errorCode();
    43653969    }
    43663970
    4367     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Start extraction of '".$p_entry['filename']."'");
    43683971
    43693972    // ----- Write gz file format header
    43703973    $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
     
    43723975
    43733976    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
    43743977    $v_size = $p_entry['compressed_size'];
    4375     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Compressed Size :".$v_size."");
    43763978    while ($v_size != 0)
    43773979    {
    43783980      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
    4379       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read ".$v_read_size." bytes");
    43803981      $v_buffer = @fread($this->zip_fd, $v_read_size);
    43813982      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
    43823983      @fwrite($v_dest_file, $v_buffer, $v_read_size);
     
    43923993
    43933994    // ----- Opening destination file
    43943995    if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
    4395       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
    43963996      $p_entry['status'] = "write_error";
    4397       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    43983997      return $v_result;
    43993998    }
    44003999
     
    44034002      @fclose($v_dest_file);
    44044003      $p_entry['status'] = "read_error";
    44054004      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
    4406       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    44074005      return PclZip::errorCode();
    44084006    }
    44094007
    4410     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File size is '.filesize($v_gzip_temp_name));
    4411     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
    44124008
    44134009    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
    44144010    $v_size = $p_entry['size'];
    4415     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size :".$v_size."");
    44164011    while ($v_size != 0) {
    44174012      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
    4418       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read ".$v_read_size." bytes");
    44194013      $v_buffer = @gzread($v_src_file, $v_read_size);
    44204014      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
    44214015      @fwrite($v_dest_file, $v_buffer, $v_read_size);
     
    44284022    @unlink($v_gzip_temp_name);
    44294023   
    44304024    // ----- Return
    4431     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    44324025    return $v_result;
    44334026  }
    44344027  // --------------------------------------------------------------------------------
     
    44414034  // --------------------------------------------------------------------------------
    44424035  function privExtractFileInOutput(&$p_entry, &$p_options)
    44434036  {
    4444     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileInOutput', "");
    44454037    $v_result=1;
    44464038
    44474039    // ----- Read the file header
    44484040    if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
    4449       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    44504041      return $v_result;
    44514042    }
    44524043
    4453     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
    44544044
    44554045    // ----- Check that the file header is coherent with $p_entry info
    44564046    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
     
    44594049
    44604050    // ----- Look for pre-extract callback
    44614051    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
    4462       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");
    44634052
    44644053      // ----- Generate a local information
    44654054      $v_local_header = array();
     
    44774066
    44784067      // ----- Look for abort result
    44794068      if ($v_result == 2) {
    4480         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
    44814069        // ----- This status is internal and will be changed in 'skipped'
    44824070        $p_entry['status'] = "aborted";
    44834071        $v_result = PCLZIP_ERR_USER_ABORTED;
     
    44864074      // ----- Update the informations
    44874075      // Only some fields can be modified
    44884076      $p_entry['filename'] = $v_local_header['filename'];
    4489       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");
    44904077    }
    44914078
    44924079    // ----- Trace
    4493     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");
    44944080
    44954081    // ----- Look if extraction should be done
    44964082    if ($p_entry['status'] == 'ok') {
     
    44994085      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
    45004086        // ----- Look for not compressed file
    45014087        if ($p_entry['compressed_size'] == $p_entry['size']) {
    4502           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
    4503           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
    45044088
    45054089          // ----- Read the file in a buffer (one shot)
    45064090          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
     
    45104094          unset($v_buffer);
    45114095        }
    45124096        else {
    4513           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");
    4514           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes");
    45154097
    45164098          // ----- Read the compressed file in a buffer (one shot)
    45174099          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
     
    45244106          echo $v_file_content;
    45254107          unset($v_file_content);
    45264108        }
    4527         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
    45284109      }
    45294110    }
    45304111
     
    45354116
    45364117    // ----- Look for post-extract callback
    45374118    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
    4538       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");
    45394119
    45404120      // ----- Generate a local information
    45414121      $v_local_header = array();
     
    45484128
    45494129      // ----- Look for abort result
    45504130      if ($v_result == 2) {
    4551         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
    45524131        $v_result = PCLZIP_ERR_USER_ABORTED;
    45534132      }
    45544133    }
    45554134
    4556     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    45574135    return $v_result;
    45584136  }
    45594137  // --------------------------------------------------------------------------------
     
    45664144  // --------------------------------------------------------------------------------
    45674145  function privExtractFileAsString(&$p_entry, &$p_string)
    45684146  {
    4569     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'");
    45704147    $v_result=1;
    45714148
    45724149    // ----- Read the file header
     
    45744151    if (($v_result = $this->privReadFileHeader($v_header)) != 1)
    45754152    {
    45764153      // ----- Return
    4577       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    45784154      return $v_result;
    45794155    }
    45804156
    4581     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
    45824157
    45834158    // ----- Check that the file header is coherent with $p_entry info
    45844159    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
    45854160        // TBC
    45864161    }
    45874162
    4588     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'");
    45894163
    45904164    // ----- Do the extraction (if not a folder)
    45914165    if (!(($p_entry['external']&0x00000010)==0x00000010))
     
    45934167      // ----- Look for not compressed file
    45944168//      if ($p_entry['compressed_size'] == $p_entry['size'])
    45954169      if ($p_entry['compression'] == 0) {
    4596         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
    4597         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
    45984170
    45994171        // ----- Reading the file
    46004172        $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
    46014173      }
    46024174      else {
    4603         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (compression method '".$p_entry['compression']."')");
    46044175
    46054176        // ----- Reading the file
    46064177        $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
     
    46124183      }
    46134184
    46144185      // ----- Trace
    4615       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
    46164186    }
    46174187    else {
    46184188        // TBC : error : can not extract a folder in a string
    46194189    }
    46204190
    46214191    // ----- Return
    4622     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    46234192    return $v_result;
    46244193  }
    46254194  // --------------------------------------------------------------------------------
     
    46324201  // --------------------------------------------------------------------------------
    46334202  function privReadFileHeader(&$p_header)
    46344203  {
    4635     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", "");
    46364204    $v_result=1;
    46374205
    46384206    // ----- Read the 4 bytes signature
    46394207    $v_binary_data = @fread($this->zip_fd, 4);
    4640     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
    46414208    $v_data = unpack('Vid', $v_binary_data);
    4642     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
    46434209
    46444210    // ----- Check signature
    46454211    if ($v_data['id'] != 0x04034b50)
    46464212    {
    4647       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header");
    46484213
    46494214      // ----- Error log
    46504215      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
    46514216
    46524217      // ----- Return
    4653       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    46544218      return PclZip::errorCode();
    46554219    }
    46564220
     
    46624226    {
    46634227      $p_header['filename'] = "";
    46644228      $p_header['status'] = "invalid_header";
    4665       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
    46664229
    46674230      // ----- Error log
    46684231      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
    46694232
    46704233      // ----- Return
    4671       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    46724234      return PclZip::errorCode();
    46734235    }
    46744236
    46754237    // ----- Extract the values
    4676     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'");
    4677     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'");
    46784238    $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
    46794239
    46804240    // ----- Get filename
    4681     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']);
    46824241    $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
    4683     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\'');
    46844242
    46854243    // ----- Get extra_fields
    4686     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']);
    46874244    if ($v_data['extra_len'] != 0) {
    46884245      $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
    46894246    }
    46904247    else {
    46914248      $p_header['extra'] = '';
    46924249    }
    4693     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\'');
    46944250
    46954251    // ----- Extract properties
    46964252    $p_header['version_extracted'] = $v_data['version'];
    4697     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : ('.$p_header['version_extracted'].') \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');
    46984253    $p_header['compression'] = $v_data['compression'];
    4699     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.$p_header['compression'].'\'');
    47004254    $p_header['size'] = $v_data['size'];
    4701     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\'');
    47024255    $p_header['compressed_size'] = $v_data['compressed_size'];
    4703     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
    47044256    $p_header['crc'] = $v_data['crc'];
    4705     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\'');
    47064257    $p_header['flag'] = $v_data['flag'];
    4707     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\'');
    4708     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag bit 11 (from right) : \''.($p_header['flag']&0x0400).'\'');
    4709     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag bit 11 (from left) : \''.($p_header['flag']&0x0020).'\'');
    47104258    $p_header['filename_len'] = $v_data['filename_len'];
    4711     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename_len : \''.$p_header['filename_len'].'\'');
    47124259
    47134260    // ----- Recuperate date in UNIX format
    47144261    $p_header['mdate'] = $v_data['mdate'];
     
    47284275      // ----- Get UNIX date format
    47294276      $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
    47304277
    4731       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
    47324278    }
    47334279    else
    47344280    {
    47354281      $p_header['mtime'] = time();
    4736       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
    47374282    }
    47384283
    47394284    // TBC
    47404285    //for(reset($v_data); $key = key($v_data); next($v_data)) {
    4741     //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]);
    47424286    //}
    47434287
    47444288    // ----- Set the stored filename
     
    47484292    $p_header['status'] = "ok";
    47494293
    47504294    // ----- Return
    4751     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    47524295    return $v_result;
    47534296  }
    47544297  // --------------------------------------------------------------------------------
     
    47614304  // --------------------------------------------------------------------------------
    47624305  function privReadCentralFileHeader(&$p_header)
    47634306  {
    4764     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", "");
    47654307    $v_result=1;
    47664308
    47674309    // ----- Read the 4 bytes signature
    47684310    $v_binary_data = @fread($this->zip_fd, 4);
    4769     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
    47704311    $v_data = unpack('Vid', $v_binary_data);
    4771     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
    47724312
    47734313    // ----- Check signature
    47744314    if ($v_data['id'] != 0x02014b50)
    47754315    {
    4776       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature");
    47774316
    47784317      // ----- Error log
    47794318      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
    47804319
    47814320      // ----- Return
    4782       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    47834321      return PclZip::errorCode();
    47844322    }
    47854323
     
    47914329    {
    47924330      $p_header['filename'] = "";
    47934331      $p_header['status'] = "invalid_header";
    4794       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
    47954332
    47964333      // ----- Error log
    47974334      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
    47984335
    47994336      // ----- Return
    4800       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    48014337      return PclZip::errorCode();
    48024338    }
    48034339
    48044340    // ----- Extract the values
    4805     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'");
    4806     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'");
    48074341    $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);
    48084342
    48094343    // ----- Get filename
    4810     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']);
    48114344    if ($p_header['filename_len'] != 0)
    48124345      $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
    48134346    else
    48144347      $p_header['filename'] = '';
    4815     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\'');
    48164348
    48174349    // ----- Get extra
    4818     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']);
    48194350    if ($p_header['extra_len'] != 0)
    48204351      $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
    48214352    else
    48224353      $p_header['extra'] = '';
    4823     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\'');
    48244354
    48254355    // ----- Get comment
    4826     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']);
    48274356    if ($p_header['comment_len'] != 0)
    48284357      $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
    48294358    else
    48304359      $p_header['comment'] = '';
    4831     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\'');
    48324360
    48334361    // ----- Extract properties
    4834     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\'');
    4835     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');
    4836     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\'');
    4837     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
    4838     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\'');
    4839     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\'');
    4840     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\'');
    48414362
    48424363    // ----- Recuperate date in UNIX format
    48434364    //if ($p_header['mdate'] && $p_header['mtime'])
     
    48574378      // ----- Get UNIX date format
    48584379      $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
    48594380
    4860       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
    48614381    }
    48624382    else
    48634383    {
    48644384      $p_header['mtime'] = time();
    4865       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
    48664385    }
    48674386
    48684387    // ----- Set the stored filename
     
    48724391    $p_header['status'] = 'ok';
    48734392
    48744393    // ----- Look if it is a directory
    4875     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'");
    4876     //--(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').')');
    48774394    if (substr($p_header['filename'], -1) == '/') {
    48784395      //$p_header['external'] = 0x41FF0010;
    48794396      $p_header['external'] = 0x00000010;
    4880       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.sprintf("Ox%04X", $p_header['external']).'\'');
    48814397    }
    48824398
    4883     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\'');
    48844399
    48854400    // ----- Return
    4886     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    48874401    return $v_result;
    48884402  }
    48894403  // --------------------------------------------------------------------------------
     
    48984412  // --------------------------------------------------------------------------------
    48994413  function privCheckFileHeaders(&$p_local_header, &$p_central_header)
    49004414  {
    4901     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFileHeaders", "");
    49024415    $v_result=1;
    49034416
    49044417        // ----- Check the static values
    49054418        // TBC
    49064419        if ($p_local_header['filename'] != $p_central_header['filename']) {
    4907           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename" : TBC To Be Completed');
    49084420        }
    49094421        if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
    4910           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "version_extracted" : TBC To Be Completed');
    49114422        }
    49124423        if ($p_local_header['flag'] != $p_central_header['flag']) {
    4913           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "flag" : TBC To Be Completed');
    49144424        }
    49154425        if ($p_local_header['compression'] != $p_central_header['compression']) {
    4916           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "compression" : TBC To Be Completed');
    49174426        }
    49184427        if ($p_local_header['mtime'] != $p_central_header['mtime']) {
    4919           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "mtime" : TBC To Be Completed');
    49204428        }
    49214429        if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
    4922           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename_len" : TBC To Be Completed');
    49234430        }
    49244431 
    49254432        // ----- Look for flag bit 3
    49264433        if (($p_local_header['flag'] & 8) == 8) {
    4927           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Purpose bit flag bit 3 set !');
    4928           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'File size, compression size and crc found in central header');
    49294434          $p_local_header['size'] = $p_central_header['size'];
    4930           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_local_header['size'].'\'');
    49314435          $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
    4932           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_local_header['compressed_size'].'\'');
    49334436          $p_local_header['crc'] = $p_central_header['crc'];
    4934           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_local_header['crc']).'\'');
    49354437        }
    49364438
    49374439    // ----- Return
    4938     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    49394440    return $v_result;
    49404441  }
    49414442  // --------------------------------------------------------------------------------
     
    49484449  // --------------------------------------------------------------------------------
    49494450  function privReadEndCentralDir(&$p_central_dir)
    49504451  {
    4951     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", "");
    49524452    $v_result=1;
    49534453
    49544454    // ----- Go to the end of the zip file
    49554455    $v_size = filesize($this->zipname);
    4956     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size");
    49574456    @fseek($this->zip_fd, $v_size);
    4958     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\'');
    49594457    if (@ftell($this->zip_fd) != $v_size)
    49604458    {
    49614459      // ----- Error log
    49624460      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
    49634461
    49644462      // ----- Return
    4965       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    49664463      return PclZip::errorCode();
    49674464    }
    49684465
     
    49704467    // in this case the end of central dir is at 22 bytes of the file end
    49714468    $v_found = 0;
    49724469    if ($v_size > 26) {
    4973       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment');
    49744470      @fseek($this->zip_fd, $v_size-22);
    4975       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\'');
    49764471      if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
    49774472      {
    49784473        // ----- Error log
    49794474        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
    49804475
    49814476        // ----- Return
    4982         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    49834477        return PclZip::errorCode();
    49844478      }
    49854479
    49864480      // ----- Read for bytes
    49874481      $v_binary_data = @fread($this->zip_fd, 4);
    4988       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
    49894482      $v_data = @unpack('Vid', $v_binary_data);
    4990       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
    49914483
    49924484      // ----- Check signature
    49934485      if ($v_data['id'] == 0x06054b50) {
    4994         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position.");
    49954486        $v_found = 1;
    49964487      }
    49974488
     
    50004491
    50014492    // ----- Go back to the maximum possible size of the Central Dir End Record
    50024493    if (!$v_found) {
    5003       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir');
    50044494      $v_maximum_size = 65557; // 0xFFFF + 22;
    50054495      if ($v_maximum_size > $v_size)
    50064496        $v_maximum_size = $v_size;
     
    50114501        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
    50124502
    50134503        // ----- Return
    5014         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    50154504        return PclZip::errorCode();
    50164505      }
    5017       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');
    50184506
    50194507      // ----- Read byte per byte in order to find the signature
    50204508      $v_pos = ftell($this->zip_fd);
     
    50334521        // ----- Compare the bytes
    50344522        if ($v_bytes == 0x504b0506)
    50354523        {
    5036           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\'');
    50374524          $v_pos++;
    50384525          break;
    50394526        }
     
    50444531      // ----- Look if not found end of central dir
    50454532      if ($v_pos == $v_size)
    50464533      {
    5047         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature");
    50484534
    50494535        // ----- Error log
    50504536        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
    50514537
    50524538        // ----- Return
    5053         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    50544539        return PclZip::errorCode();
    50554540      }
    50564541    }
     
    50614546    // ----- Look for invalid block size
    50624547    if (strlen($v_binary_data) != 18)
    50634548    {
    5064       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
    50654549
    50664550      // ----- Error log
    50674551      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
    50684552
    50694553      // ----- Return
    5070       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    50714554      return PclZip::errorCode();
    50724555    }
    50734556
    50744557    // ----- Extract the values
    5075     ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'");
    5076     ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'");
    50774558    $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
    50784559
    50794560    // ----- Check the global size
    5080     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']);
    50814561    if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
    5082       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The central dir is not at the end of the archive. Some trailing bytes exists after the archive.");
    50834562
    50844563          // ----- Removed in release 2.2 see readme file
    50854564          // The check of the file size is a little too strict.
     
    50924571                                                   .' Some trailing bytes exists after the archive.');
    50934572
    50944573      // ----- Return
    5095       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    50964574      return PclZip::errorCode();
    50974575          }
    50984576    }
    50994577
    51004578    // ----- Get comment
    5101     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment size : \''.$v_data['comment_size'].'\'');
    51024579    if ($v_data['comment_size'] != 0) {
    51034580      $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
    51044581    }
    51054582    else
    51064583      $p_central_dir['comment'] = '';
    5107     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\'');
    51084584
    51094585    $p_central_dir['entries'] = $v_data['entries'];
    5110     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\'');
    51114586    $p_central_dir['disk_entries'] = $v_data['disk_entries'];
    5112     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\'');
    51134587    $p_central_dir['offset'] = $v_data['offset'];
    5114     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\'');
    51154588    $p_central_dir['size'] = $v_data['size'];
    5116     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\'');
    51174589    $p_central_dir['disk'] = $v_data['disk'];
    5118     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\'');
    51194590    $p_central_dir['disk_start'] = $v_data['disk_start'];
    5120     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\'');
    51214591
    51224592    // TBC
    51234593    //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
    5124     //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]);
    51254594    //}
    51264595
    51274596    // ----- Return
    5128     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    51294597    return $v_result;
    51304598  }
    51314599  // --------------------------------------------------------------------------------
     
    51384606  // --------------------------------------------------------------------------------
    51394607  function privDeleteByRule(&$p_result_list, &$p_options)
    51404608  {
    5141     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", "");
    51424609    $v_result=1;
    51434610    $v_list_detail = array();
    51444611
    51454612    // ----- Open the zip file
    5146     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
    51474613    if (($v_result=$this->privOpenFd('rb')) != 1)
    51484614    {
    51494615      // ----- Return
    5150       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    51514616      return $v_result;
    51524617    }
    51534618
     
    51564621    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
    51574622    {
    51584623      $this->privCloseFd();
    5159       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    51604624      return $v_result;
    51614625    }
    51624626
    51634627    // ----- Go to beginning of File
    5164     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
    51654628    @rewind($this->zip_fd);
    5166     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
    51674629
    51684630    // ----- Scan all the files
    51694631    // ----- Start at beginning of Central Dir
    51704632    $v_pos_entry = $v_central_dir['offset'];
    5171     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
    51724633    @rewind($this->zip_fd);
    5173     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
    51744634    if (@fseek($this->zip_fd, $v_pos_entry))
    51754635    {
    51764636      // ----- Close the zip file
     
    51804640      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
    51814641
    51824642      // ----- Return
    5183       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    51844643      return PclZip::errorCode();
    51854644    }
    5186     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
    51874645
    51884646    // ----- Read each entry
    51894647    $v_header_list = array();
    51904648    $j_start = 0;
    51914649    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
    51924650    {
    5193       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$i')");
    51944651
    51954652      // ----- Read the file header
    51964653      $v_header_list[$v_nb_extracted] = array();
     
    51994656        // ----- Close the zip file
    52004657        $this->privCloseFd();
    52014658
    5202         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    52034659        return $v_result;
    52044660      }
    52054661
    5206       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'");
    52074662
    52084663      // ----- Store the index
    52094664      $v_header_list[$v_nb_extracted]['index'] = $i;
     
    52144669      // ----- Look for extract by name rule
    52154670      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
    52164671          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
    5217           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
    52184672
    52194673          // ----- Look if the filename is in the list
    52204674          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
    5221               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
    52224675
    52234676              // ----- Look for a directory
    52244677              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
    5225                   //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
    52264678
    52274679                  // ----- Look if the directory is in the filename path
    52284680                  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
    52294681                      && (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])) {
    5230                       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
    52314682                      $v_found = true;
    52324683                  }
    52334684                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
    52344685                          && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
    5235                       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory");
    52364686                      $v_found = true;
    52374687                  }
    52384688              }
    52394689              // ----- Look for a filename
    52404690              elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
    5241                   //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
    52424691                  $v_found = true;
    52434692              }
    52444693          }
    52454694      }
    52464695
    52474696      // ----- Look for extract by ereg rule
     4697      // ereg() is deprecated with PHP 5.3
     4698      /*
    52484699      else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
    52494700               && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
    5250           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
    52514701
    52524702          if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
    5253               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
    52544703              $v_found = true;
    52554704          }
    52564705      }
     4706      */
    52574707
    52584708      // ----- Look for extract by preg rule
    52594709      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
    52604710               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
    5261           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
    52624711
    52634712          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
    5264               //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
    52654713              $v_found = true;
    52664714          }
    52674715      }
     
    52694717      // ----- Look for extract by index rule
    52704718      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
    52714719               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
    5272           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
    52734720
    52744721          // ----- Look if the index is in the list
    52754722          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
    5276               //--(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']."]");
    52774723
    52784724              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
    5279                   //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
    52804725                  $v_found = true;
    52814726              }
    52824727              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
    5283                   //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
    52844728                  $j_start = $j+1;
    52854729              }
    52864730
    52874731              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
    5288                   //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
    52894732                  break;
    52904733              }
    52914734          }
    52924735      }
    52934736      else {
    5294         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "No argument mean remove all file");
    52954737        $v_found = true;
    52964738      }
    52974739
    52984740      // ----- Look for deletion
    52994741      if ($v_found)
    53004742      {
    5301         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted");
    53024743        unset($v_header_list[$v_nb_extracted]);
    53034744      }
    53044745      else
    53054746      {
    5306         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted");
    53074747        $v_nb_extracted++;
    53084748      }
    53094749    }
     
    53184758        $v_temp_zip = new PclZip($v_zip_temp_name);
    53194759
    53204760        // ----- Open the temporary zip file in write mode
    5321         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode");
    53224761        if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
    53234762            $this->privCloseFd();
    53244763
    53254764            // ----- Return
    5326             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    53274765            return $v_result;
    53284766        }
    53294767
    53304768        // ----- Look which file need to be kept
    53314769        for ($i=0; $i<sizeof($v_header_list); $i++) {
    5332             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Keep entry index '$i' : '".$v_header_list[$i]['filename']."'");
    53334770
    53344771            // ----- Calculate the position of the header
    5335             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset='". $v_header_list[$i]['offset']."'");
    5336             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
    53374772            @rewind($this->zip_fd);
    5338             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
    53394773            if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {
    53404774                // ----- Close the zip file
    53414775                $this->privCloseFd();
     
    53464780                PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
    53474781
    53484782                // ----- Return
    5349                 //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    53504783                return PclZip::errorCode();
    53514784            }
    5352             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
    53534785
    53544786            // ----- Read the file header
    53554787            $v_local_header = array();
     
    53604792                @unlink($v_zip_temp_name);
    53614793
    53624794                // ----- Return
    5363                 //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    53644795                return $v_result;
    53654796            }
    53664797           
     
    53794810                @unlink($v_zip_temp_name);
    53804811
    53814812                // ----- Return
    5382                 //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    53834813                return $v_result;
    53844814            }
    5385             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'");
    53864815
    53874816            // ----- Read/write the data block
    53884817            if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
     
    53924821                @unlink($v_zip_temp_name);
    53934822
    53944823                // ----- Return
    5395                 //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    53964824                return $v_result;
    53974825            }
    53984826        }
    53994827
    54004828        // ----- Store the offset of the central dir
    54014829        $v_offset = @ftell($v_temp_zip->zip_fd);
    5402         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset");
    54034830
    54044831        // ----- Re-Create the Central Dir files header
    5405         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory");
    54064832        for ($i=0; $i<sizeof($v_header_list); $i++) {
    54074833            // ----- Create the file header
    5408             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset of file : ".$v_header_list[$i]['offset']);
    54094834            if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
    54104835                $v_temp_zip->privCloseFd();
    54114836                $this->privCloseFd();
    54124837                @unlink($v_zip_temp_name);
    54134838
    54144839                // ----- Return
    5415                 //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    54164840                return $v_result;
    54174841            }
    54184842
     
    54204844            $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
    54214845        }
    54224846
    5423         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer");
    54244847
    54254848        // ----- Zip file comment
    54264849        $v_comment = '';
     
    54404863            @unlink($v_zip_temp_name);
    54414864
    54424865            // ----- Return
    5443             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    54444866            return $v_result;
    54454867        }
    54464868
     
    54664888        $this->privCloseFd();
    54674889
    54684890        if (($v_result = $this->privOpenFd('wb')) != 1) {
    5469           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    54704891          return $v_result;
    54714892        }
    54724893
    54734894        if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
    5474           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    54754895          return $v_result;
    54764896        }
    54774897
     
    54794899    }
    54804900
    54814901    // ----- Return
    5482     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    54834902    return $v_result;
    54844903  }
    54854904  // --------------------------------------------------------------------------------
     
    54994918  {
    55004919    $v_result = 1;
    55014920
    5502     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'");
    55034921
    55044922    // ----- Remove the final '/'
    55054923    if (($p_is_dir) && (substr($p_dir, -1)=='/'))
    55064924    {
    55074925      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
    55084926    }
    5509     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'");
    55104927
    55114928    // ----- Check the directory availability
    55124929    if ((is_dir($p_dir)) || ($p_dir == ""))
    55134930    {
    5514       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory");
    55154931      return 1;
    55164932    }
    55174933
    55184934    // ----- Extract parent directory
    55194935    $p_parent_dir = dirname($p_dir);
    5520     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'");
    55214936
    55224937    // ----- Just a check
    55234938    if ($p_parent_dir != $p_dir)
     
    55274942      {
    55284943        if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
    55294944        {
    5530           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    55314945          return $v_result;
    55324946        }
    55334947      }
    55344948    }
    55354949
    55364950    // ----- Create the directory
    5537     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'");
    55384951    if (!@mkdir($p_dir, 0777))
    55394952    {
    55404953      // ----- Error log
    55414954      PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
    55424955
    55434956      // ----- Return
    5544       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    55454957      return PclZip::errorCode();
    55464958    }
    55474959
    55484960    // ----- Return
    5549     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created");
    55504961    return $v_result;
    55514962  }
    55524963  // --------------------------------------------------------------------------------
     
    55604971  // --------------------------------------------------------------------------------
    55614972  function privMerge(&$p_archive_to_add)
    55624973  {
    5563     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'");
    55644974    $v_result=1;
    55654975
    55664976    // ----- Look if the archive_to_add exists
    55674977    if (!is_file($p_archive_to_add->zipname))
    55684978    {
    5569       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge.");
    55704979
    55714980      // ----- Nothing to merge, so merge is a success
    55724981      $v_result = 1;
    55734982
    55744983      // ----- Return
    5575       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    55764984      return $v_result;
    55774985    }
    55784986
    55794987    // ----- Look if the archive exists
    55804988    if (!is_file($this->zipname))
    55814989    {
    5582       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add.");
    55834990
    55844991      // ----- Do a duplicate
    55854992      $v_result = $this->privDuplicate($p_archive_to_add->zipname);
    55864993
    55874994      // ----- Return
    5588       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    55894995      return $v_result;
    55904996    }
    55914997
    55924998    // ----- Open the zip file
    5593     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
    55944999    if (($v_result=$this->privOpenFd('rb')) != 1)
    55955000    {
    55965001      // ----- Return
    5597       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    55985002      return $v_result;
    55995003    }
    56005004
     
    56035007    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
    56045008    {
    56055009      $this->privCloseFd();
    5606       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    56075010      return $v_result;
    56085011    }
    56095012
    56105013    // ----- Go to beginning of File
    5611     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
    56125014    @rewind($this->zip_fd);
    5613     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
    56145015
    56155016    // ----- Open the archive_to_add file
    5616     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode");
    56175017    if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
    56185018    {
    56195019      $this->privCloseFd();
    56205020
    56215021      // ----- Return
    5622       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    56235022      return $v_result;
    56245023    }
    56255024
     
    56305029      $this->privCloseFd();
    56315030      $p_archive_to_add->privCloseFd();
    56325031
    5633       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    56345032      return $v_result;
    56355033    }
    56365034
    56375035    // ----- Go to beginning of File
    5638     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");
    56395036    @rewind($p_archive_to_add->zip_fd);
    5640     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");
    56415037
    56425038    // ----- Creates a temporay file
    56435039    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
    56445040
    56455041    // ----- Open the temporary file in write mode
    5646     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
    56475042    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
    56485043    {
    56495044      $this->privCloseFd();
     
    56525047      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
    56535048
    56545049      // ----- Return
    5655       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    56565050      return PclZip::errorCode();
    56575051    }
    56585052
     
    56625056    while ($v_size != 0)
    56635057    {
    56645058      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
    5665       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
    56665059      $v_buffer = fread($this->zip_fd, $v_read_size);
    56675060      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
    56685061      $v_size -= $v_read_size;
     
    56735066    while ($v_size != 0)
    56745067    {
    56755068      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
    5676       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
    56775069      $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
    56785070      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
    56795071      $v_size -= $v_read_size;
     
    56815073
    56825074    // ----- Store the offset of the central dir
    56835075    $v_offset = @ftell($v_zip_temp_fd);
    5684     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
    56855076
    56865077    // ----- Copy the block of file headers from the old archive
    56875078    $v_size = $v_central_dir['size'];
    56885079    while ($v_size != 0)
    56895080    {
    56905081      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
    5691       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
    56925082      $v_buffer = @fread($this->zip_fd, $v_read_size);
    56935083      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
    56945084      $v_size -= $v_read_size;
     
    56995089    while ($v_size != 0)
    57005090    {
    57015091      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
    5702       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
    57035092      $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
    57045093      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
    57055094      $v_size -= $v_read_size;
     
    57305119      unset($v_header_list);
    57315120
    57325121      // ----- Return
    5733       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    57345122      return $v_result;
    57355123    }
    57365124
     
    57565144    PclZipUtilRename($v_zip_temp_name, $this->zipname);
    57575145
    57585146    // ----- Return
    5759     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    57605147    return $v_result;
    57615148  }
    57625149  // --------------------------------------------------------------------------------
     
    57695156  // --------------------------------------------------------------------------------
    57705157  function privDuplicate($p_archive_filename)
    57715158  {
    5772     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'");
    57735159    $v_result=1;
    57745160
    57755161    // ----- Look if the $p_archive_filename exists
    57765162    if (!is_file($p_archive_filename))
    57775163    {
    5778       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate.");
    57795164
    57805165      // ----- Nothing to duplicate, so duplicate is a success.
    57815166      $v_result = 1;
    57825167
    57835168      // ----- Return
    5784       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    57855169      return $v_result;
    57865170    }
    57875171
    57885172    // ----- Open the zip file
    5789     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
    57905173    if (($v_result=$this->privOpenFd('wb')) != 1)
    57915174    {
    57925175      // ----- Return
    5793       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    57945176      return $v_result;
    57955177    }
    57965178
    57975179    // ----- Open the temporary file in write mode
    5798     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
    57995180    if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
    58005181    {
    58015182      $this->privCloseFd();
     
    58035184      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
    58045185
    58055186      // ----- Return
    5806       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    58075187      return PclZip::errorCode();
    58085188    }
    58095189
     
    58135193    while ($v_size != 0)
    58145194    {
    58155195      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
    5816       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes");
    58175196      $v_buffer = fread($v_zip_temp_fd, $v_read_size);
    58185197      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
    58195198      $v_size -= $v_read_size;
     
    58265205    @fclose($v_zip_temp_fd);
    58275206
    58285207    // ----- Return
    5829     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    58305208    return $v_result;
    58315209  }
    58325210  // --------------------------------------------------------------------------------
     
    58735251  // --------------------------------------------------------------------------------
    58745252  function privDisableMagicQuotes()
    58755253  {
    5876     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDisableMagicQuotes', "");
    58775254    $v_result=1;
    58785255
    58795256    // ----- Look if function exists
    58805257    if (   (!function_exists("get_magic_quotes_runtime"))
    58815258            || (!function_exists("set_magic_quotes_runtime"))) {
    5882       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported");
    5883       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    58845259      return $v_result;
    58855260        }
    58865261
    58875262    // ----- Look if already done
    58885263    if ($this->magic_quotes_status != -1) {
    5889       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote already disabled");
    5890       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    58915264      return $v_result;
    58925265        }
    58935266
    58945267        // ----- Get and memorize the magic_quote value
    58955268        $this->magic_quotes_status = @get_magic_quotes_runtime();
    5896     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Current magic_quotes_runtime status is '".($this->magic_quotes_status==0?'disable':'enable')."'");
    58975269
    58985270        // ----- Disable magic_quotes
    58995271        if ($this->magic_quotes_status == 1) {
    5900       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Disable magic_quotes");
    59015272          @set_magic_quotes_runtime(0);
    59025273        }
    59035274
    59045275    // ----- Return
    5905     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    59065276    return $v_result;
    59075277  }
    59085278  // --------------------------------------------------------------------------------
     
    59155285  // --------------------------------------------------------------------------------
    59165286  function privSwapBackMagicQuotes()
    59175287  {
    5918     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privSwapBackMagicQuotes', "");
    59195288    $v_result=1;
    59205289
    59215290    // ----- Look if function exists
    59225291    if (   (!function_exists("get_magic_quotes_runtime"))
    59235292            || (!function_exists("set_magic_quotes_runtime"))) {
    5924       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported");
    5925       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    59265293      return $v_result;
    59275294        }
    59285295
    59295296    // ----- Look if something to do
    59305297    if ($this->magic_quotes_status != -1) {
    5931       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote not modified");
    5932       //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    59335298      return $v_result;
    59345299        }
    59355300
    59365301        // ----- Swap back magic_quotes
    59375302        if ($this->magic_quotes_status == 1) {
    5938       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Enable back magic_quotes");
    59395303          @set_magic_quotes_runtime($this->magic_quotes_status);
    59405304        }
    59415305
    59425306    // ----- Return
    5943     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    59445307    return $v_result;
    59455308  }
    59465309  // --------------------------------------------------------------------------------
     
    59575320  // --------------------------------------------------------------------------------
    59585321  function PclZipUtilPathReduction($p_dir)
    59595322  {
    5960     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'");
    59615323    $v_result = "";
    59625324
    59635325    // ----- Look for not empty path
     
    59845346                        // ----- It is an invalid path, so the path is not modified
    59855347                        // TBC
    59865348                        $v_result = $p_dir;
    5987                 //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid path is unchanged");
    59885349                $v_skip = 0;
    59895350                    }
    59905351                  }
     
    60195380    }
    60205381
    60215382    // ----- Return
    6022     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    60235383    return $v_result;
    60245384  }
    60255385  // --------------------------------------------------------------------------------
     
    60415401  // --------------------------------------------------------------------------------
    60425402  function PclZipUtilPathInclusion($p_dir, $p_path)
    60435403  {
    6044     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'");
    60455404    $v_result = 1;
    60465405   
    60475406    // ----- Look for path beginning by ./
    60485407    if (   ($p_dir == '.')
    60495408        || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
    60505409      $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
    6051       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_dir '".$p_dir."'");
    60525410    }
    60535411    if (   ($p_path == '.')
    60545412        || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
    60555413      $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
    6056       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_path '".$p_path."'");
    60575414    }
    60585415
    60595416    // ----- Explode dir and path by directory separator
     
    60665423    $i = 0;
    60675424    $j = 0;
    60685425    while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
    6069       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'");
    60705426
    60715427      // ----- Look for empty dir (path reduction)
    60725428      if ($v_list_dir[$i] == '') {
     
    60805436
    60815437      // ----- Compare the items
    60825438      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
    6083         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different");
    60845439        $v_result = 0;
    60855440      }
    60865441
     
    60915446
    60925447    // ----- Look if everything seems to be the same
    60935448    if ($v_result) {
    6094       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break");
    60955449      // ----- Skip all the empty items
    60965450      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
    60975451      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
    6098       //--(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]:'')."'");
    60995452
    61005453      if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
    61015454        // ----- There are exactly the same
     
    61085461    }
    61095462
    61105463    // ----- Return
    6111     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    61125464    return $v_result;
    61135465  }
    61145466  // --------------------------------------------------------------------------------
     
    61265478  // --------------------------------------------------------------------------------
    61275479  function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
    61285480  {
    6129     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode");
    61305481    $v_result = 1;
    61315482
    61325483    if ($p_mode==0)
    61335484    {
    6134       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src)));
    6135       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest)));
    61365485      while ($p_size != 0)
    61375486      {
    61385487        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
    6139         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
    61405488        $v_buffer = @fread($p_src, $v_read_size);
    61415489        @fwrite($p_dest, $v_buffer, $v_read_size);
    61425490        $p_size -= $v_read_size;
    61435491      }
    6144       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src)));
    6145       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest)));
    61465492    }
    61475493    else if ($p_mode==1)
    61485494    {
    61495495      while ($p_size != 0)
    61505496      {
    61515497        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
    6152         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
    61535498        $v_buffer = @gzread($p_src, $v_read_size);
    61545499        @fwrite($p_dest, $v_buffer, $v_read_size);
    61555500        $p_size -= $v_read_size;
     
    61605505      while ($p_size != 0)
    61615506      {
    61625507        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
    6163         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
    61645508        $v_buffer = @fread($p_src, $v_read_size);
    61655509        @gzwrite($p_dest, $v_buffer, $v_read_size);
    61665510        $p_size -= $v_read_size;
     
    61715515      while ($p_size != 0)
    61725516      {
    61735517        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
    6174         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
    61755518        $v_buffer = @gzread($p_src, $v_read_size);
    61765519        @gzwrite($p_dest, $v_buffer, $v_read_size);
    61775520        $p_size -= $v_read_size;
     
    61795522    }
    61805523
    61815524    // ----- Return
    6182     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    61835525    return $v_result;
    61845526  }
    61855527  // --------------------------------------------------------------------------------
     
    61985540  // --------------------------------------------------------------------------------
    61995541  function PclZipUtilRename($p_src, $p_dest)
    62005542  {
    6201     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest");
    62025543    $v_result = 1;
    62035544
    62045545    // ----- Try to rename the files
    62055546    if (!@rename($p_src, $p_dest)) {
    6206       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink");
    62075547
    62085548      // ----- Try to copy & unlink the src
    62095549      if (!@copy($p_src, $p_dest)) {
    6210         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file");
    62115550        $v_result = 0;
    62125551      }
    62135552      else if (!@unlink($p_src)) {
    6214         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename");
    62155553        $v_result = 0;
    62165554      }
    62175555    }
    62185556
    62195557    // ----- Return
    6220     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    62215558    return $v_result;
    62225559  }
    62235560  // --------------------------------------------------------------------------------
     
    62335570  // --------------------------------------------------------------------------------
    62345571  function PclZipUtilOptionText($p_option)
    62355572  {
    6236     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'");
    62375573   
    62385574    $v_list = get_defined_constants();
    62395575    for (reset($v_list); $v_key = key($v_list); next($v_list)) {
     
    62425578           || ($v_prefix == 'PCLZIP_CB_')
    62435579           || ($v_prefix == 'PCLZIP_ATT'))
    62445580                && ($v_list[$v_key] == $p_option)) {
    6245         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key);
    62465581        return $v_key;
    62475582            }
    62485583    }
    62495584   
    62505585    $v_result = 'Unknown';
    62515586
    6252     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    62535587    return $v_result;
    62545588  }
    62555589  // --------------------------------------------------------------------------------
     
    62825616  // --------------------------------------------------------------------------------
    62835617
    62845618
    6285 ?>
     5619?>
     5620 No newline at end of file