Ignore:
Timestamp:
2014/08/22 18:31:39 (10 years ago)
Author:
kimoto
Message:

#2609 モジュールのバグfix

XML_Util 1.2.3
Mobile_Detect 2.8.3
Cache_Lite 1.7.16
Archive_Tar 1.3.12

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/module/Archive/Tar.php

    r22964 r23600  
    4545define('ARCHIVE_TAR_END_BLOCK', pack("a512", '')); 
    4646 
     47if (!function_exists('gzopen') && function_exists('gzopen64')) { 
     48    function gzopen($filename, $mode, $use_include_path = 0) 
     49    { 
     50        gzopen64($filename, $mode, $use_include_path); 
     51    } 
     52} 
     53 
     54if (!function_exists('gztell') && function_exists('gztell64')) { 
     55    function gztell($zp) 
     56    { 
     57        gztell64($zp); 
     58    } 
     59} 
     60 
     61if (!function_exists('gzseek') && function_exists('gzseek64')) { 
     62    function gzseek($zp, $offset, $whence = SEEK_SET) 
     63    { 
     64        gzseek64($zp, $offset, $whence); 
     65    } 
     66} 
     67 
    4768/** 
    48 * Creates a (compressed) Tar archive 
    49 * 
    50 * @package Archive_Tar 
    51 * @author  Vincent Blavet <vincent@phpconcept.net> 
    52 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License 
    53 * @version $Revision$ 
    54 */ 
     69 * Creates a (compressed) Tar archive 
     70 * 
     71 * @package Archive_Tar 
     72 * @author  Vincent Blavet <vincent@phpconcept.net> 
     73 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License 
     74 * @version $Revision$ 
     75 */ 
    5576class Archive_Tar extends PEAR 
    5677{ 
    5778    /** 
    58     * @var string Name of the Tar 
    59     */ 
    60     var $_tarname=''; 
     79     * @var string Name of the Tar 
     80     */ 
     81    var $_tarname = ''; 
    6182 
    6283    /** 
    63     * @var boolean if true, the Tar file will be gzipped 
    64     */ 
    65     var $_compress=false; 
     84     * @var boolean if true, the Tar file will be gzipped 
     85     */ 
     86    var $_compress = false; 
    6687 
    6788    /** 
    68     * @var string Type of compression : 'none', 'gz' or 'bz2' 
    69     */ 
    70     var $_compress_type='none'; 
     89     * @var string Type of compression : 'none', 'gz', 'bz2' or 'lzma2' 
     90     */ 
     91    var $_compress_type = 'none'; 
    7192 
    7293    /** 
    73     * @var string Explode separator 
    74     */ 
    75     var $_separator=' '; 
     94     * @var string Explode separator 
     95     */ 
     96    var $_separator = ' '; 
    7697 
    7798    /** 
    78     * @var file descriptor 
    79     */ 
    80     var $_file=0; 
     99     * @var file descriptor 
     100     */ 
     101    var $_file = 0; 
    81102 
    82103    /** 
    83     * @var string Local Tar name of a remote Tar (http:// or ftp://) 
    84     */ 
    85     var $_temp_tarname=''; 
     104     * @var string Local Tar name of a remote Tar (http:// or ftp://) 
     105     */ 
     106    var $_temp_tarname = ''; 
    86107 
    87108    /** 
    88     * @var string regular expression for ignoring files or directories 
    89     */ 
    90     var $_ignore_regexp=''; 
     109     * @var string regular expression for ignoring files or directories 
     110     */ 
     111    var $_ignore_regexp = ''; 
    91112 
    92113    /** 
    93114     * @var object PEAR_Error object 
    94115     */ 
    95     var $error_object=null;  
     116    var $error_object = null; 
    96117 
    97118    // {{{ constructor 
    98119    /** 
    99     * Archive_Tar Class constructor. This flavour of the constructor only 
    100     * declare a new Archive_Tar object, identifying it by the name of the 
    101     * tar file. 
    102     * If the compress argument is set the tar will be read or created as a 
    103     * gzip or bz2 compressed TAR file. 
    104     * 
    105     * @param string $p_tarname The name of the tar archive to create 
    106     * @param string $p_compress can be null, 'gz' or 'bz2'. This 
    107     *               parameter indicates if gzip or bz2 compression 
    108     *               is required.  For compatibility reason the 
    109     *               boolean value 'true' means 'gz'. 
    110     * 
    111     * @access public 
    112     */ 
     120     * Archive_Tar Class constructor. This flavour of the constructor only 
     121     * declare a new Archive_Tar object, identifying it by the name of the 
     122     * tar file. 
     123     * If the compress argument is set the tar will be read or created as a 
     124     * gzip or bz2 compressed TAR file. 
     125     * 
     126     * @param string $p_tarname The name of the tar archive to create 
     127     * @param string $p_compress can be null, 'gz', 'bz2' or 'lzma2'. This 
     128     *               parameter indicates if gzip, bz2 or lzma2 compression 
     129     *               is required.  For compatibility reason the 
     130     *               boolean value 'true' means 'gz'. 
     131     * 
     132     * @access public 
     133     */ 
    113134    function Archive_Tar($p_tarname, $p_compress = null) 
    114135    { 
    115         $this->PEAR(); 
     136        if (version_compare(PHP_VERSION, '5.0.0', '<')) { 
     137            $this->PEAR(); 
     138        } 
    116139        $this->_compress = false; 
    117140        $this->_compress_type = 'none'; 
     
    129152                        $this->_compress = true; 
    130153                        $this->_compress_type = 'bz2'; 
     154                    } elseif (file_get_contents($p_tarname, false, null, 1, 4) == '7zXZ') { 
     155                        $this->_compress = true; 
     156                        $this->_compress_type = 'lzma2'; 
    131157                    } 
    132158                } 
     
    138164                    $this->_compress_type = 'gz'; 
    139165                } elseif ((substr($p_tarname, -3) == 'bz2') || 
    140                           (substr($p_tarname, -2) == 'bz')) { 
     166                    (substr($p_tarname, -2) == 'bz') 
     167                ) { 
    141168                    $this->_compress = true; 
    142169                    $this->_compress_type = 'bz2'; 
     170                } else { 
     171                    if (substr($p_tarname, -2) == 'xz') { 
     172                        $this->_compress = true; 
     173                        $this->_compress_type = 'lzma2'; 
     174                    } 
    143175                } 
    144176            } 
     
    147179                $this->_compress = true; 
    148180                $this->_compress_type = 'gz'; 
    149             } else if ($p_compress == 'bz2') { 
    150                 $this->_compress = true; 
    151                 $this->_compress_type = 'bz2'; 
    152181            } else { 
    153                 $this->_error("Unsupported compression type '$p_compress'\n". 
    154                     "Supported types are 'gz' and 'bz2'.\n"); 
    155                 return false; 
     182                if ($p_compress == 'bz2') { 
     183                    $this->_compress = true; 
     184                    $this->_compress_type = 'bz2'; 
     185                } else { 
     186                    if ($p_compress == 'lzma2') { 
     187                        $this->_compress = true; 
     188                        $this->_compress_type = 'lzma2'; 
     189                    } else { 
     190                        $this->_error( 
     191                            "Unsupported compression type '$p_compress'\n" . 
     192                            "Supported types are 'gz', 'bz2' and 'lzma2'.\n" 
     193                        ); 
     194                        return false; 
     195                    } 
     196                } 
    156197            } 
    157198        } 
    158199        $this->_tarname = $p_tarname; 
    159         if ($this->_compress) { // assert zlib or bz2 extension support 
    160             if ($this->_compress_type == 'gz') 
     200        if ($this->_compress) { // assert zlib or bz2 or xz extension support 
     201            if ($this->_compress_type == 'gz') { 
    161202                $extname = 'zlib'; 
    162             else if ($this->_compress_type == 'bz2') 
    163                 $extname = 'bz2'; 
     203            } else { 
     204                if ($this->_compress_type == 'bz2') { 
     205                    $extname = 'bz2'; 
     206                } else { 
     207                    if ($this->_compress_type == 'lzma2') { 
     208                        $extname = 'xz'; 
     209                    } 
     210                } 
     211            } 
    164212 
    165213            if (!extension_loaded($extname)) { 
     
    167215            } 
    168216            if (!extension_loaded($extname)) { 
    169                 $this->_error("The extension '$extname' couldn't be found.\n". 
    170                     "Please make sure your version of PHP was built ". 
    171                     "with '$extname' support.\n"); 
     217                $this->_error( 
     218                    "The extension '$extname' couldn't be found.\n" . 
     219                    "Please make sure your version of PHP was built " . 
     220                    "with '$extname' support.\n" 
     221                ); 
    172222                return false; 
    173223            } 
    174224        } 
    175225    } 
     226 
    176227    // }}} 
    177228 
     
    181232        $this->_close(); 
    182233        // ----- Look for a local copy to delete 
    183         if ($this->_temp_tarname != '') 
     234        if ($this->_temp_tarname != '') { 
    184235            @unlink($this->_temp_tarname); 
     236        } 
    185237        $this->_PEAR(); 
    186238    } 
     239 
     240    // }}} 
     241 
     242    // {{{ PHP5-compatible destructor 
     243    function __destruct() 
     244    { 
     245        $this->_Archive_Tar(); 
     246    } 
     247 
    187248    // }}} 
    188249 
    189250    // {{{ create() 
    190251    /** 
    191     * This method creates the archive file and add the files / directories 
    192     * that are listed in $p_filelist. 
    193     * If a file with the same name exist and is writable, it is replaced 
    194     * by the new tar. 
    195     * The method return false and a PEAR error text. 
    196     * The $p_filelist parameter can be an array of string, each string 
    197     * representing a filename or a directory name with their path if 
    198     * needed. It can also be a single string with names separated by a 
    199     * single blank. 
    200     * For each directory added in the archive, the files and 
    201     * sub-directories are also added. 
    202     * See also createModify() method for more details. 
    203     * 
    204     * @param array $p_filelist An array of filenames and directory names, or a 
    205     *              single string with names separated by a single 
    206     *              blank space. 
    207     * 
    208     * @return true on success, false on error. 
    209     * @see    createModify() 
    210     * @access public 
    211     */ 
     252     * This method creates the archive file and add the files / directories 
     253     * that are listed in $p_filelist. 
     254     * If a file with the same name exist and is writable, it is replaced 
     255     * by the new tar. 
     256     * The method return false and a PEAR error text. 
     257     * The $p_filelist parameter can be an array of string, each string 
     258     * representing a filename or a directory name with their path if 
     259     * needed. It can also be a single string with names separated by a 
     260     * single blank. 
     261     * For each directory added in the archive, the files and 
     262     * sub-directories are also added. 
     263     * See also createModify() method for more details. 
     264     * 
     265     * @param array $p_filelist An array of filenames and directory names, or a 
     266     *              single string with names separated by a single 
     267     *              blank space. 
     268     * 
     269     * @return true on success, false on error. 
     270     * @see    createModify() 
     271     * @access public 
     272     */ 
    212273    function create($p_filelist) 
    213274    { 
    214275        return $this->createModify($p_filelist, '', ''); 
    215276    } 
     277 
    216278    // }}} 
    217279 
    218280    // {{{ add() 
    219281    /** 
    220     * This method add the files / directories that are listed in $p_filelist in 
    221     * the archive. If the archive does not exist it is created. 
    222     * The method return false and a PEAR error text. 
    223     * The files and directories listed are only added at the end of the archive, 
    224     * even if a file with the same name is already archived. 
    225     * See also createModify() method for more details. 
    226     * 
    227     * @param array $p_filelist An array of filenames and directory names, or a 
    228     *              single string with names separated by a single 
    229     *              blank space. 
    230     * 
    231     * @return true on success, false on error. 
    232     * @see    createModify() 
    233     * @access public 
    234     */ 
     282     * This method add the files / directories that are listed in $p_filelist in 
     283     * the archive. If the archive does not exist it is created. 
     284     * The method return false and a PEAR error text. 
     285     * The files and directories listed are only added at the end of the archive, 
     286     * even if a file with the same name is already archived. 
     287     * See also createModify() method for more details. 
     288     * 
     289     * @param array $p_filelist An array of filenames and directory names, or a 
     290     *              single string with names separated by a single 
     291     *              blank space. 
     292     * 
     293     * @return true on success, false on error. 
     294     * @see    createModify() 
     295     * @access public 
     296     */ 
    235297    function add($p_filelist) 
    236298    { 
    237299        return $this->addModify($p_filelist, '', ''); 
    238300    } 
     301 
    239302    // }}} 
    240303 
    241304    // {{{ extract() 
    242     function extract($p_path='', $p_preserve=false) 
     305    function extract($p_path = '', $p_preserve = false) 
    243306    { 
    244307        return $this->extractModify($p_path, '', $p_preserve); 
    245308    } 
     309 
    246310    // }}} 
    247311 
     
    261325        return $v_list_detail; 
    262326    } 
     327 
    263328    // }}} 
    264329 
    265330    // {{{ createModify() 
    266331    /** 
    267     * This method creates the archive file and add the files / directories 
    268     * that are listed in $p_filelist. 
    269     * If the file already exists and is writable, it is replaced by the 
    270     * new tar. It is a create and not an add. If the file exists and is 
    271     * read-only or is a directory it is not replaced. The method return 
    272     * false and a PEAR error text. 
    273     * The $p_filelist parameter can be an array of string, each string 
    274     * representing a filename or a directory name with their path if 
    275     * needed. It can also be a single string with names separated by a 
    276     * single blank. 
    277     * The path indicated in $p_remove_dir will be removed from the 
    278     * memorized path of each file / directory listed when this path 
    279     * exists. By default nothing is removed (empty path '') 
    280     * The path indicated in $p_add_dir will be added at the beginning of 
    281     * the memorized path of each file / directory listed. However it can 
    282     * be set to empty ''. The adding of a path is done after the removing 
    283     * of path. 
    284     * The path add/remove ability enables the user to prepare an archive 
    285     * for extraction in a different path than the origin files are. 
    286     * See also addModify() method for file adding properties. 
    287     * 
    288     * @param array  $p_filelist  An array of filenames and directory names, 
    289     *                             or a single string with names separated by 
    290     *                             a single blank space. 
    291     * @param string $p_add_dir    A string which contains a path to be added 
    292     *                             to the memorized path of each element in 
    293     *                             the list. 
    294     * @param string $p_remove_dir A string which contains a path to be 
    295     *                             removed from the memorized path of each 
    296     *                             element in the list, when relevant. 
    297     * 
    298     * @return boolean true on success, false on error. 
    299     * @access public 
    300     * @see addModify() 
    301     */ 
    302     function createModify($p_filelist, $p_add_dir, $p_remove_dir='') 
     332     * This method creates the archive file and add the files / directories 
     333     * that are listed in $p_filelist. 
     334     * If the file already exists and is writable, it is replaced by the 
     335     * new tar. It is a create and not an add. If the file exists and is 
     336     * read-only or is a directory it is not replaced. The method return 
     337     * false and a PEAR error text. 
     338     * The $p_filelist parameter can be an array of string, each string 
     339     * representing a filename or a directory name with their path if 
     340     * needed. It can also be a single string with names separated by a 
     341     * single blank. 
     342     * The path indicated in $p_remove_dir will be removed from the 
     343     * memorized path of each file / directory listed when this path 
     344     * exists. By default nothing is removed (empty path '') 
     345     * The path indicated in $p_add_dir will be added at the beginning of 
     346     * the memorized path of each file / directory listed. However it can 
     347     * be set to empty ''. The adding of a path is done after the removing 
     348     * of path. 
     349     * The path add/remove ability enables the user to prepare an archive 
     350     * for extraction in a different path than the origin files are. 
     351     * See also addModify() method for file adding properties. 
     352     * 
     353     * @param array $p_filelist An array of filenames and directory names, 
     354     *                             or a single string with names separated by 
     355     *                             a single blank space. 
     356     * @param string $p_add_dir A string which contains a path to be added 
     357     *                             to the memorized path of each element in 
     358     *                             the list. 
     359     * @param string $p_remove_dir A string which contains a path to be 
     360     *                             removed from the memorized path of each 
     361     *                             element in the list, when relevant. 
     362     * 
     363     * @return boolean true on success, false on error. 
     364     * @access public 
     365     * @see addModify() 
     366     */ 
     367    function createModify($p_filelist, $p_add_dir, $p_remove_dir = '') 
    303368    { 
    304369        $v_result = true; 
    305370 
    306         if (!$this->_openWrite()) 
     371        if (!$this->_openWrite()) { 
    307372            return false; 
     373        } 
    308374 
    309375        if ($p_filelist != '') { 
    310             if (is_array($p_filelist)) 
     376            if (is_array($p_filelist)) { 
    311377                $v_list = $p_filelist; 
    312             elseif (is_string($p_filelist)) 
     378            } elseif (is_string($p_filelist)) { 
    313379                $v_list = explode($this->_separator, $p_filelist); 
    314             else { 
     380            } else { 
    315381                $this->_cleanFile(); 
    316382                $this->_error('Invalid file list'); 
     
    324390            $this->_writeFooter(); 
    325391            $this->_close(); 
    326         } else 
     392        } else { 
    327393            $this->_cleanFile(); 
     394        } 
    328395 
    329396        return $v_result; 
    330397    } 
     398 
    331399    // }}} 
    332400 
    333401    // {{{ addModify() 
    334402    /** 
    335     * This method add the files / directories listed in $p_filelist at the 
    336     * end of the existing archive. If the archive does not yet exists it 
    337     * is created. 
    338     * The $p_filelist parameter can be an array of string, each string 
    339     * representing a filename or a directory name with their path if 
    340     * needed. It can also be a single string with names separated by a 
    341     * single blank. 
    342     * The path indicated in $p_remove_dir will be removed from the 
    343     * memorized path of each file / directory listed when this path 
    344     * exists. By default nothing is removed (empty path '') 
    345     * The path indicated in $p_add_dir will be added at the beginning of 
    346     * the memorized path of each file / directory listed. However it can 
    347     * be set to empty ''. The adding of a path is done after the removing 
    348     * of path. 
    349     * The path add/remove ability enables the user to prepare an archive 
    350     * for extraction in a different path than the origin files are. 
    351     * If a file/dir is already in the archive it will only be added at the 
    352     * end of the archive. There is no update of the existing archived 
    353     * file/dir. However while extracting the archive, the last file will 
    354     * replace the first one. This results in a none optimization of the 
    355     * archive size. 
    356     * If a file/dir does not exist the file/dir is ignored. However an 
    357     * error text is send to PEAR error. 
    358     * If a file/dir is not readable the file/dir is ignored. However an 
    359     * error text is send to PEAR error. 
    360     * 
    361     * @param array  $p_filelist  An array of filenames and directory 
    362     *                             names, or a single string with names 
    363     *                             separated by a single blank space. 
    364     * @param string $p_add_dir    A string which contains a path to be 
    365     *                             added to the memorized path of each 
    366     *                             element in the list. 
    367     * @param string $p_remove_dir A string which contains a path to be 
    368     *                             removed from the memorized path of 
    369     *                             each element in the list, when 
    370     *                             relevant. 
    371     * 
    372     * @return true on success, false on error. 
    373     * @access public 
    374     */ 
    375     function addModify($p_filelist, $p_add_dir, $p_remove_dir='') 
     403     * This method add the files / directories listed in $p_filelist at the 
     404     * end of the existing archive. If the archive does not yet exists it 
     405     * is created. 
     406     * The $p_filelist parameter can be an array of string, each string 
     407     * representing a filename or a directory name with their path if 
     408     * needed. It can also be a single string with names separated by a 
     409     * single blank. 
     410     * The path indicated in $p_remove_dir will be removed from the 
     411     * memorized path of each file / directory listed when this path 
     412     * exists. By default nothing is removed (empty path '') 
     413     * The path indicated in $p_add_dir will be added at the beginning of 
     414     * the memorized path of each file / directory listed. However it can 
     415     * be set to empty ''. The adding of a path is done after the removing 
     416     * of path. 
     417     * The path add/remove ability enables the user to prepare an archive 
     418     * for extraction in a different path than the origin files are. 
     419     * If a file/dir is already in the archive it will only be added at the 
     420     * end of the archive. There is no update of the existing archived 
     421     * file/dir. However while extracting the archive, the last file will 
     422     * replace the first one. This results in a none optimization of the 
     423     * archive size. 
     424     * If a file/dir does not exist the file/dir is ignored. However an 
     425     * error text is send to PEAR error. 
     426     * If a file/dir is not readable the file/dir is ignored. However an 
     427     * error text is send to PEAR error. 
     428     * 
     429     * @param array $p_filelist An array of filenames and directory 
     430     *                             names, or a single string with names 
     431     *                             separated by a single blank space. 
     432     * @param string $p_add_dir A string which contains a path to be 
     433     *                             added to the memorized path of each 
     434     *                             element in the list. 
     435     * @param string $p_remove_dir A string which contains a path to be 
     436     *                             removed from the memorized path of 
     437     *                             each element in the list, when 
     438     *                             relevant. 
     439     * 
     440     * @return true on success, false on error. 
     441     * @access public 
     442     */ 
     443    function addModify($p_filelist, $p_add_dir, $p_remove_dir = '') 
    376444    { 
    377445        $v_result = true; 
    378446 
    379         if (!$this->_isArchive()) 
    380             $v_result = $this->createModify($p_filelist, $p_add_dir, 
    381                                             $p_remove_dir); 
    382         else { 
    383             if (is_array($p_filelist)) 
     447        if (!$this->_isArchive()) { 
     448            $v_result = $this->createModify( 
     449                $p_filelist, 
     450                $p_add_dir, 
     451                $p_remove_dir 
     452            ); 
     453        } else { 
     454            if (is_array($p_filelist)) { 
    384455                $v_list = $p_filelist; 
    385             elseif (is_string($p_filelist)) 
     456            } elseif (is_string($p_filelist)) { 
    386457                $v_list = explode($this->_separator, $p_filelist); 
    387             else { 
     458            } else { 
    388459                $this->_error('Invalid file list'); 
    389460                return false; 
     
    395466        return $v_result; 
    396467    } 
     468 
    397469    // }}} 
    398470 
    399471    // {{{ addString() 
    400472    /** 
    401     * This method add a single string as a file at the 
    402     * end of the existing archive. If the archive does not yet exists it 
    403     * is created. 
    404     * 
    405     * @param string $p_filename A string which contains the full 
    406     *                           filename path that will be associated 
    407     *                           with the string. 
    408     * @param string $p_string   The content of the file added in 
    409     *                           the archive. 
    410     * @param int    $p_datetime A custom date/time (unix timestamp) 
    411     *                           for the file (optional). 
    412     * 
    413     * @return true on success, false on error. 
    414     * @access public 
    415     */ 
    416     function addString($p_filename, $p_string, $p_datetime = false) 
    417     { 
     473     * This method add a single string as a file at the 
     474     * end of the existing archive. If the archive does not yet exists it 
     475     * is created. 
     476     * 
     477     * @param string $p_filename A string which contains the full 
     478     *                           filename path that will be associated 
     479     *                           with the string. 
     480     * @param string $p_string The content of the file added in 
     481     *                           the archive. 
     482     * @param int $p_datetime A custom date/time (unix timestamp) 
     483     *                           for the file (optional). 
     484     * @param array $p_params An array of optional params: 
     485     *                               stamp => the datetime (replaces 
     486     *                                   datetime above if it exists) 
     487     *                               mode => the permissions on the 
     488     *                                   file (600 by default) 
     489     *                               type => is this a link?  See the 
     490     *                                   tar specification for details. 
     491     *                                   (default = regular file) 
     492     *                               uid => the user ID of the file 
     493     *                                   (default = 0 = root) 
     494     *                               gid => the group ID of the file 
     495     *                                   (default = 0 = root) 
     496     * 
     497     * @return true on success, false on error. 
     498     * @access public 
     499     */ 
     500    function addString($p_filename, $p_string, $p_datetime = false, $p_params = array()) 
     501    { 
     502        $p_stamp = @$p_params["stamp"] ? $p_params["stamp"] : ($p_datetime ? $p_datetime : time()); 
     503        $p_mode = @$p_params["mode"] ? $p_params["mode"] : 0600; 
     504        $p_type = @$p_params["type"] ? $p_params["type"] : ""; 
     505        $p_uid = @$p_params["uid"] ? $p_params["uid"] : ""; 
     506        $p_gid = @$p_params["gid"] ? $p_params["gid"] : ""; 
    418507        $v_result = true; 
    419508 
     
    425514        } 
    426515 
    427         if (!$this->_openAppend()) 
     516        if (!$this->_openAppend()) { 
    428517            return false; 
     518        } 
    429519 
    430520        // Need to check the get back to the temporary file ? .... 
    431         $v_result = $this->_addString($p_filename, $p_string, $p_datetime); 
     521        $v_result = $this->_addString($p_filename, $p_string, $p_datetime, $p_params); 
    432522 
    433523        $this->_writeFooter(); 
     
    437527        return $v_result; 
    438528    } 
     529 
    439530    // }}} 
    440531 
    441532    // {{{ extractModify() 
    442533    /** 
    443     * This method extract all the content of the archive in the directory 
    444     * indicated by $p_path. When relevant the memorized path of the 
    445     * files/dir can be modified by removing the $p_remove_path path at the 
    446     * beginning of the file/dir path. 
    447     * While extracting a file, if the directory path does not exists it is 
    448     * created. 
    449     * While extracting a file, if the file already exists it is replaced 
    450     * without looking for last modification date. 
    451     * While extracting a file, if the file already exists and is write 
    452     * protected, the extraction is aborted. 
    453     * While extracting a file, if a directory with the same name already 
    454     * exists, the extraction is aborted. 
    455     * While extracting a directory, if a file with the same name already 
    456     * exists, the extraction is aborted. 
    457     * While extracting a file/directory if the destination directory exist 
    458     * and is write protected, or does not exist but can not be created, 
    459     * the extraction is aborted. 
    460     * If after extraction an extracted file does not show the correct 
    461     * stored file size, the extraction is aborted. 
    462     * When the extraction is aborted, a PEAR error text is set and false 
    463     * is returned. However the result can be a partial extraction that may 
    464     * need to be manually cleaned. 
    465     * 
    466     * @param string  $p_path        The path of the directory where the 
    467     *                               files/dir need to by extracted. 
    468     * @param string $p_remove_path Part of the memorized path that can be 
    469     *                               removed if present at the beginning of 
    470     *                               the file/dir path. 
    471     * @param boolean $p_preserve    Preserve user/group ownership of files 
    472     * 
    473     * @return boolean true on success, false on error. 
    474     * @access public 
    475     * @see    extractList() 
    476     */ 
    477     function extractModify($p_path, $p_remove_path, $p_preserve=false) 
     534     * This method extract all the content of the archive in the directory 
     535     * indicated by $p_path. When relevant the memorized path of the 
     536     * files/dir can be modified by removing the $p_remove_path path at the 
     537     * beginning of the file/dir path. 
     538     * While extracting a file, if the directory path does not exists it is 
     539     * created. 
     540     * While extracting a file, if the file already exists it is replaced 
     541     * without looking for last modification date. 
     542     * While extracting a file, if the file already exists and is write 
     543     * protected, the extraction is aborted. 
     544     * While extracting a file, if a directory with the same name already 
     545     * exists, the extraction is aborted. 
     546     * While extracting a directory, if a file with the same name already 
     547     * exists, the extraction is aborted. 
     548     * While extracting a file/directory if the destination directory exist 
     549     * and is write protected, or does not exist but can not be created, 
     550     * the extraction is aborted. 
     551     * If after extraction an extracted file does not show the correct 
     552     * stored file size, the extraction is aborted. 
     553     * When the extraction is aborted, a PEAR error text is set and false 
     554     * is returned. However the result can be a partial extraction that may 
     555     * need to be manually cleaned. 
     556     * 
     557     * @param string $p_path The path of the directory where the 
     558     *                               files/dir need to by extracted. 
     559     * @param string $p_remove_path Part of the memorized path that can be 
     560     *                               removed if present at the beginning of 
     561     *                               the file/dir path. 
     562     * @param boolean $p_preserve Preserve user/group ownership of files 
     563     * 
     564     * @return boolean true on success, false on error. 
     565     * @access public 
     566     * @see    extractList() 
     567     */ 
     568    function extractModify($p_path, $p_remove_path, $p_preserve = false) 
    478569    { 
    479570        $v_result = true; 
     
    481572 
    482573        if ($v_result = $this->_openRead()) { 
    483             $v_result = $this->_extractList($p_path, $v_list_detail, 
    484                 "complete", 0, $p_remove_path, $p_preserve); 
     574            $v_result = $this->_extractList( 
     575                $p_path, 
     576                $v_list_detail, 
     577                "complete", 
     578                0, 
     579                $p_remove_path, 
     580                $p_preserve 
     581            ); 
    485582            $this->_close(); 
    486583        } 
     
    488585        return $v_result; 
    489586    } 
     587 
    490588    // }}} 
    491589 
    492590    // {{{ extractInString() 
    493591    /** 
    494     * This method extract from the archive one file identified by $p_filename. 
    495     * The return value is a string with the file content, or NULL on error. 
    496     * 
    497     * @param string $p_filename The path of the file to extract in a string. 
    498     * 
    499     * @return a string with the file content or NULL. 
    500     * @access public 
    501     */ 
     592     * This method extract from the archive one file identified by $p_filename. 
     593     * The return value is a string with the file content, or NULL on error. 
     594     * 
     595     * @param string $p_filename The path of the file to extract in a string. 
     596     * 
     597     * @return a string with the file content or NULL. 
     598     * @access public 
     599     */ 
    502600    function extractInString($p_filename) 
    503601    { 
     
    511609        return $v_result; 
    512610    } 
     611 
    513612    // }}} 
    514613 
    515614    // {{{ extractList() 
    516615    /** 
    517     * This method extract from the archive only the files indicated in the 
    518     * $p_filelist. These files are extracted in the current directory or 
    519     * in the directory indicated by the optional $p_path parameter. 
    520     * If indicated the $p_remove_path can be used in the same way as it is 
    521     * used in extractModify() method. 
    522     * 
    523     * @param array   $p_filelist    An array of filenames and directory names, 
    524     *                               or a single string with names separated 
    525     *                               by a single blank space. 
    526     * @param string  $p_path        The path of the directory where the 
    527     *                               files/dir need to by extracted. 
    528     * @param string $p_remove_path Part of the memorized path that can be 
    529     *                               removed if present at the beginning of 
    530     *                               the file/dir path. 
    531     * @param boolean $p_preserve    Preserve user/group ownership of files 
    532     * 
    533     * @return true on success, false on error. 
    534     * @access public 
    535     * @see    extractModify() 
    536     */ 
    537     function extractList($p_filelist, $p_path='', $p_remove_path='', $p_preserve=false) 
     616     * This method extract from the archive only the files indicated in the 
     617     * $p_filelist. These files are extracted in the current directory or 
     618     * in the directory indicated by the optional $p_path parameter. 
     619     * If indicated the $p_remove_path can be used in the same way as it is 
     620     * used in extractModify() method. 
     621     * 
     622     * @param array $p_filelist An array of filenames and directory names, 
     623     *                               or a single string with names separated 
     624     *                               by a single blank space. 
     625     * @param string $p_path The path of the directory where the 
     626     *                               files/dir need to by extracted. 
     627     * @param string $p_remove_path Part of the memorized path that can be 
     628     *                               removed if present at the beginning of 
     629     *                               the file/dir path. 
     630     * @param boolean $p_preserve Preserve user/group ownership of files 
     631     * 
     632     * @return true on success, false on error. 
     633     * @access public 
     634     * @see    extractModify() 
     635     */ 
     636    function extractList($p_filelist, $p_path = '', $p_remove_path = '', $p_preserve = false) 
    538637    { 
    539638        $v_result = true; 
    540639        $v_list_detail = array(); 
    541640 
    542         if (is_array($p_filelist)) 
     641        if (is_array($p_filelist)) { 
    543642            $v_list = $p_filelist; 
    544         elseif (is_string($p_filelist)) 
     643        } elseif (is_string($p_filelist)) { 
    545644            $v_list = explode($this->_separator, $p_filelist); 
    546         else { 
     645        } else { 
    547646            $this->_error('Invalid string list'); 
    548647            return false; 
     
    550649 
    551650        if ($v_result = $this->_openRead()) { 
    552             $v_result = $this->_extractList($p_path, $v_list_detail, "partial", 
    553                 $v_list, $p_remove_path, $p_preserve); 
     651            $v_result = $this->_extractList( 
     652                $p_path, 
     653                $v_list_detail, 
     654                "partial", 
     655                $v_list, 
     656                $p_remove_path, 
     657                $p_preserve 
     658            ); 
    554659            $this->_close(); 
    555660        } 
     
    557662        return $v_result; 
    558663    } 
     664 
    559665    // }}} 
    560666 
    561667    // {{{ setAttribute() 
    562668    /** 
    563     * This method set specific attributes of the archive. It uses a variable 
    564     * list of parameters, in the format attribute code + attribute values : 
    565     * $arch->setAttribute(ARCHIVE_TAR_ATT_SEPARATOR, ','); 
    566     * 
    567     * @param mixed $argv variable list of attributes and values 
    568     * 
    569     * @return true on success, false on error. 
    570     * @access public 
    571     */ 
     669     * This method set specific attributes of the archive. It uses a variable 
     670     * list of parameters, in the format attribute code + attribute values : 
     671     * $arch->setAttribute(ARCHIVE_TAR_ATT_SEPARATOR, ','); 
     672     * 
     673     * @param mixed $argv variable list of attributes and values 
     674     * 
     675     * @return true on success, false on error. 
     676     * @access public 
     677     */ 
    572678    function setAttribute() 
    573679    { 
     
    580686 
    581687        // ----- Get the arguments 
    582         $v_att_list = &func_get_args(); 
     688        $v_att_list = & func_get_args(); 
    583689 
    584690        // ----- Read the attributes 
    585         $i=0; 
    586         while ($i<$v_size) { 
     691        $i = 0; 
     692        while ($i < $v_size) { 
    587693 
    588694            // ----- Look for next option 
     
    591697                case ARCHIVE_TAR_ATT_SEPARATOR : 
    592698                    // ----- Check the number of parameters 
    593                     if (($i+1) >= $v_size) { 
    594                         $this->_error('Invalid number of parameters for ' 
    595                                       .'attribute ARCHIVE_TAR_ATT_SEPARATOR'); 
     699                    if (($i + 1) >= $v_size) { 
     700                        $this->_error( 
     701                            'Invalid number of parameters for ' 
     702                            . 'attribute ARCHIVE_TAR_ATT_SEPARATOR' 
     703                        ); 
    596704                        return false; 
    597705                    } 
    598706 
    599707                    // ----- Get the value 
    600                     $this->_separator = $v_att_list[$i+1]; 
     708                    $this->_separator = $v_att_list[$i + 1]; 
    601709                    $i++; 
    602                 break; 
     710                    break; 
    603711 
    604712                default : 
    605                     $this->_error('Unknow attribute code '.$v_att_list[$i].''); 
     713                    $this->_error('Unknow attribute code ' . $v_att_list[$i] . ''); 
    606714                    return false; 
    607715            } 
     
    613721        return $v_result; 
    614722    } 
     723 
    615724    // }}} 
    616725 
    617726    // {{{ setIgnoreRegexp() 
    618727    /** 
    619     * This method sets the regular expression for ignoring files and directories 
    620     * at import, for example: 
    621     * $arch->setIgnoreRegexp("#CVS|\.svn#"); 
    622     * 
    623     * @param string $regexp regular expression defining which files or directories to ignore 
    624     * 
    625     * @access public 
    626     */ 
     728     * This method sets the regular expression for ignoring files and directories 
     729     * at import, for example: 
     730     * $arch->setIgnoreRegexp("#CVS|\.svn#"); 
     731     * 
     732     * @param string $regexp regular expression defining which files or directories to ignore 
     733     * 
     734     * @access public 
     735     */ 
    627736    function setIgnoreRegexp($regexp) 
    628737    { 
    629         $this->_ignore_regexp = $regexp; 
    630     } 
     738        $this->_ignore_regexp = $regexp; 
     739    } 
     740 
    631741    // }}} 
    632742 
    633743    // {{{ setIgnoreList() 
    634744    /** 
    635     * This method sets the regular expression for ignoring all files and directories 
    636     * matching the filenames in the array list at import, for example: 
    637     * $arch->setIgnoreList(array('CVS', '.svn', 'bin/tool')); 
    638     * 
    639     * @param array $list a list of file or directory names to ignore 
    640     * 
    641     * @access public 
    642     */ 
     745     * This method sets the regular expression for ignoring all files and directories 
     746     * matching the filenames in the array list at import, for example: 
     747     * $arch->setIgnoreList(array('CVS', '.svn', 'bin/tool')); 
     748     * 
     749     * @param array $list a list of file or directory names to ignore 
     750     * 
     751     * @access public 
     752     */ 
    643753    function setIgnoreList($list) 
    644754    { 
    645         $regexp = str_replace(array('#', '.', '^', '$'), array('\#', '\.', '\^', '\$'), $list); 
    646         $regexp = '#/'.join('$|/', $list).'#'; 
    647         $this->setIgnoreRegexp($regexp); 
    648     } 
     755        $regexp = str_replace(array('#', '.', '^', '$'), array('\#', '\.', '\^', '\$'), $list); 
     756        $regexp = '#/' . join('$|/', $list) . '#'; 
     757        $this->setIgnoreRegexp($regexp); 
     758    } 
     759 
    649760    // }}} 
    650761 
     
    652763    function _error($p_message) 
    653764    { 
    654         $this->error_object = &$this->raiseError($p_message);  
    655     } 
     765        $this->error_object = & $this->raiseError($p_message); 
     766    } 
     767 
    656768    // }}} 
    657769 
     
    659771    function _warning($p_message) 
    660772    { 
    661         $this->error_object = &$this->raiseError($p_message);  
    662     } 
     773        $this->error_object = & $this->raiseError($p_message); 
     774    } 
     775 
    663776    // }}} 
    664777 
    665778    // {{{ _isArchive() 
    666     function _isArchive($p_filename=null) 
     779    function _isArchive($p_filename = null) 
    667780    { 
    668781        if ($p_filename == null) { 
     
    672785        return @is_file($p_filename) && !@is_link($p_filename); 
    673786    } 
     787 
    674788    // }}} 
    675789 
     
    677791    function _openWrite() 
    678792    { 
    679         if ($this->_compress_type == 'gz' && function_exists('gzopen')) 
     793        if ($this->_compress_type == 'gz' && function_exists('gzopen')) { 
    680794            $this->_file = @gzopen($this->_tarname, "wb9"); 
    681         else if ($this->_compress_type == 'bz2' && function_exists('bzopen')) 
    682             $this->_file = @bzopen($this->_tarname, "w"); 
    683         else if ($this->_compress_type == 'none') 
    684             $this->_file = @fopen($this->_tarname, "wb"); 
    685         else { 
    686             $this->_error('Unknown or missing compression type (' 
    687                           .$this->_compress_type.')'); 
     795        } else { 
     796            if ($this->_compress_type == 'bz2' && function_exists('bzopen')) { 
     797                $this->_file = @bzopen($this->_tarname, "w"); 
     798            } else { 
     799                if ($this->_compress_type == 'lzma2' && function_exists('xzopen')) { 
     800                    $this->_file = @xzopen($this->_tarname, 'w'); 
     801                } else { 
     802                    if ($this->_compress_type == 'none') { 
     803                        $this->_file = @fopen($this->_tarname, "wb"); 
     804                    } else { 
     805                        $this->_error( 
     806                            'Unknown or missing compression type (' 
     807                            . $this->_compress_type . ')' 
     808                        ); 
     809                        return false; 
     810                    } 
     811                } 
     812            } 
     813        } 
     814 
     815        if ($this->_file == 0) { 
     816            $this->_error( 
     817                'Unable to open in write mode \'' 
     818                . $this->_tarname . '\'' 
     819            ); 
    688820            return false; 
    689821        } 
    690822 
    691         if ($this->_file == 0) { 
    692             $this->_error('Unable to open in write mode \'' 
    693                           .$this->_tarname.'\''); 
    694             return false; 
    695         } 
    696  
    697823        return true; 
    698824    } 
     825 
    699826    // }}} 
    700827 
     
    704831        if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') { 
    705832 
    706           // ----- Look if a local copy need to be done 
    707           if ($this->_temp_tarname == '') { 
    708               $this->_temp_tarname = uniqid('tar').'.tmp'; 
    709               if (!$v_file_from = @fopen($this->_tarname, 'rb')) { 
    710                 $this->_error('Unable to open in read mode \'' 
    711                               .$this->_tarname.'\''); 
    712                 $this->_temp_tarname = ''; 
    713                 return false; 
    714               } 
    715               if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) { 
    716                 $this->_error('Unable to open in write mode \'' 
    717                               .$this->_temp_tarname.'\''); 
    718                 $this->_temp_tarname = ''; 
    719                 return false; 
    720               } 
    721               while ($v_data = @fread($v_file_from, 1024)) 
    722                   @fwrite($v_file_to, $v_data); 
    723               @fclose($v_file_from); 
    724               @fclose($v_file_to); 
    725           } 
    726  
    727           // ----- File to open if the local copy 
    728           $v_filename = $this->_temp_tarname; 
    729  
    730         } else 
    731           // ----- File to open if the normal Tar file 
    732           $v_filename = $this->_tarname; 
    733  
    734         if ($this->_compress_type == 'gz' && function_exists('gzopen')) 
     833            // ----- Look if a local copy need to be done 
     834            if ($this->_temp_tarname == '') { 
     835                $this->_temp_tarname = uniqid('tar') . '.tmp'; 
     836                if (!$v_file_from = @fopen($this->_tarname, 'rb')) { 
     837                    $this->_error( 
     838                        'Unable to open in read mode \'' 
     839                        . $this->_tarname . '\'' 
     840                    ); 
     841                    $this->_temp_tarname = ''; 
     842                    return false; 
     843                } 
     844                if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) { 
     845                    $this->_error( 
     846                        'Unable to open in write mode \'' 
     847                        . $this->_temp_tarname . '\'' 
     848                    ); 
     849                    $this->_temp_tarname = ''; 
     850                    return false; 
     851                } 
     852                while ($v_data = @fread($v_file_from, 1024)) { 
     853                    @fwrite($v_file_to, $v_data); 
     854                } 
     855                @fclose($v_file_from); 
     856                @fclose($v_file_to); 
     857            } 
     858 
     859            // ----- File to open if the local copy 
     860            $v_filename = $this->_temp_tarname; 
     861 
     862        } else // ----- File to open if the normal Tar file 
     863        { 
     864            $v_filename = $this->_tarname; 
     865        } 
     866 
     867        if ($this->_compress_type == 'gz' && function_exists('gzopen')) { 
    735868            $this->_file = @gzopen($v_filename, "rb"); 
    736         else if ($this->_compress_type == 'bz2' && function_exists('bzopen')) 
    737             $this->_file = @bzopen($v_filename, "r"); 
    738         else if ($this->_compress_type == 'none') 
    739             $this->_file = @fopen($v_filename, "rb"); 
    740         else { 
    741             $this->_error('Unknown or missing compression type (' 
    742                           .$this->_compress_type.')'); 
     869        } else { 
     870            if ($this->_compress_type == 'bz2' && function_exists('bzopen')) { 
     871                $this->_file = @bzopen($v_filename, "r"); 
     872            } else { 
     873                if ($this->_compress_type == 'lzma2' && function_exists('xzopen')) { 
     874                    $this->_file = @xzopen($v_filename, "r"); 
     875                } else { 
     876                    if ($this->_compress_type == 'none') { 
     877                        $this->_file = @fopen($v_filename, "rb"); 
     878                    } else { 
     879                        $this->_error( 
     880                            'Unknown or missing compression type (' 
     881                            . $this->_compress_type . ')' 
     882                        ); 
     883                        return false; 
     884                    } 
     885                } 
     886            } 
     887        } 
     888 
     889        if ($this->_file == 0) { 
     890            $this->_error('Unable to open in read mode \'' . $v_filename . '\''); 
    743891            return false; 
    744892        } 
    745893 
    746         if ($this->_file == 0) { 
    747             $this->_error('Unable to open in read mode \''.$v_filename.'\''); 
    748             return false; 
    749         } 
    750  
    751894        return true; 
    752895    } 
     896 
    753897    // }}} 
    754898 
     
    756900    function _openReadWrite() 
    757901    { 
    758         if ($this->_compress_type == 'gz') 
     902        if ($this->_compress_type == 'gz') { 
    759903            $this->_file = @gzopen($this->_tarname, "r+b"); 
    760         else if ($this->_compress_type == 'bz2') { 
    761             $this->_error('Unable to open bz2 in read/write mode \'' 
    762                           .$this->_tarname.'\' (limitation of bz2 extension)'); 
     904        } else { 
     905            if ($this->_compress_type == 'bz2') { 
     906                $this->_error( 
     907                    'Unable to open bz2 in read/write mode \'' 
     908                    . $this->_tarname . '\' (limitation of bz2 extension)' 
     909                ); 
     910                return false; 
     911            } else { 
     912                if ($this->_compress_type == 'lzma2') { 
     913                    $this->_error( 
     914                        'Unable to open lzma2 in read/write mode \'' 
     915                        . $this->_tarname . '\' (limitation of lzma2 extension)' 
     916                    ); 
     917                    return false; 
     918                } else { 
     919                    if ($this->_compress_type == 'none') { 
     920                        $this->_file = @fopen($this->_tarname, "r+b"); 
     921                    } else { 
     922                        $this->_error( 
     923                            'Unknown or missing compression type (' 
     924                            . $this->_compress_type . ')' 
     925                        ); 
     926                        return false; 
     927                    } 
     928                } 
     929            } 
     930        } 
     931 
     932        if ($this->_file == 0) { 
     933            $this->_error( 
     934                'Unable to open in read/write mode \'' 
     935                . $this->_tarname . '\'' 
     936            ); 
    763937            return false; 
    764         } else if ($this->_compress_type == 'none') 
    765             $this->_file = @fopen($this->_tarname, "r+b"); 
    766         else { 
    767             $this->_error('Unknown or missing compression type (' 
    768                           .$this->_compress_type.')'); 
    769             return false; 
    770         } 
    771  
    772         if ($this->_file == 0) { 
    773             $this->_error('Unable to open in read/write mode \'' 
    774                           .$this->_tarname.'\''); 
    775             return false; 
    776938        } 
    777939 
    778940        return true; 
    779941    } 
     942 
    780943    // }}} 
    781944 
     
    785948        //if (isset($this->_file)) { 
    786949        if (is_resource($this->_file)) { 
    787             if ($this->_compress_type == 'gz') 
     950            if ($this->_compress_type == 'gz') { 
    788951                @gzclose($this->_file); 
    789             else if ($this->_compress_type == 'bz2') 
    790                 @bzclose($this->_file); 
    791             else if ($this->_compress_type == 'none') 
    792                 @fclose($this->_file); 
    793             else 
    794                 $this->_error('Unknown or missing compression type (' 
    795                               .$this->_compress_type.')'); 
     952            } else { 
     953                if ($this->_compress_type == 'bz2') { 
     954                    @bzclose($this->_file); 
     955                } else { 
     956                    if ($this->_compress_type == 'lzma2') { 
     957                        @xzclose($this->_file); 
     958                    } else { 
     959                        if ($this->_compress_type == 'none') { 
     960                            @fclose($this->_file); 
     961                        } else { 
     962                            $this->_error( 
     963                                'Unknown or missing compression type (' 
     964                                . $this->_compress_type . ')' 
     965                            ); 
     966                        } 
     967                    } 
     968                } 
     969            } 
    796970 
    797971            $this->_file = 0; 
     
    807981        return true; 
    808982    } 
     983 
    809984    // }}} 
    810985 
     
    8271002        return true; 
    8281003    } 
     1004 
    8291005    // }}} 
    8301006 
    8311007    // {{{ _writeBlock() 
    832     function _writeBlock($p_binary_data, $p_len=null) 
    833     { 
    834       if (is_resource($this->_file)) { 
    835           if ($p_len === null) { 
    836               if ($this->_compress_type == 'gz') 
    837                   @gzputs($this->_file, $p_binary_data); 
    838               else if ($this->_compress_type == 'bz2') 
    839                   @bzwrite($this->_file, $p_binary_data); 
    840               else if ($this->_compress_type == 'none') 
    841                   @fputs($this->_file, $p_binary_data); 
    842               else 
    843                   $this->_error('Unknown or missing compression type (' 
    844                                 .$this->_compress_type.')'); 
    845           } else { 
    846               if ($this->_compress_type == 'gz') 
    847                   @gzputs($this->_file, $p_binary_data, $p_len); 
    848               else if ($this->_compress_type == 'bz2') 
    849                   @bzwrite($this->_file, $p_binary_data, $p_len); 
    850               else if ($this->_compress_type == 'none') 
    851                   @fputs($this->_file, $p_binary_data, $p_len); 
    852               else 
    853                   $this->_error('Unknown or missing compression type (' 
    854                                 .$this->_compress_type.')'); 
    855  
    856           } 
    857       } 
    858       return true; 
    859     } 
     1008    function _writeBlock($p_binary_data, $p_len = null) 
     1009    { 
     1010        if (is_resource($this->_file)) { 
     1011            if ($p_len === null) { 
     1012                if ($this->_compress_type == 'gz') { 
     1013                    @gzputs($this->_file, $p_binary_data); 
     1014                } else { 
     1015                    if ($this->_compress_type == 'bz2') { 
     1016                        @bzwrite($this->_file, $p_binary_data); 
     1017                    } else { 
     1018                        if ($this->_compress_type == 'lzma2') { 
     1019                            @xzwrite($this->_file, $p_binary_data); 
     1020                        } else { 
     1021                            if ($this->_compress_type == 'none') { 
     1022                                @fputs($this->_file, $p_binary_data); 
     1023                            } else { 
     1024                                $this->_error( 
     1025                                    'Unknown or missing compression type (' 
     1026                                    . $this->_compress_type . ')' 
     1027                                ); 
     1028                            } 
     1029                        } 
     1030                    } 
     1031                } 
     1032            } else { 
     1033                if ($this->_compress_type == 'gz') { 
     1034                    @gzputs($this->_file, $p_binary_data, $p_len); 
     1035                } else { 
     1036                    if ($this->_compress_type == 'bz2') { 
     1037                        @bzwrite($this->_file, $p_binary_data, $p_len); 
     1038                    } else { 
     1039                        if ($this->_compress_type == 'lzma2') { 
     1040                            @xzwrite($this->_file, $p_binary_data, $p_len); 
     1041                        } else { 
     1042                            if ($this->_compress_type == 'none') { 
     1043                                @fputs($this->_file, $p_binary_data, $p_len); 
     1044                            } else { 
     1045                                $this->_error( 
     1046                                    'Unknown or missing compression type (' 
     1047                                    . $this->_compress_type . ')' 
     1048                                ); 
     1049                            } 
     1050                        } 
     1051                    } 
     1052                } 
     1053 
     1054            } 
     1055        } 
     1056        return true; 
     1057    } 
     1058 
    8601059    // }}} 
    8611060 
     
    8631062    function _readBlock() 
    8641063    { 
    865       $v_block = null; 
    866       if (is_resource($this->_file)) { 
    867           if ($this->_compress_type == 'gz') 
    868               $v_block = @gzread($this->_file, 512); 
    869           else if ($this->_compress_type == 'bz2') 
    870               $v_block = @bzread($this->_file, 512); 
    871           else if ($this->_compress_type == 'none') 
    872               $v_block = @fread($this->_file, 512); 
    873           else 
    874               $this->_error('Unknown or missing compression type (' 
    875                             .$this->_compress_type.')'); 
    876       } 
    877       return $v_block; 
    878     } 
     1064        $v_block = null; 
     1065        if (is_resource($this->_file)) { 
     1066            if ($this->_compress_type == 'gz') { 
     1067                $v_block = @gzread($this->_file, 512); 
     1068            } else { 
     1069                if ($this->_compress_type == 'bz2') { 
     1070                    $v_block = @bzread($this->_file, 512); 
     1071                } else { 
     1072                    if ($this->_compress_type == 'lzma2') { 
     1073                        $v_block = @xzread($this->_file, 512); 
     1074                    } else { 
     1075                        if ($this->_compress_type == 'none') { 
     1076                            $v_block = @fread($this->_file, 512); 
     1077                        } else { 
     1078                            $this->_error( 
     1079                                'Unknown or missing compression type (' 
     1080                                . $this->_compress_type . ')' 
     1081                            ); 
     1082                        } 
     1083                    } 
     1084                } 
     1085            } 
     1086        } 
     1087        return $v_block; 
     1088    } 
     1089 
    8791090    // }}} 
    8801091 
    8811092    // {{{ _jumpBlock() 
    882     function _jumpBlock($p_len=null) 
    883     { 
    884       if (is_resource($this->_file)) { 
    885           if ($p_len === null) 
    886               $p_len = 1; 
    887  
    888           if ($this->_compress_type == 'gz') { 
    889               @gzseek($this->_file, gztell($this->_file)+($p_len*512)); 
    890           } 
    891           else if ($this->_compress_type == 'bz2') { 
    892               // ----- Replace missing bztell() and bzseek() 
    893               for ($i=0; $i<$p_len; $i++) 
    894                   $this->_readBlock(); 
    895           } else if ($this->_compress_type == 'none') 
    896               @fseek($this->_file, $p_len*512, SEEK_CUR); 
    897           else 
    898               $this->_error('Unknown or missing compression type (' 
    899                             .$this->_compress_type.')'); 
    900  
    901       } 
    902       return true; 
    903     } 
     1093    function _jumpBlock($p_len = null) 
     1094    { 
     1095        if (is_resource($this->_file)) { 
     1096            if ($p_len === null) { 
     1097                $p_len = 1; 
     1098            } 
     1099 
     1100            if ($this->_compress_type == 'gz') { 
     1101                @gzseek($this->_file, gztell($this->_file) + ($p_len * 512)); 
     1102            } else { 
     1103                if ($this->_compress_type == 'bz2') { 
     1104                    // ----- Replace missing bztell() and bzseek() 
     1105                    for ($i = 0; $i < $p_len; $i++) { 
     1106                        $this->_readBlock(); 
     1107                    } 
     1108                } else { 
     1109                    if ($this->_compress_type == 'lzma2') { 
     1110                        // ----- Replace missing xztell() and xzseek() 
     1111                        for ($i = 0; $i < $p_len; $i++) { 
     1112                            $this->_readBlock(); 
     1113                        } 
     1114                    } else { 
     1115                        if ($this->_compress_type == 'none') { 
     1116                            @fseek($this->_file, $p_len * 512, SEEK_CUR); 
     1117                        } else { 
     1118                            $this->_error( 
     1119                                'Unknown or missing compression type (' 
     1120                                . $this->_compress_type . ')' 
     1121                            ); 
     1122                        } 
     1123                    } 
     1124                } 
     1125            } 
     1126 
     1127        } 
     1128        return true; 
     1129    } 
     1130 
    9041131    // }}} 
    9051132 
     
    9071134    function _writeFooter() 
    9081135    { 
    909       if (is_resource($this->_file)) { 
    910           // ----- Write the last 0 filled block for end of archive 
    911           $v_binary_data = pack('a1024', ''); 
    912           $this->_writeBlock($v_binary_data); 
    913       } 
    914       return true; 
    915     } 
     1136        if (is_resource($this->_file)) { 
     1137            // ----- Write the last 0 filled block for end of archive 
     1138            $v_binary_data = pack('a1024', ''); 
     1139            $this->_writeBlock($v_binary_data); 
     1140        } 
     1141        return true; 
     1142    } 
     1143 
    9161144    // }}} 
    9171145 
     
    9191147    function _addList($p_list, $p_add_dir, $p_remove_dir) 
    9201148    { 
    921       $v_result=true; 
    922       $v_header = array(); 
    923  
    924       // ----- Remove potential windows directory separator 
    925       $p_add_dir = $this->_translateWinPath($p_add_dir); 
    926       $p_remove_dir = $this->_translateWinPath($p_remove_dir, false); 
    927  
    928       if (!$this->_file) { 
    929           $this->_error('Invalid file descriptor'); 
    930           return false; 
    931       } 
    932  
    933       if (sizeof($p_list) == 0) 
    934           return true; 
    935  
    936       foreach ($p_list as $v_filename) { 
    937           if (!$v_result) { 
    938               break; 
    939           } 
    940  
    941         // ----- Skip the current tar name 
    942         if ($v_filename == $this->_tarname) 
    943             continue; 
    944  
    945         if ($v_filename == '') 
    946             continue; 
    947  
    948         // ----- ignore files and directories matching the ignore regular expression 
    949         if ($this->_ignore_regexp && preg_match($this->_ignore_regexp, '/'.$v_filename)) { 
    950             $this->_warning("File '$v_filename' ignored"); 
    951             continue; 
    952         } 
    953  
    954         if (!file_exists($v_filename) && !is_link($v_filename)) { 
    955             $this->_warning("File '$v_filename' does not exist"); 
    956             continue; 
    957         } 
    958  
    959         // ----- Add the file or directory header 
    960         if (!$this->_addFile($v_filename, $v_header, $p_add_dir, $p_remove_dir)) 
     1149        $v_result = true; 
     1150        $v_header = array(); 
     1151 
     1152        // ----- Remove potential windows directory separator 
     1153        $p_add_dir = $this->_translateWinPath($p_add_dir); 
     1154        $p_remove_dir = $this->_translateWinPath($p_remove_dir, false); 
     1155 
     1156        if (!$this->_file) { 
     1157            $this->_error('Invalid file descriptor'); 
    9611158            return false; 
    962  
    963         if (@is_dir($v_filename) && !@is_link($v_filename)) { 
    964             if (!($p_hdir = opendir($v_filename))) { 
    965                 $this->_warning("Directory '$v_filename' can not be read"); 
     1159        } 
     1160 
     1161        if (sizeof($p_list) == 0) { 
     1162            return true; 
     1163        } 
     1164 
     1165        foreach ($p_list as $v_filename) { 
     1166            if (!$v_result) { 
     1167                break; 
     1168            } 
     1169 
     1170            // ----- Skip the current tar name 
     1171            if ($v_filename == $this->_tarname) { 
    9661172                continue; 
    9671173            } 
    968             while (false !== ($p_hitem = readdir($p_hdir))) { 
    969                 if (($p_hitem != '.') && ($p_hitem != '..')) { 
    970                     if ($v_filename != ".") 
    971                         $p_temp_list[0] = $v_filename.'/'.$p_hitem; 
    972                     else 
    973                         $p_temp_list[0] = $p_hitem; 
    974  
    975                     $v_result = $this->_addList($p_temp_list, 
    976                                                 $p_add_dir, 
    977                                                 $p_remove_dir); 
    978                 } 
    979             } 
    980  
    981             unset($p_temp_list); 
    982             unset($p_hdir); 
    983             unset($p_hitem); 
    984         } 
    985       } 
    986  
    987       return $v_result; 
    988     } 
     1174 
     1175            if ($v_filename == '') { 
     1176                continue; 
     1177            } 
     1178 
     1179            // ----- ignore files and directories matching the ignore regular expression 
     1180            if ($this->_ignore_regexp && preg_match($this->_ignore_regexp, '/' . $v_filename)) { 
     1181                $this->_warning("File '$v_filename' ignored"); 
     1182                continue; 
     1183            } 
     1184 
     1185            if (!file_exists($v_filename) && !is_link($v_filename)) { 
     1186                $this->_warning("File '$v_filename' does not exist"); 
     1187                continue; 
     1188            } 
     1189 
     1190            // ----- Add the file or directory header 
     1191            if (!$this->_addFile($v_filename, $v_header, $p_add_dir, $p_remove_dir)) { 
     1192                return false; 
     1193            } 
     1194 
     1195            if (@is_dir($v_filename) && !@is_link($v_filename)) { 
     1196                if (!($p_hdir = opendir($v_filename))) { 
     1197                    $this->_warning("Directory '$v_filename' can not be read"); 
     1198                    continue; 
     1199                } 
     1200                while (false !== ($p_hitem = readdir($p_hdir))) { 
     1201                    if (($p_hitem != '.') && ($p_hitem != '..')) { 
     1202                        if ($v_filename != ".") { 
     1203                            $p_temp_list[0] = $v_filename . '/' . $p_hitem; 
     1204                        } else { 
     1205                            $p_temp_list[0] = $p_hitem; 
     1206                        } 
     1207 
     1208                        $v_result = $this->_addList( 
     1209                            $p_temp_list, 
     1210                            $p_add_dir, 
     1211                            $p_remove_dir 
     1212                        ); 
     1213                    } 
     1214                } 
     1215 
     1216                unset($p_temp_list); 
     1217                unset($p_hdir); 
     1218                unset($p_hitem); 
     1219            } 
     1220        } 
     1221 
     1222        return $v_result; 
     1223    } 
     1224 
    9891225    // }}} 
    9901226 
    9911227    // {{{ _addFile() 
    992     function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir) 
    993     { 
    994       if (!$this->_file) { 
    995           $this->_error('Invalid file descriptor'); 
    996           return false; 
    997       } 
    998  
    999       if ($p_filename == '') { 
    1000           $this->_error('Invalid file name'); 
    1001           return false; 
    1002       } 
    1003  
    1004       // ----- Calculate the stored filename 
    1005       $p_filename = $this->_translateWinPath($p_filename, false);; 
    1006       $v_stored_filename = $p_filename; 
    1007       if (strcmp($p_filename, $p_remove_dir) == 0) { 
    1008           return true; 
    1009       } 
    1010       if ($p_remove_dir != '') { 
    1011           if (substr($p_remove_dir, -1) != '/') 
    1012               $p_remove_dir .= '/'; 
    1013  
    1014           if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir) 
    1015               $v_stored_filename = substr($p_filename, strlen($p_remove_dir)); 
    1016       } 
    1017       $v_stored_filename = $this->_translateWinPath($v_stored_filename); 
    1018       if ($p_add_dir != '') { 
    1019           if (substr($p_add_dir, -1) == '/') 
    1020               $v_stored_filename = $p_add_dir.$v_stored_filename; 
    1021           else 
    1022               $v_stored_filename = $p_add_dir.'/'.$v_stored_filename; 
    1023       } 
    1024  
    1025       $v_stored_filename = $this->_pathReduction($v_stored_filename); 
    1026  
    1027       if ($this->_isArchive($p_filename)) { 
    1028           if (($v_file = @fopen($p_filename, "rb")) == 0) { 
    1029               $this->_warning("Unable to open file '".$p_filename 
    1030                               ."' in binary read mode"); 
    1031               return true; 
    1032           } 
    1033  
    1034           if (!$this->_writeHeader($p_filename, $v_stored_filename)) 
    1035               return false; 
    1036  
    1037           while (($v_buffer = fread($v_file, 512)) != '') { 
    1038               $v_binary_data = pack("a512", "$v_buffer"); 
    1039               $this->_writeBlock($v_binary_data); 
    1040           } 
    1041  
    1042           fclose($v_file); 
    1043  
    1044       } else { 
    1045           // ----- Only header for dir 
    1046           if (!$this->_writeHeader($p_filename, $v_stored_filename)) 
    1047               return false; 
    1048       } 
    1049  
    1050       return true; 
    1051     } 
     1228    function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $v_stored_filename = null) 
     1229    { 
     1230        if (!$this->_file) { 
     1231            $this->_error('Invalid file descriptor'); 
     1232            return false; 
     1233        } 
     1234 
     1235        if ($p_filename == '') { 
     1236            $this->_error('Invalid file name'); 
     1237            return false; 
     1238        } 
     1239 
     1240        if (is_null($v_stored_filename)) { 
     1241            // ----- Calculate the stored filename 
     1242            $p_filename = $this->_translateWinPath($p_filename, false);; 
     1243            $v_stored_filename = $p_filename; 
     1244 
     1245            if (strcmp($p_filename, $p_remove_dir) == 0) { 
     1246                return true; 
     1247            } 
     1248 
     1249            if ($p_remove_dir != '') { 
     1250                if (substr($p_remove_dir, -1) != '/') { 
     1251                    $p_remove_dir .= '/'; 
     1252                } 
     1253 
     1254                if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir) { 
     1255                    $v_stored_filename = substr($p_filename, strlen($p_remove_dir)); 
     1256                } 
     1257            } 
     1258 
     1259            $v_stored_filename = $this->_translateWinPath($v_stored_filename); 
     1260            if ($p_add_dir != '') { 
     1261                if (substr($p_add_dir, -1) == '/') { 
     1262                    $v_stored_filename = $p_add_dir . $v_stored_filename; 
     1263                } else { 
     1264                    $v_stored_filename = $p_add_dir . '/' . $v_stored_filename; 
     1265                } 
     1266            } 
     1267 
     1268            $v_stored_filename = $this->_pathReduction($v_stored_filename); 
     1269        } 
     1270 
     1271        if ($this->_isArchive($p_filename)) { 
     1272            if (($v_file = @fopen($p_filename, "rb")) == 0) { 
     1273                $this->_warning( 
     1274                    "Unable to open file '" . $p_filename 
     1275                    . "' in binary read mode" 
     1276                ); 
     1277                return true; 
     1278            } 
     1279 
     1280            if (!$this->_writeHeader($p_filename, $v_stored_filename)) { 
     1281                return false; 
     1282            } 
     1283 
     1284            while (($v_buffer = fread($v_file, 512)) != '') { 
     1285                $v_binary_data = pack("a512", "$v_buffer"); 
     1286                $this->_writeBlock($v_binary_data); 
     1287            } 
     1288 
     1289            fclose($v_file); 
     1290 
     1291        } else { 
     1292            // ----- Only header for dir 
     1293            if (!$this->_writeHeader($p_filename, $v_stored_filename)) { 
     1294                return false; 
     1295            } 
     1296        } 
     1297 
     1298        return true; 
     1299    } 
     1300 
    10521301    // }}} 
    10531302 
    10541303    // {{{ _addString() 
    1055     function _addString($p_filename, $p_string, $p_datetime = false) 
    1056     { 
    1057       if (!$this->_file) { 
    1058           $this->_error('Invalid file descriptor'); 
    1059           return false; 
    1060       } 
    1061  
    1062       if ($p_filename == '') { 
    1063           $this->_error('Invalid file name'); 
    1064           return false; 
    1065       } 
    1066  
    1067       // ----- Calculate the stored filename 
    1068       $p_filename = $this->_translateWinPath($p_filename, false);; 
    1069        
    1070       // ----- If datetime is not specified, set current time 
    1071       if ($p_datetime === false) { 
    1072           $p_datetime = time(); 
    1073       } 
    1074  
    1075       if (!$this->_writeHeaderBlock($p_filename, strlen($p_string), 
    1076                                     $p_datetime, 384, "", 0, 0)) 
    1077           return false; 
    1078  
    1079       $i=0; 
    1080       while (($v_buffer = substr($p_string, (($i++)*512), 512)) != '') { 
    1081           $v_binary_data = pack("a512", $v_buffer); 
    1082           $this->_writeBlock($v_binary_data); 
    1083       } 
    1084  
    1085       return true; 
    1086     } 
     1304    function _addString($p_filename, $p_string, $p_datetime = false, $p_params = array()) 
     1305    { 
     1306        $p_stamp = @$p_params["stamp"] ? $p_params["stamp"] : ($p_datetime ? $p_datetime : time()); 
     1307        $p_mode = @$p_params["mode"] ? $p_params["mode"] : 0600; 
     1308        $p_type = @$p_params["type"] ? $p_params["type"] : ""; 
     1309        $p_uid = @$p_params["uid"] ? $p_params["uid"] : 0; 
     1310        $p_gid = @$p_params["gid"] ? $p_params["gid"] : 0; 
     1311        if (!$this->_file) { 
     1312            $this->_error('Invalid file descriptor'); 
     1313            return false; 
     1314        } 
     1315 
     1316        if ($p_filename == '') { 
     1317            $this->_error('Invalid file name'); 
     1318            return false; 
     1319        } 
     1320 
     1321        // ----- Calculate the stored filename 
     1322        $p_filename = $this->_translateWinPath($p_filename, false);; 
     1323 
     1324        // ----- If datetime is not specified, set current time 
     1325        if ($p_datetime === false) { 
     1326            $p_datetime = time(); 
     1327        } 
     1328 
     1329        if (!$this->_writeHeaderBlock( 
     1330            $p_filename, 
     1331            strlen($p_string), 
     1332            $p_stamp, 
     1333            $p_mode, 
     1334            $p_type, 
     1335            $p_uid, 
     1336            $p_gid 
     1337        ) 
     1338        ) { 
     1339            return false; 
     1340        } 
     1341 
     1342        $i = 0; 
     1343        while (($v_buffer = substr($p_string, (($i++) * 512), 512)) != '') { 
     1344            $v_binary_data = pack("a512", $v_buffer); 
     1345            $this->_writeBlock($v_binary_data); 
     1346        } 
     1347 
     1348        return true; 
     1349    } 
     1350 
    10871351    // }}} 
    10881352 
     
    10901354    function _writeHeader($p_filename, $p_stored_filename) 
    10911355    { 
    1092         if ($p_stored_filename == '') 
     1356        if ($p_stored_filename == '') { 
    10931357            $p_stored_filename = $p_filename; 
     1358        } 
    10941359        $v_reduce_filename = $this->_pathReduction($p_stored_filename); 
    10951360 
    10961361        if (strlen($v_reduce_filename) > 99) { 
    1097           if (!$this->_writeLongHeader($v_reduce_filename)) 
    1098             return false; 
     1362            if (!$this->_writeLongHeader($v_reduce_filename)) { 
     1363                return false; 
     1364            } 
    10991365        } 
    11001366 
     
    11091375 
    11101376        if (@is_link($p_filename)) { 
    1111           $v_typeflag = '2'; 
    1112           $v_linkname = readlink($p_filename); 
    1113           $v_size = sprintf("%011s", DecOct(0)); 
     1377            $v_typeflag = '2'; 
     1378            $v_linkname = readlink($p_filename); 
     1379            $v_size = sprintf("%011s", DecOct(0)); 
    11141380        } elseif (@is_dir($p_filename)) { 
    1115           $v_typeflag = "5"; 
    1116           $v_size = sprintf("%011s", DecOct(0)); 
     1381            $v_typeflag = "5"; 
     1382            $v_size = sprintf("%011s", DecOct(0)); 
    11171383        } else { 
    1118           $v_typeflag = '0'; 
    1119           clearstatcache(); 
    1120           $v_size = sprintf("%011s", DecOct($v_info['size'])); 
     1384            $v_typeflag = '0'; 
     1385            clearstatcache(); 
     1386            $v_size = sprintf("%011s", DecOct($v_info['size'])); 
    11211387        } 
    11221388 
     
    11241390 
    11251391        $v_version = ' '; 
    1126          
    1127         if (function_exists('posix_getpwuid')) 
    1128         { 
    1129           $userinfo = posix_getpwuid($v_info[4]); 
    1130           $groupinfo = posix_getgrgid($v_info[5]); 
    1131            
    1132           $v_uname = $userinfo['name']; 
    1133           $v_gname = $groupinfo['name']; 
    1134         } 
    1135         else 
    1136         { 
    1137           $v_uname = ''; 
    1138           $v_gname = ''; 
     1392 
     1393        if (function_exists('posix_getpwuid')) { 
     1394            $userinfo = posix_getpwuid($v_info[4]); 
     1395            $groupinfo = posix_getgrgid($v_info[5]); 
     1396 
     1397            $v_uname = $userinfo['name']; 
     1398            $v_gname = $groupinfo['name']; 
     1399        } else { 
     1400            $v_uname = ''; 
     1401            $v_gname = ''; 
    11391402        } 
    11401403 
     
    11451408        $v_prefix = ''; 
    11461409 
    1147         $v_binary_data_first = pack("a100a8a8a8a12a12", 
    1148                                     $v_reduce_filename, $v_perms, $v_uid, 
    1149                                     $v_gid, $v_size, $v_mtime); 
    1150         $v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", 
    1151                                    $v_typeflag, $v_linkname, $v_magic, 
    1152                                    $v_version, $v_uname, $v_gname, 
    1153                                    $v_devmajor, $v_devminor, $v_prefix, ''); 
     1410        $v_binary_data_first = pack( 
     1411            "a100a8a8a8a12a12", 
     1412            $v_reduce_filename, 
     1413            $v_perms, 
     1414            $v_uid, 
     1415            $v_gid, 
     1416            $v_size, 
     1417            $v_mtime 
     1418        ); 
     1419        $v_binary_data_last = pack( 
     1420            "a1a100a6a2a32a32a8a8a155a12", 
     1421            $v_typeflag, 
     1422            $v_linkname, 
     1423            $v_magic, 
     1424            $v_version, 
     1425            $v_uname, 
     1426            $v_gname, 
     1427            $v_devmajor, 
     1428            $v_devminor, 
     1429            $v_prefix, 
     1430            '' 
     1431        ); 
    11541432 
    11551433        // ----- Calculate the checksum 
    11561434        $v_checksum = 0; 
    11571435        // ..... First part of the header 
    1158         for ($i=0; $i<148; $i++) 
    1159             $v_checksum += ord(substr($v_binary_data_first,$i,1)); 
     1436        for ($i = 0; $i < 148; $i++) { 
     1437            $v_checksum += ord(substr($v_binary_data_first, $i, 1)); 
     1438        } 
    11601439        // ..... Ignore the checksum value and replace it by ' ' (space) 
    1161         for ($i=148; $i<156; $i++) 
     1440        for ($i = 148; $i < 156; $i++) { 
    11621441            $v_checksum += ord(' '); 
     1442        } 
    11631443        // ..... Last part of the header 
    1164         for ($i=156, $j=0; $i<512; $i++, $j++) 
    1165             $v_checksum += ord(substr($v_binary_data_last,$j,1)); 
     1444        for ($i = 156, $j = 0; $i < 512; $i++, $j++) { 
     1445            $v_checksum += ord(substr($v_binary_data_last, $j, 1)); 
     1446        } 
    11661447 
    11671448        // ----- Write the first 148 bytes of the header in the archive 
     
    11781459        return true; 
    11791460    } 
     1461 
    11801462    // }}} 
    11811463 
    11821464    // {{{ _writeHeaderBlock() 
    1183     function _writeHeaderBlock($p_filename, $p_size, $p_mtime=0, $p_perms=0, 
    1184                                $p_type='', $p_uid=0, $p_gid=0) 
    1185     { 
     1465    function _writeHeaderBlock( 
     1466        $p_filename, 
     1467        $p_size, 
     1468        $p_mtime = 0, 
     1469        $p_perms = 0, 
     1470        $p_type = '', 
     1471        $p_uid = 0, 
     1472        $p_gid = 0 
     1473    ) { 
    11861474        $p_filename = $this->_pathReduction($p_filename); 
    11871475 
    11881476        if (strlen($p_filename) > 99) { 
    1189           if (!$this->_writeLongHeader($p_filename)) 
    1190             return false; 
     1477            if (!$this->_writeLongHeader($p_filename)) { 
     1478                return false; 
     1479            } 
    11911480        } 
    11921481 
    11931482        if ($p_type == "5") { 
    1194           $v_size = sprintf("%011s", DecOct(0)); 
     1483            $v_size = sprintf("%011s", DecOct(0)); 
    11951484        } else { 
    1196           $v_size = sprintf("%011s", DecOct($p_size)); 
     1485            $v_size = sprintf("%011s", DecOct($p_size)); 
    11971486        } 
    11981487 
     
    12091498        $v_version = ' '; 
    12101499 
    1211         if (function_exists('posix_getpwuid')) 
    1212         { 
    1213           $userinfo = posix_getpwuid($p_uid); 
    1214           $groupinfo = posix_getgrgid($p_gid); 
    1215            
    1216           $v_uname = $userinfo['name']; 
    1217           $v_gname = $groupinfo['name']; 
    1218         } 
    1219         else 
    1220         { 
    1221           $v_uname = ''; 
    1222           $v_gname = ''; 
    1223         } 
    1224          
     1500        if (function_exists('posix_getpwuid')) { 
     1501            $userinfo = posix_getpwuid($p_uid); 
     1502            $groupinfo = posix_getgrgid($p_gid); 
     1503 
     1504            $v_uname = $userinfo['name']; 
     1505            $v_gname = $groupinfo['name']; 
     1506        } else { 
     1507            $v_uname = ''; 
     1508            $v_gname = ''; 
     1509        } 
     1510 
    12251511        $v_devmajor = ''; 
    12261512 
     
    12291515        $v_prefix = ''; 
    12301516 
    1231         $v_binary_data_first = pack("a100a8a8a8a12A12", 
    1232                                     $p_filename, $v_perms, $v_uid, $v_gid, 
    1233                                     $v_size, $v_mtime); 
    1234         $v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", 
    1235                                    $p_type, $v_linkname, $v_magic, 
    1236                                    $v_version, $v_uname, $v_gname, 
    1237                                    $v_devmajor, $v_devminor, $v_prefix, ''); 
     1517        $v_binary_data_first = pack( 
     1518            "a100a8a8a8a12A12", 
     1519            $p_filename, 
     1520            $v_perms, 
     1521            $v_uid, 
     1522            $v_gid, 
     1523            $v_size, 
     1524            $v_mtime 
     1525        ); 
     1526        $v_binary_data_last = pack( 
     1527            "a1a100a6a2a32a32a8a8a155a12", 
     1528            $p_type, 
     1529            $v_linkname, 
     1530            $v_magic, 
     1531            $v_version, 
     1532            $v_uname, 
     1533            $v_gname, 
     1534            $v_devmajor, 
     1535            $v_devminor, 
     1536            $v_prefix, 
     1537            '' 
     1538        ); 
    12381539 
    12391540        // ----- Calculate the checksum 
    12401541        $v_checksum = 0; 
    12411542        // ..... First part of the header 
    1242         for ($i=0; $i<148; $i++) 
    1243             $v_checksum += ord(substr($v_binary_data_first,$i,1)); 
     1543        for ($i = 0; $i < 148; $i++) { 
     1544            $v_checksum += ord(substr($v_binary_data_first, $i, 1)); 
     1545        } 
    12441546        // ..... Ignore the checksum value and replace it by ' ' (space) 
    1245         for ($i=148; $i<156; $i++) 
     1547        for ($i = 148; $i < 156; $i++) { 
    12461548            $v_checksum += ord(' '); 
     1549        } 
    12471550        // ..... Last part of the header 
    1248         for ($i=156, $j=0; $i<512; $i++, $j++) 
    1249             $v_checksum += ord(substr($v_binary_data_last,$j,1)); 
     1551        for ($i = 156, $j = 0; $i < 512; $i++, $j++) { 
     1552            $v_checksum += ord(substr($v_binary_data_last, $j, 1)); 
     1553        } 
    12501554 
    12511555        // ----- Write the first 148 bytes of the header in the archive 
     
    12621566        return true; 
    12631567    } 
     1568 
    12641569    // }}} 
    12651570 
     
    12871592        $v_prefix = ''; 
    12881593 
    1289         $v_binary_data_first = pack("a100a8a8a8a12a12", 
    1290                                     '././@LongLink', 0, 0, 0, $v_size, 0); 
    1291         $v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", 
    1292                                    $v_typeflag, $v_linkname, $v_magic, 
    1293                                    $v_version, $v_uname, $v_gname, 
    1294                                    $v_devmajor, $v_devminor, $v_prefix, ''); 
     1594        $v_binary_data_first = pack( 
     1595            "a100a8a8a8a12a12", 
     1596            '././@LongLink', 
     1597            0, 
     1598            0, 
     1599            0, 
     1600            $v_size, 
     1601            0 
     1602        ); 
     1603        $v_binary_data_last = pack( 
     1604            "a1a100a6a2a32a32a8a8a155a12", 
     1605            $v_typeflag, 
     1606            $v_linkname, 
     1607            $v_magic, 
     1608            $v_version, 
     1609            $v_uname, 
     1610            $v_gname, 
     1611            $v_devmajor, 
     1612            $v_devminor, 
     1613            $v_prefix, 
     1614            '' 
     1615        ); 
    12951616 
    12961617        // ----- Calculate the checksum 
    12971618        $v_checksum = 0; 
    12981619        // ..... First part of the header 
    1299         for ($i=0; $i<148; $i++) 
    1300             $v_checksum += ord(substr($v_binary_data_first,$i,1)); 
     1620        for ($i = 0; $i < 148; $i++) { 
     1621            $v_checksum += ord(substr($v_binary_data_first, $i, 1)); 
     1622        } 
    13011623        // ..... Ignore the checksum value and replace it by ' ' (space) 
    1302         for ($i=148; $i<156; $i++) 
     1624        for ($i = 148; $i < 156; $i++) { 
    13031625            $v_checksum += ord(' '); 
     1626        } 
    13041627        // ..... Last part of the header 
    1305         for ($i=156, $j=0; $i<512; $i++, $j++) 
    1306             $v_checksum += ord(substr($v_binary_data_last,$j,1)); 
     1628        for ($i = 156, $j = 0; $i < 512; $i++, $j++) { 
     1629            $v_checksum += ord(substr($v_binary_data_last, $j, 1)); 
     1630        } 
    13071631 
    13081632        // ----- Write the first 148 bytes of the header in the archive 
     
    13181642 
    13191643        // ----- Write the filename as content of the block 
    1320         $i=0; 
    1321         while (($v_buffer = substr($p_filename, (($i++)*512), 512)) != '') { 
     1644        $i = 0; 
     1645        while (($v_buffer = substr($p_filename, (($i++) * 512), 512)) != '') { 
    13221646            $v_binary_data = pack("a512", "$v_buffer"); 
    13231647            $this->_writeBlock($v_binary_data); 
     
    13261650        return true; 
    13271651    } 
     1652 
    13281653    // }}} 
    13291654 
     
    13311656    function _readHeader($v_binary_data, &$v_header) 
    13321657    { 
    1333         if (strlen($v_binary_data)==0) { 
     1658        if (strlen($v_binary_data) == 0) { 
    13341659            $v_header['filename'] = ''; 
    13351660            return true; 
     
    13381663        if (strlen($v_binary_data) != 512) { 
    13391664            $v_header['filename'] = ''; 
    1340             $this->_error('Invalid block size : '.strlen($v_binary_data)); 
     1665            $this->_error('Invalid block size : ' . strlen($v_binary_data)); 
    13411666            return false; 
    13421667        } 
     
    13481673        $v_checksum = 0; 
    13491674        // ..... First part of the header 
    1350         for ($i=0; $i<148; $i++) 
    1351             $v_checksum+=ord(substr($v_binary_data,$i,1)); 
     1675        for ($i = 0; $i < 148; $i++) { 
     1676            $v_checksum += ord(substr($v_binary_data, $i, 1)); 
     1677        } 
    13521678        // ..... Ignore the checksum value and replace it by ' ' (space) 
    1353         for ($i=148; $i<156; $i++) 
     1679        for ($i = 148; $i < 156; $i++) { 
    13541680            $v_checksum += ord(' '); 
     1681        } 
    13551682        // ..... Last part of the header 
    1356         for ($i=156; $i<512; $i++) 
    1357            $v_checksum+=ord(substr($v_binary_data,$i,1)); 
    1358  
    1359         if (version_compare(PHP_VERSION,"5.5.0-dev")<0) { 
     1683        for ($i = 156; $i < 512; $i++) { 
     1684            $v_checksum += ord(substr($v_binary_data, $i, 1)); 
     1685        } 
     1686 
     1687        if (version_compare(PHP_VERSION, "5.5.0-dev") < 0) { 
    13601688            $fmt = "a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/" . 
    1361                    "a8checksum/a1typeflag/a100link/a6magic/a2version/" . 
    1362                    "a32uname/a32gname/a8devmajor/a8devminor/a131prefix"; 
     1689                "a8checksum/a1typeflag/a100link/a6magic/a2version/" . 
     1690                "a32uname/a32gname/a8devmajor/a8devminor/a131prefix"; 
    13631691        } else { 
    13641692            $fmt = "Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/" . 
    1365                    "Z8checksum/Z1typeflag/Z100link/Z6magic/Z2version/" . 
    1366                    "Z32uname/Z32gname/Z8devmajor/Z8devminor/Z131prefix"; 
     1693                "Z8checksum/Z1typeflag/Z100link/Z6magic/Z2version/" . 
     1694                "Z32uname/Z32gname/Z8devmajor/Z8devminor/Z131prefix"; 
    13671695        } 
    13681696        $v_data = unpack($fmt, $v_binary_data); 
     
    13781706 
    13791707            // ----- Look for last block (empty block) 
    1380             if (($v_checksum == 256) && ($v_header['checksum'] == 0)) 
     1708            if (($v_checksum == 256) && ($v_header['checksum'] == 0)) { 
    13811709                return true; 
    1382  
    1383             $this->_error('Invalid checksum for file "'.$v_data['filename'] 
    1384                           .'" : '.$v_checksum.' calculated, ' 
    1385                           .$v_header['checksum'].' expected'); 
     1710            } 
     1711 
     1712            $this->_error( 
     1713                'Invalid checksum for file "' . $v_data['filename'] 
     1714                . '" : ' . $v_checksum . ' calculated, ' 
     1715                . $v_header['checksum'] . ' expected' 
     1716            ); 
    13861717            return false; 
    13871718        } 
     
    13901721        $v_header['filename'] = $v_data['filename']; 
    13911722        if ($this->_maliciousFilename($v_header['filename'])) { 
    1392             $this->_error('Malicious .tar detected, file "' . $v_header['filename'] . 
    1393                 '" will not install in desired directory tree'); 
     1723            $this->_error( 
     1724                'Malicious .tar detected, file "' . $v_header['filename'] . 
     1725                '" will not install in desired directory tree' 
     1726            ); 
    13941727            return false; 
    13951728        } 
     
    14001733        $v_header['mtime'] = OctDec(trim($v_data['mtime'])); 
    14011734        if (($v_header['typeflag'] = $v_data['typeflag']) == "5") { 
    1402           $v_header['size'] = 0; 
     1735            $v_header['size'] = 0; 
    14031736        } 
    14041737        $v_header['link'] = trim($v_data['link']); 
     
    14151748        return true; 
    14161749    } 
     1750 
    14171751    // }}} 
    14181752 
     
    14361770        return false; 
    14371771    } 
     1772 
    14381773    // }}} 
    14391774 
     
    14411776    function _readLongHeader(&$v_header) 
    14421777    { 
    1443       $v_filename = ''; 
    1444       $n = floor($v_header['size']/512); 
    1445       for ($i=0; $i<$n; $i++) { 
    1446         $v_content = $this->_readBlock(); 
    1447         $v_filename .= $v_content; 
    1448       } 
    1449       if (($v_header['size'] % 512) != 0) { 
    1450         $v_content = $this->_readBlock(); 
    1451         $v_filename .= trim($v_content); 
    1452       } 
    1453  
    1454       // ----- Read the next header 
    1455       $v_binary_data = $this->_readBlock(); 
    1456  
    1457       if (!$this->_readHeader($v_binary_data, $v_header)) 
    1458         return false; 
    1459  
    1460       $v_filename = trim($v_filename); 
    1461       $v_header['filename'] = $v_filename; 
     1778        $v_filename = ''; 
     1779        $n = floor($v_header['size'] / 512); 
     1780        for ($i = 0; $i < $n; $i++) { 
     1781            $v_content = $this->_readBlock(); 
     1782            $v_filename .= $v_content; 
     1783        } 
     1784        if (($v_header['size'] % 512) != 0) { 
     1785            $v_content = $this->_readBlock(); 
     1786            $v_filename .= trim($v_content); 
     1787        } 
     1788 
     1789        // ----- Read the next header 
     1790        $v_binary_data = $this->_readBlock(); 
     1791 
     1792        if (!$this->_readHeader($v_binary_data, $v_header)) { 
     1793            return false; 
     1794        } 
     1795 
     1796        $v_filename = trim($v_filename); 
     1797        $v_header['filename'] = $v_filename; 
    14621798        if ($this->_maliciousFilename($v_filename)) { 
    1463             $this->_error('Malicious .tar detected, file "' . $v_filename . 
    1464                 '" will not install in desired directory tree'); 
     1799            $this->_error( 
     1800                'Malicious .tar detected, file "' . $v_filename . 
     1801                '" will not install in desired directory tree' 
     1802            ); 
    14651803            return false; 
    1466       } 
    1467  
    1468       return true; 
    1469     } 
     1804        } 
     1805 
     1806        return true; 
     1807    } 
     1808 
    14701809    // }}} 
    14711810 
    14721811    // {{{ _extractInString() 
    14731812    /** 
    1474     * This method extract from the archive one file identified by $p_filename. 
    1475     * The return value is a string with the file content, or null on error. 
    1476     * 
    1477     * @param string $p_filename The path of the file to extract in a string. 
    1478     * 
    1479     * @return a string with the file content or null. 
    1480     * @access private 
    1481     */ 
     1813     * This method extract from the archive one file identified by $p_filename. 
     1814     * The return value is a string with the file content, or null on error. 
     1815     * 
     1816     * @param string $p_filename The path of the file to extract in a string. 
     1817     * 
     1818     * @return a string with the file content or null. 
     1819     * @access private 
     1820     */ 
    14821821    function _extractInString($p_filename) 
    14831822    { 
    14841823        $v_result_str = ""; 
    14851824 
    1486         While (strlen($v_binary_data = $this->_readBlock()) != 0) 
    1487         { 
    1488           if (!$this->_readHeader($v_binary_data, $v_header)) 
    1489             return null; 
    1490  
    1491           if ($v_header['filename'] == '') 
    1492             continue; 
    1493  
    1494           // ----- Look for long filename 
    1495           if ($v_header['typeflag'] == 'L') { 
    1496             if (!$this->_readLongHeader($v_header)) 
    1497               return null; 
    1498           } 
    1499  
    1500           if ($v_header['filename'] == $p_filename) { 
    1501               if ($v_header['typeflag'] == "5") { 
    1502                   $this->_error('Unable to extract in string a directory ' 
    1503                                 .'entry {'.$v_header['filename'].'}'); 
    1504                   return null; 
    1505               } else { 
    1506                   $n = floor($v_header['size']/512); 
    1507                   for ($i=0; $i<$n; $i++) { 
    1508                       $v_result_str .= $this->_readBlock(); 
    1509                   } 
    1510                   if (($v_header['size'] % 512) != 0) { 
    1511                       $v_content = $this->_readBlock(); 
    1512                       $v_result_str .= substr($v_content, 0, 
    1513                                               ($v_header['size'] % 512)); 
    1514                   } 
    1515                   return $v_result_str; 
    1516               } 
    1517           } else { 
    1518               $this->_jumpBlock(ceil(($v_header['size']/512))); 
    1519           } 
     1825        While (strlen($v_binary_data = $this->_readBlock()) != 0) { 
     1826            if (!$this->_readHeader($v_binary_data, $v_header)) { 
     1827                return null; 
     1828            } 
     1829 
     1830            if ($v_header['filename'] == '') { 
     1831                continue; 
     1832            } 
     1833 
     1834            // ----- Look for long filename 
     1835            if ($v_header['typeflag'] == 'L') { 
     1836                if (!$this->_readLongHeader($v_header)) { 
     1837                    return null; 
     1838                } 
     1839            } 
     1840 
     1841            if ($v_header['filename'] == $p_filename) { 
     1842                if ($v_header['typeflag'] == "5") { 
     1843                    $this->_error( 
     1844                        'Unable to extract in string a directory ' 
     1845                        . 'entry {' . $v_header['filename'] . '}' 
     1846                    ); 
     1847                    return null; 
     1848                } else { 
     1849                    $n = floor($v_header['size'] / 512); 
     1850                    for ($i = 0; $i < $n; $i++) { 
     1851                        $v_result_str .= $this->_readBlock(); 
     1852                    } 
     1853                    if (($v_header['size'] % 512) != 0) { 
     1854                        $v_content = $this->_readBlock(); 
     1855                        $v_result_str .= substr( 
     1856                            $v_content, 
     1857                            0, 
     1858                            ($v_header['size'] % 512) 
     1859                        ); 
     1860                    } 
     1861                    return $v_result_str; 
     1862                } 
     1863            } else { 
     1864                $this->_jumpBlock(ceil(($v_header['size'] / 512))); 
     1865            } 
    15201866        } 
    15211867 
    15221868        return null; 
    15231869    } 
     1870 
    15241871    // }}} 
    15251872 
    15261873    // {{{ _extractList() 
    1527     function _extractList($p_path, &$p_list_detail, $p_mode, 
    1528                           $p_file_list, $p_remove_path, $p_preserve=false) 
    1529     { 
    1530     $v_result=true; 
    1531     $v_nb = 0; 
    1532     $v_extract_all = true; 
    1533     $v_listing = false; 
    1534  
    1535     $p_path = $this->_translateWinPath($p_path, false); 
    1536     if ($p_path == '' || (substr($p_path, 0, 1) != '/' 
    1537         && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) { 
    1538       $p_path = "./".$p_path; 
    1539     } 
    1540     $p_remove_path = $this->_translateWinPath($p_remove_path); 
    1541  
    1542     // ----- Look for path to remove format (should end by /) 
    1543     if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) 
    1544       $p_remove_path .= '/'; 
    1545     $p_remove_path_size = strlen($p_remove_path); 
    1546  
    1547     switch ($p_mode) { 
    1548       case "complete" : 
     1874    function _extractList( 
     1875        $p_path, 
     1876        &$p_list_detail, 
     1877        $p_mode, 
     1878        $p_file_list, 
     1879        $p_remove_path, 
     1880        $p_preserve = false 
     1881    ) { 
     1882        $v_result = true; 
     1883        $v_nb = 0; 
    15491884        $v_extract_all = true; 
    15501885        $v_listing = false; 
    1551       break; 
    1552       case "partial" : 
    1553           $v_extract_all = false; 
    1554           $v_listing = false; 
    1555       break; 
    1556       case "list" : 
    1557           $v_extract_all = false; 
    1558           $v_listing = true; 
    1559       break; 
    1560       default : 
    1561         $this->_error('Invalid extract mode ('.$p_mode.')'); 
    1562         return false; 
    1563     } 
    1564  
    1565     clearstatcache(); 
    1566  
    1567     while (strlen($v_binary_data = $this->_readBlock()) != 0) 
    1568     { 
    1569       $v_extract_file = FALSE; 
    1570       $v_extraction_stopped = 0; 
    1571  
    1572       if (!$this->_readHeader($v_binary_data, $v_header)) 
    1573         return false; 
    1574  
    1575       if ($v_header['filename'] == '') { 
    1576         continue; 
    1577       } 
    1578  
    1579       // ----- Look for long filename 
    1580       if ($v_header['typeflag'] == 'L') { 
    1581         if (!$this->_readLongHeader($v_header)) 
    1582           return false; 
    1583       } 
    1584  
    1585       if ((!$v_extract_all) && (is_array($p_file_list))) { 
    1586         // ----- By default no unzip if the file is not found 
    1587         $v_extract_file = false; 
    1588  
    1589         for ($i=0; $i<sizeof($p_file_list); $i++) { 
    1590           // ----- Look if it is a directory 
    1591           if (substr($p_file_list[$i], -1) == '/') { 
    1592             // ----- Look if the directory is in the filename path 
    1593             if ((strlen($v_header['filename']) > strlen($p_file_list[$i])) 
    1594                 && (substr($v_header['filename'], 0, strlen($p_file_list[$i])) 
    1595                     == $p_file_list[$i])) { 
    1596               $v_extract_file = true; 
    1597               break; 
    1598             } 
    1599           } 
    1600  
    1601           // ----- It is a file, so compare the file names 
    1602           elseif ($p_file_list[$i] == $v_header['filename']) { 
    1603             $v_extract_file = true; 
    1604             break; 
    1605           } 
    1606         } 
    1607       } else { 
    1608         $v_extract_file = true; 
    1609       } 
    1610  
    1611       // ----- Look if this file need to be extracted 
    1612       if (($v_extract_file) && (!$v_listing)) 
    1613       { 
    1614         if (($p_remove_path != '') 
    1615             && (substr($v_header['filename'].'/', 0, $p_remove_path_size) 
    1616                 == $p_remove_path)) { 
    1617           $v_header['filename'] = substr($v_header['filename'], 
    1618                                          $p_remove_path_size); 
    1619           if( $v_header['filename'] == '' ){ 
    1620             continue; 
    1621           } 
    1622         } 
    1623         if (($p_path != './') && ($p_path != '/')) { 
    1624           while (substr($p_path, -1) == '/') 
    1625             $p_path = substr($p_path, 0, strlen($p_path)-1); 
    1626  
    1627           if (substr($v_header['filename'], 0, 1) == '/') 
    1628               $v_header['filename'] = $p_path.$v_header['filename']; 
    1629           else 
    1630             $v_header['filename'] = $p_path.'/'.$v_header['filename']; 
    1631         } 
    1632         if (file_exists($v_header['filename'])) { 
    1633           if (   (@is_dir($v_header['filename'])) 
    1634               && ($v_header['typeflag'] == '')) { 
    1635             $this->_error('File '.$v_header['filename'] 
    1636                           .' already exists as a directory'); 
    1637             return false; 
    1638           } 
    1639           if (   ($this->_isArchive($v_header['filename'])) 
    1640               && ($v_header['typeflag'] == "5")) { 
    1641             $this->_error('Directory '.$v_header['filename'] 
    1642                           .' already exists as a file'); 
    1643             return false; 
    1644           } 
    1645           if (!is_writeable($v_header['filename'])) { 
    1646             $this->_error('File '.$v_header['filename'] 
    1647                           .' already exists and is write protected'); 
    1648             return false; 
    1649           } 
    1650           if (filemtime($v_header['filename']) > $v_header['mtime']) { 
    1651             // To be completed : An error or silent no replace ? 
    1652           } 
    1653         } 
    1654  
    1655         // ----- Check the directory availability and create it if necessary 
    1656         elseif (($v_result 
    1657                  = $this->_dirCheck(($v_header['typeflag'] == "5" 
    1658                                     ?$v_header['filename'] 
    1659                                     :dirname($v_header['filename'])))) != 1) { 
    1660             $this->_error('Unable to create path for '.$v_header['filename']); 
    1661             return false; 
    1662         } 
    1663  
    1664         if ($v_extract_file) { 
    1665           if ($v_header['typeflag'] == "5") { 
    1666             if (!@file_exists($v_header['filename'])) { 
    1667                 if (!@mkdir($v_header['filename'], 0777)) { 
    1668                     $this->_error('Unable to create directory {' 
    1669                                   .$v_header['filename'].'}'); 
     1886 
     1887        $p_path = $this->_translateWinPath($p_path, false); 
     1888        if ($p_path == '' || (substr($p_path, 0, 1) != '/' 
     1889                && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':')) 
     1890        ) { 
     1891            $p_path = "./" . $p_path; 
     1892        } 
     1893        $p_remove_path = $this->_translateWinPath($p_remove_path); 
     1894 
     1895        // ----- Look for path to remove format (should end by /) 
     1896        if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) { 
     1897            $p_remove_path .= '/'; 
     1898        } 
     1899        $p_remove_path_size = strlen($p_remove_path); 
     1900 
     1901        switch ($p_mode) { 
     1902            case "complete" : 
     1903                $v_extract_all = true; 
     1904                $v_listing = false; 
     1905                break; 
     1906            case "partial" : 
     1907                $v_extract_all = false; 
     1908                $v_listing = false; 
     1909                break; 
     1910            case "list" : 
     1911                $v_extract_all = false; 
     1912                $v_listing = true; 
     1913                break; 
     1914            default : 
     1915                $this->_error('Invalid extract mode (' . $p_mode . ')'); 
     1916                return false; 
     1917        } 
     1918 
     1919        clearstatcache(); 
     1920 
     1921        while (strlen($v_binary_data = $this->_readBlock()) != 0) { 
     1922            $v_extract_file = false; 
     1923            $v_extraction_stopped = 0; 
     1924 
     1925            if (!$this->_readHeader($v_binary_data, $v_header)) { 
     1926                return false; 
     1927            } 
     1928 
     1929            if ($v_header['filename'] == '') { 
     1930                continue; 
     1931            } 
     1932 
     1933            // ----- Look for long filename 
     1934            if ($v_header['typeflag'] == 'L') { 
     1935                if (!$this->_readLongHeader($v_header)) { 
    16701936                    return false; 
    16711937                } 
    16721938            } 
    1673           } elseif ($v_header['typeflag'] == "2") { 
    1674               if (@file_exists($v_header['filename'])) { 
    1675                   @unlink($v_header['filename']); 
    1676               } 
    1677               if (!@symlink($v_header['link'], $v_header['filename'])) { 
    1678                   $this->_error('Unable to extract symbolic link {' 
    1679                                 .$v_header['filename'].'}'); 
    1680                   return false; 
    1681               } 
    1682           } else { 
    1683               if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { 
    1684                   $this->_error('Error while opening {'.$v_header['filename'] 
    1685                                 .'} in write binary mode'); 
    1686                   return false; 
    1687               } else { 
    1688                   $n = floor($v_header['size']/512); 
    1689                   for ($i=0; $i<$n; $i++) { 
    1690                       $v_content = $this->_readBlock(); 
    1691                       fwrite($v_dest_file, $v_content, 512); 
    1692                   } 
    1693             if (($v_header['size'] % 512) != 0) { 
    1694               $v_content = $this->_readBlock(); 
    1695               fwrite($v_dest_file, $v_content, ($v_header['size'] % 512)); 
    1696             } 
    1697  
    1698             @fclose($v_dest_file); 
    1699              
    1700             if ($p_preserve) { 
    1701                 @chown($v_header['filename'], $v_header['uid']); 
    1702                 @chgrp($v_header['filename'], $v_header['gid']); 
    1703             } 
    1704  
    1705             // ----- Change the file mode, mtime 
    1706             @touch($v_header['filename'], $v_header['mtime']); 
    1707             if ($v_header['mode'] & 0111) { 
    1708                 // make file executable, obey umask 
    1709                 $mode = fileperms($v_header['filename']) | (~umask() & 0111); 
    1710                 @chmod($v_header['filename'], $mode); 
    1711             } 
    1712           } 
    1713  
    1714           // ----- Check the file size 
    1715           clearstatcache(); 
    1716           if (!is_file($v_header['filename'])) { 
    1717               $this->_error('Extracted file '.$v_header['filename'] 
    1718                             .'does not exist. Archive may be corrupted.'); 
    1719               return false; 
    1720           } 
    1721            
    1722           $filesize = filesize($v_header['filename']); 
    1723           if ($filesize != $v_header['size']) { 
    1724               $this->_error('Extracted file '.$v_header['filename'] 
    1725                             .' does not have the correct file size \'' 
    1726                             .$filesize 
    1727                             .'\' ('.$v_header['size'] 
    1728                             .' expected). Archive may be corrupted.'); 
    1729               return false; 
    1730           } 
    1731           } 
    1732         } else { 
    1733           $this->_jumpBlock(ceil(($v_header['size']/512))); 
    1734         } 
    1735       } else { 
    1736           $this->_jumpBlock(ceil(($v_header['size']/512))); 
    1737       } 
    1738  
    1739       /* TBC : Seems to be unused ... 
    1740       if ($this->_compress) 
    1741         $v_end_of_file = @gzeof($this->_file); 
    1742       else 
    1743         $v_end_of_file = @feof($this->_file); 
    1744         */ 
    1745  
    1746       if ($v_listing || $v_extract_file || $v_extraction_stopped) { 
    1747         // ----- Log extracted files 
    1748         if (($v_file_dir = dirname($v_header['filename'])) 
    1749             == $v_header['filename']) 
    1750           $v_file_dir = ''; 
    1751         if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) 
    1752           $v_file_dir = '/'; 
    1753  
    1754         $p_list_detail[$v_nb++] = $v_header; 
    1755         if (is_array($p_file_list) && (count($p_list_detail) == count($p_file_list))) { 
    1756             return true; 
    1757         } 
    1758       } 
    1759     } 
     1939 
     1940            // ignore extended / pax headers 
     1941            if ($v_header['typeflag'] == 'x' || $v_header['typeflag'] == 'g') { 
     1942                $this->_jumpBlock(ceil(($v_header['size'] / 512))); 
     1943                continue; 
     1944            } 
     1945 
     1946            if ((!$v_extract_all) && (is_array($p_file_list))) { 
     1947                // ----- By default no unzip if the file is not found 
     1948                $v_extract_file = false; 
     1949 
     1950                for ($i = 0; $i < sizeof($p_file_list); $i++) { 
     1951                    // ----- Look if it is a directory 
     1952                    if (substr($p_file_list[$i], -1) == '/') { 
     1953                        // ----- Look if the directory is in the filename path 
     1954                        if ((strlen($v_header['filename']) > strlen($p_file_list[$i])) 
     1955                            && (substr($v_header['filename'], 0, strlen($p_file_list[$i])) 
     1956                                == $p_file_list[$i]) 
     1957                        ) { 
     1958                            $v_extract_file = true; 
     1959                            break; 
     1960                        } 
     1961                    } // ----- It is a file, so compare the file names 
     1962                    elseif ($p_file_list[$i] == $v_header['filename']) { 
     1963                        $v_extract_file = true; 
     1964                        break; 
     1965                    } 
     1966                } 
     1967            } else { 
     1968                $v_extract_file = true; 
     1969            } 
     1970 
     1971            // ----- Look if this file need to be extracted 
     1972            if (($v_extract_file) && (!$v_listing)) { 
     1973                if (($p_remove_path != '') 
     1974                    && (substr($v_header['filename'] . '/', 0, $p_remove_path_size) 
     1975                        == $p_remove_path) 
     1976                ) { 
     1977                    $v_header['filename'] = substr( 
     1978                        $v_header['filename'], 
     1979                        $p_remove_path_size 
     1980                    ); 
     1981                    if ($v_header['filename'] == '') { 
     1982                        continue; 
     1983                    } 
     1984                } 
     1985                if (($p_path != './') && ($p_path != '/')) { 
     1986                    while (substr($p_path, -1) == '/') { 
     1987                        $p_path = substr($p_path, 0, strlen($p_path) - 1); 
     1988                    } 
     1989 
     1990                    if (substr($v_header['filename'], 0, 1) == '/') { 
     1991                        $v_header['filename'] = $p_path . $v_header['filename']; 
     1992                    } else { 
     1993                        $v_header['filename'] = $p_path . '/' . $v_header['filename']; 
     1994                    } 
     1995                } 
     1996                if (file_exists($v_header['filename'])) { 
     1997                    if ((@is_dir($v_header['filename'])) 
     1998                        && ($v_header['typeflag'] == '') 
     1999                    ) { 
     2000                        $this->_error( 
     2001                            'File ' . $v_header['filename'] 
     2002                            . ' already exists as a directory' 
     2003                        ); 
     2004                        return false; 
     2005                    } 
     2006                    if (($this->_isArchive($v_header['filename'])) 
     2007                        && ($v_header['typeflag'] == "5") 
     2008                    ) { 
     2009                        $this->_error( 
     2010                            'Directory ' . $v_header['filename'] 
     2011                            . ' already exists as a file' 
     2012                        ); 
     2013                        return false; 
     2014                    } 
     2015                    if (!is_writeable($v_header['filename'])) { 
     2016                        $this->_error( 
     2017                            'File ' . $v_header['filename'] 
     2018                            . ' already exists and is write protected' 
     2019                        ); 
     2020                        return false; 
     2021                    } 
     2022                    if (filemtime($v_header['filename']) > $v_header['mtime']) { 
     2023                        // To be completed : An error or silent no replace ? 
     2024                    } 
     2025                } // ----- Check the directory availability and create it if necessary 
     2026                elseif (($v_result 
     2027                        = $this->_dirCheck( 
     2028                        ($v_header['typeflag'] == "5" 
     2029                            ? $v_header['filename'] 
     2030                            : dirname($v_header['filename'])) 
     2031                    )) != 1 
     2032                ) { 
     2033                    $this->_error('Unable to create path for ' . $v_header['filename']); 
     2034                    return false; 
     2035                } 
     2036 
     2037                if ($v_extract_file) { 
     2038                    if ($v_header['typeflag'] == "5") { 
     2039                        if (!@file_exists($v_header['filename'])) { 
     2040                            if (!@mkdir($v_header['filename'], 0777)) { 
     2041                                $this->_error( 
     2042                                    'Unable to create directory {' 
     2043                                    . $v_header['filename'] . '}' 
     2044                                ); 
     2045                                return false; 
     2046                            } 
     2047                        } 
     2048                    } elseif ($v_header['typeflag'] == "2") { 
     2049                        if (@file_exists($v_header['filename'])) { 
     2050                            @unlink($v_header['filename']); 
     2051                        } 
     2052                        if (!@symlink($v_header['link'], $v_header['filename'])) { 
     2053                            $this->_error( 
     2054                                'Unable to extract symbolic link {' 
     2055                                . $v_header['filename'] . '}' 
     2056                            ); 
     2057                            return false; 
     2058                        } 
     2059                    } else { 
     2060                        if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { 
     2061                            $this->_error( 
     2062                                'Error while opening {' . $v_header['filename'] 
     2063                                . '} in write binary mode' 
     2064                            ); 
     2065                            return false; 
     2066                        } else { 
     2067                            $n = floor($v_header['size'] / 512); 
     2068                            for ($i = 0; $i < $n; $i++) { 
     2069                                $v_content = $this->_readBlock(); 
     2070                                fwrite($v_dest_file, $v_content, 512); 
     2071                            } 
     2072                            if (($v_header['size'] % 512) != 0) { 
     2073                                $v_content = $this->_readBlock(); 
     2074                                fwrite($v_dest_file, $v_content, ($v_header['size'] % 512)); 
     2075                            } 
     2076 
     2077                            @fclose($v_dest_file); 
     2078 
     2079                            if ($p_preserve) { 
     2080                                @chown($v_header['filename'], $v_header['uid']); 
     2081                                @chgrp($v_header['filename'], $v_header['gid']); 
     2082                            } 
     2083 
     2084                            // ----- Change the file mode, mtime 
     2085                            @touch($v_header['filename'], $v_header['mtime']); 
     2086                            if ($v_header['mode'] & 0111) { 
     2087                                // make file executable, obey umask 
     2088                                $mode = fileperms($v_header['filename']) | (~umask() & 0111); 
     2089                                @chmod($v_header['filename'], $mode); 
     2090                            } 
     2091                        } 
     2092 
     2093                        // ----- Check the file size 
     2094                        clearstatcache(); 
     2095                        if (!is_file($v_header['filename'])) { 
     2096                            $this->_error( 
     2097                                'Extracted file ' . $v_header['filename'] 
     2098                                . 'does not exist. Archive may be corrupted.' 
     2099                            ); 
     2100                            return false; 
     2101                        } 
     2102 
     2103                        $filesize = filesize($v_header['filename']); 
     2104                        if ($filesize != $v_header['size']) { 
     2105                            $this->_error( 
     2106                                'Extracted file ' . $v_header['filename'] 
     2107                                . ' does not have the correct file size \'' 
     2108                                . $filesize 
     2109                                . '\' (' . $v_header['size'] 
     2110                                . ' expected). Archive may be corrupted.' 
     2111                            ); 
     2112                            return false; 
     2113                        } 
     2114                    } 
     2115                } else { 
     2116                    $this->_jumpBlock(ceil(($v_header['size'] / 512))); 
     2117                } 
     2118            } else { 
     2119                $this->_jumpBlock(ceil(($v_header['size'] / 512))); 
     2120            } 
     2121 
     2122            /* TBC : Seems to be unused ... 
     2123            if ($this->_compress) 
     2124              $v_end_of_file = @gzeof($this->_file); 
     2125            else 
     2126              $v_end_of_file = @feof($this->_file); 
     2127              */ 
     2128 
     2129            if ($v_listing || $v_extract_file || $v_extraction_stopped) { 
     2130                // ----- Log extracted files 
     2131                if (($v_file_dir = dirname($v_header['filename'])) 
     2132                    == $v_header['filename'] 
     2133                ) { 
     2134                    $v_file_dir = ''; 
     2135                } 
     2136                if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) { 
     2137                    $v_file_dir = '/'; 
     2138                } 
     2139 
     2140                $p_list_detail[$v_nb++] = $v_header; 
     2141                if (is_array($p_file_list) && (count($p_list_detail) == count($p_file_list))) { 
     2142                    return true; 
     2143                } 
     2144            } 
     2145        } 
    17602146 
    17612147        return true; 
    17622148    } 
     2149 
    17632150    // }}} 
    17642151 
     
    17662153    function _openAppend() 
    17672154    { 
    1768         if (filesize($this->_tarname) == 0) 
    1769           return $this->_openWrite(); 
     2155        if (filesize($this->_tarname) == 0) { 
     2156            return $this->_openWrite(); 
     2157        } 
    17702158 
    17712159        if ($this->_compress) { 
    17722160            $this->_close(); 
    17732161 
    1774             if (!@rename($this->_tarname, $this->_tarname.".tmp")) { 
    1775                 $this->_error('Error while renaming \''.$this->_tarname 
    1776                               .'\' to temporary file \''.$this->_tarname 
    1777                               .'.tmp\''); 
     2162            if (!@rename($this->_tarname, $this->_tarname . ".tmp")) { 
     2163                $this->_error( 
     2164                    'Error while renaming \'' . $this->_tarname 
     2165                    . '\' to temporary file \'' . $this->_tarname 
     2166                    . '.tmp\'' 
     2167                ); 
    17782168                return false; 
    17792169            } 
    17802170 
    1781             if ($this->_compress_type == 'gz') 
    1782                 $v_temp_tar = @gzopen($this->_tarname.".tmp", "rb"); 
    1783             elseif ($this->_compress_type == 'bz2') 
    1784                 $v_temp_tar = @bzopen($this->_tarname.".tmp", "r"); 
     2171            if ($this->_compress_type == 'gz') { 
     2172                $v_temp_tar = @gzopen($this->_tarname . ".tmp", "rb"); 
     2173            } elseif ($this->_compress_type == 'bz2') { 
     2174                $v_temp_tar = @bzopen($this->_tarname . ".tmp", "r"); 
     2175            } elseif ($this->_compress_type == 'lzma2') { 
     2176                $v_temp_tar = @xzopen($this->_tarname . ".tmp", "r"); 
     2177            } 
     2178 
    17852179 
    17862180            if ($v_temp_tar == 0) { 
    1787                 $this->_error('Unable to open file \''.$this->_tarname 
    1788                               .'.tmp\' in binary read mode'); 
    1789                 @rename($this->_tarname.".tmp", $this->_tarname); 
     2181                $this->_error( 
     2182                    'Unable to open file \'' . $this->_tarname 
     2183                    . '.tmp\' in binary read mode' 
     2184                ); 
     2185                @rename($this->_tarname . ".tmp", $this->_tarname); 
    17902186                return false; 
    17912187            } 
    17922188 
    17932189            if (!$this->_openWrite()) { 
    1794                 @rename($this->_tarname.".tmp", $this->_tarname); 
     2190                @rename($this->_tarname . ".tmp", $this->_tarname); 
    17952191                return false; 
    17962192            } 
     
    17982194            if ($this->_compress_type == 'gz') { 
    17992195                $end_blocks = 0; 
    1800                  
     2196 
    18012197                while (!@gzeof($v_temp_tar)) { 
    18022198                    $v_buffer = @gzread($v_temp_tar, 512); 
     
    18172213 
    18182214                @gzclose($v_temp_tar); 
    1819             } 
    1820             elseif ($this->_compress_type == 'bz2') { 
     2215            } elseif ($this->_compress_type == 'bz2') { 
    18212216                $end_blocks = 0; 
    1822                  
     2217 
    18232218                while (strlen($v_buffer = @bzread($v_temp_tar, 512)) > 0) { 
    18242219                    if ($v_buffer == ARCHIVE_TAR_END_BLOCK || strlen($v_buffer) == 0) { 
     
    18382233 
    18392234                @bzclose($v_temp_tar); 
    1840             } 
    1841  
    1842             if (!@unlink($this->_tarname.".tmp")) { 
    1843                 $this->_error('Error while deleting temporary file \'' 
    1844                               .$this->_tarname.'.tmp\''); 
     2235            } elseif ($this->_compress_type == 'lzma2') { 
     2236                $end_blocks = 0; 
     2237 
     2238                while (strlen($v_buffer = @xzread($v_temp_tar, 512)) > 0) { 
     2239                    if ($v_buffer == ARCHIVE_TAR_END_BLOCK || strlen($v_buffer) == 0) { 
     2240                        $end_blocks++; 
     2241                        // do not copy end blocks, we will re-make them 
     2242                        // after appending 
     2243                        continue; 
     2244                    } elseif ($end_blocks > 0) { 
     2245                        for ($i = 0; $i < $end_blocks; $i++) { 
     2246                            $this->_writeBlock(ARCHIVE_TAR_END_BLOCK); 
     2247                        } 
     2248                        $end_blocks = 0; 
     2249                    } 
     2250                    $v_binary_data = pack("a512", $v_buffer); 
     2251                    $this->_writeBlock($v_binary_data); 
     2252                } 
     2253 
     2254                @xzclose($v_temp_tar); 
     2255            } 
     2256 
     2257            if (!@unlink($this->_tarname . ".tmp")) { 
     2258                $this->_error( 
     2259                    'Error while deleting temporary file \'' 
     2260                    . $this->_tarname . '.tmp\'' 
     2261                ); 
    18452262            } 
    18462263 
    18472264        } else { 
    18482265            // ----- For not compressed tar, just add files before the last 
    1849             //       one or two 512 bytes block 
    1850             if (!$this->_openReadWrite()) 
    1851                return false; 
     2266            //       one or two 512 bytes block 
     2267            if (!$this->_openReadWrite()) { 
     2268                return false; 
     2269            } 
    18522270 
    18532271            clearstatcache(); 
     
    18602278            if (fread($this->_file, 512) == ARCHIVE_TAR_END_BLOCK) { 
    18612279                fseek($this->_file, $v_size - 1024); 
    1862             } 
    1863             elseif (fread($this->_file, 512) == ARCHIVE_TAR_END_BLOCK) { 
     2280            } elseif (fread($this->_file, 512) == ARCHIVE_TAR_END_BLOCK) { 
    18642281                fseek($this->_file, $v_size - 512); 
    18652282            } 
     
    18682285        return true; 
    18692286    } 
     2287 
    18702288    // }}} 
    18712289 
    18722290    // {{{ _append() 
    1873     function _append($p_filelist, $p_add_dir='', $p_remove_dir='') 
    1874     { 
    1875         if (!$this->_openAppend()) 
     2291    function _append($p_filelist, $p_add_dir = '', $p_remove_dir = '') 
     2292    { 
     2293        if (!$this->_openAppend()) { 
    18762294            return false; 
    1877  
    1878         if ($this->_addList($p_filelist, $p_add_dir, $p_remove_dir)) 
    1879            $this->_writeFooter(); 
     2295        } 
     2296 
     2297        if ($this->_addList($p_filelist, $p_add_dir, $p_remove_dir)) { 
     2298            $this->_writeFooter(); 
     2299        } 
    18802300 
    18812301        $this->_close(); 
     
    18832303        return true; 
    18842304    } 
     2305 
    18852306    // }}} 
    18862307 
     
    18982319    { 
    18992320        clearstatcache(); 
    1900         if ((@is_dir($p_dir)) || ($p_dir == '')) 
     2321        if ((@is_dir($p_dir)) || ($p_dir == '')) { 
    19012322            return true; 
     2323        } 
    19022324 
    19032325        $p_parent_dir = dirname($p_dir); 
     
    19052327        if (($p_parent_dir != $p_dir) && 
    19062328            ($p_parent_dir != '') && 
    1907             (!$this->_dirCheck($p_parent_dir))) 
    1908              return false; 
     2329            (!$this->_dirCheck($p_parent_dir)) 
     2330        ) { 
     2331            return false; 
     2332        } 
    19092333 
    19102334        if (!@mkdir($p_dir, 0777)) { 
     
    19412365 
    19422366            // ----- Study directories from last to first 
    1943             for ($i=sizeof($v_list)-1; $i>=0; $i--) { 
     2367            for ($i = sizeof($v_list) - 1; $i >= 0; $i--) { 
    19442368                // ----- Look for current path 
    19452369                if ($v_list[$i] == ".") { 
    19462370                    // ----- Ignore this directory 
    19472371                    // Should be the first $i=0, but no check is done 
    1948                 } 
    1949                 else if ($v_list[$i] == "..") { 
    1950                     // ----- Ignore it and ignore the $i-1 
    1951                     $i--; 
    1952                 } 
    1953                 else if (   ($v_list[$i] == '') 
    1954                          && ($i!=(sizeof($v_list)-1)) 
    1955                          && ($i!=0)) { 
    1956                     // ----- Ignore only the double '//' in path, 
    1957                     // but not the first and last / 
    19582372                } else { 
    1959                     $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?'/' 
    1960                                 .$v_result:''); 
    1961                 } 
    1962             } 
    1963         } 
    1964          
     2373                    if ($v_list[$i] == "..") { 
     2374                        // ----- Ignore it and ignore the $i-1 
     2375                        $i--; 
     2376                    } else { 
     2377                        if (($v_list[$i] == '') 
     2378                            && ($i != (sizeof($v_list) - 1)) 
     2379                            && ($i != 0) 
     2380                        ) { 
     2381                            // ----- Ignore only the double '//' in path, 
     2382                            // but not the first and last / 
     2383                        } else { 
     2384                            $v_result = $v_list[$i] . ($i != (sizeof($v_list) - 1) ? '/' 
     2385                                    . $v_result : ''); 
     2386                        } 
     2387                    } 
     2388                } 
     2389            } 
     2390        } 
     2391 
    19652392        if (defined('OS_WINDOWS') && OS_WINDOWS) { 
    19662393            $v_result = strtr($v_result, '\\', '/'); 
    19672394        } 
    1968          
     2395 
    19692396        return $v_result; 
    19702397    } 
     
    19732400 
    19742401    // {{{ _translateWinPath() 
    1975     function _translateWinPath($p_path, $p_remove_disk_letter=true) 
    1976     { 
    1977       if (defined('OS_WINDOWS') && OS_WINDOWS) { 
    1978           // ----- Look for potential disk letter 
    1979           if (   ($p_remove_disk_letter) 
    1980               && (($v_position = strpos($p_path, ':')) != false)) { 
    1981               $p_path = substr($p_path, $v_position+1); 
    1982           } 
    1983           // ----- Change potential windows directory separator 
    1984           if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { 
    1985               $p_path = strtr($p_path, '\\', '/'); 
    1986           } 
    1987       } 
    1988       return $p_path; 
     2402    function _translateWinPath($p_path, $p_remove_disk_letter = true) 
     2403    { 
     2404        if (defined('OS_WINDOWS') && OS_WINDOWS) { 
     2405            // ----- Look for potential disk letter 
     2406            if (($p_remove_disk_letter) 
     2407                && (($v_position = strpos($p_path, ':')) != false) 
     2408            ) { 
     2409                $p_path = substr($p_path, $v_position + 1); 
     2410            } 
     2411            // ----- Change potential windows directory separator 
     2412            if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { 
     2413                $p_path = strtr($p_path, '\\', '/'); 
     2414            } 
     2415        } 
     2416        return $p_path; 
    19892417    } 
    19902418    // }}} 
    19912419 
    19922420} 
     2421 
    19932422?> 
Note: See TracChangeset for help on using the changeset viewer.