Commit 96deb1602f89319ab7b6df597689bc2e7e29ddb2
1 parent
67a8fda4
Fixed line endings
Committed by: Megan Watson Reviewed by: Prince Mbekwa
Showing
1 changed file
with
87 additions
and
87 deletions
thirdparty/peclzip/pclzip.lib.php
| ... | ... | @@ -27,7 +27,7 @@ |
| 27 | 27 | |
| 28 | 28 | // ----- Constants |
| 29 | 29 | define( 'PCLZIP_READ_BLOCK_SIZE', 2048 ); |
| 30 | - | |
| 30 | + | |
| 31 | 31 | // ----- File list separator |
| 32 | 32 | // In version 1.x of PclZip, the separator for file list is a space |
| 33 | 33 | // (which is not a very smart choice, specifically for windows paths !). |
| ... | ... | @@ -126,7 +126,7 @@ |
| 126 | 126 | // which is not correctly supported by PHP ... |
| 127 | 127 | //define( 'PCLZIP_OPT_CRYPT', 77018 ); |
| 128 | 128 | define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 ); |
| 129 | - | |
| 129 | + | |
| 130 | 130 | // ----- File description attributes |
| 131 | 131 | define( 'PCLZIP_ATT_FILE_NAME', 79001 ); |
| 132 | 132 | define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 ); |
| ... | ... | @@ -169,7 +169,7 @@ |
| 169 | 169 | // ----- Internal error handling |
| 170 | 170 | var $error_code = 1; |
| 171 | 171 | var $error_string = ''; |
| 172 | - | |
| 172 | + | |
| 173 | 173 | // ----- Current status of the magic_quotes_runtime |
| 174 | 174 | // This value store the php configuration for magic_quotes |
| 175 | 175 | // The class can then disable the magic_quotes and reset it after |
| ... | ... | @@ -315,16 +315,16 @@ |
| 315 | 315 | $v_att_list = array(); |
| 316 | 316 | $v_filedescr_list = array(); |
| 317 | 317 | $p_result_list = array(); |
| 318 | - | |
| 318 | + | |
| 319 | 319 | // ----- Look if the $p_filelist is really an array |
| 320 | 320 | if (is_array($p_filelist)) { |
| 321 | - | |
| 321 | + | |
| 322 | 322 | // ----- Look if the first element is also an array |
| 323 | 323 | // This will mean that this is a file description entry |
| 324 | 324 | if (isset($p_filelist[0]) && is_array($p_filelist[0])) { |
| 325 | 325 | $v_att_list = $p_filelist; |
| 326 | 326 | } |
| 327 | - | |
| 327 | + | |
| 328 | 328 | // ----- The list is a list of string names |
| 329 | 329 | else { |
| 330 | 330 | $v_string_list = $p_filelist; |
| ... | ... | @@ -343,7 +343,7 @@ |
| 343 | 343 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); |
| 344 | 344 | return 0; |
| 345 | 345 | } |
| 346 | - | |
| 346 | + | |
| 347 | 347 | // ----- Reformat the string list |
| 348 | 348 | if (sizeof($v_string_list) != 0) { |
| 349 | 349 | foreach ($v_string_list as $v_string) { |
| ... | ... | @@ -355,7 +355,7 @@ |
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | - | |
| 358 | + | |
| 359 | 359 | // ----- For each file in the list check the attributes |
| 360 | 360 | $v_supported_attributes |
| 361 | 361 | = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
| ... | ... | @@ -505,16 +505,16 @@ |
| 505 | 505 | $v_att_list = array(); |
| 506 | 506 | $v_filedescr_list = array(); |
| 507 | 507 | $p_result_list = array(); |
| 508 | - | |
| 508 | + | |
| 509 | 509 | // ----- Look if the $p_filelist is really an array |
| 510 | 510 | if (is_array($p_filelist)) { |
| 511 | - | |
| 511 | + | |
| 512 | 512 | // ----- Look if the first element is also an array |
| 513 | 513 | // This will mean that this is a file description entry |
| 514 | 514 | if (isset($p_filelist[0]) && is_array($p_filelist[0])) { |
| 515 | 515 | $v_att_list = $p_filelist; |
| 516 | 516 | } |
| 517 | - | |
| 517 | + | |
| 518 | 518 | // ----- The list is a list of string names |
| 519 | 519 | else { |
| 520 | 520 | $v_string_list = $p_filelist; |
| ... | ... | @@ -533,14 +533,14 @@ |
| 533 | 533 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); |
| 534 | 534 | return 0; |
| 535 | 535 | } |
| 536 | - | |
| 536 | + | |
| 537 | 537 | // ----- Reformat the string list |
| 538 | 538 | if (sizeof($v_string_list) != 0) { |
| 539 | 539 | foreach ($v_string_list as $v_string) { |
| 540 | 540 | $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | - | |
| 543 | + | |
| 544 | 544 | // ----- For each file in the list check the attributes |
| 545 | 545 | $v_supported_attributes |
| 546 | 546 | = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
| ... | ... | @@ -990,7 +990,7 @@ |
| 990 | 990 | // Options : |
| 991 | 991 | // PCLZIP_OPT_BY_INDEX : |
| 992 | 992 | // PCLZIP_OPT_BY_NAME : |
| 993 | - // PCLZIP_OPT_BY_EREG : | |
| 993 | + // PCLZIP_OPT_BY_EREG : | |
| 994 | 994 | // PCLZIP_OPT_BY_PREG : |
| 995 | 995 | // Return Values : |
| 996 | 996 | // 0 on failure, |
| ... | ... | @@ -1065,7 +1065,7 @@ |
| 1065 | 1065 | function deleteByIndex($p_index) |
| 1066 | 1066 | { |
| 1067 | 1067 | //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'"); |
| 1068 | - | |
| 1068 | + | |
| 1069 | 1069 | $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); |
| 1070 | 1070 | |
| 1071 | 1071 | // ----- Return |
| ... | ... | @@ -1119,7 +1119,7 @@ |
| 1119 | 1119 | if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
| 1120 | 1120 | { |
| 1121 | 1121 | $this->privSwapBackMagicQuotes(); |
| 1122 | - | |
| 1122 | + | |
| 1123 | 1123 | // ----- Error log |
| 1124 | 1124 | PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
| 1125 | 1125 | |
| ... | ... | @@ -1448,7 +1448,7 @@ |
| 1448 | 1448 | { |
| 1449 | 1449 | //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", ""); |
| 1450 | 1450 | $v_result=1; |
| 1451 | - | |
| 1451 | + | |
| 1452 | 1452 | // ----- Read the options |
| 1453 | 1453 | $i=0; |
| 1454 | 1454 | while ($i<$p_size) { |
| ... | ... | @@ -1645,7 +1645,7 @@ |
| 1645 | 1645 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); |
| 1646 | 1646 | return PclZip::errorCode(); |
| 1647 | 1647 | } |
| 1648 | - | |
| 1648 | + | |
| 1649 | 1649 | // ----- Reduce the index list |
| 1650 | 1650 | // each index item in the list must be a couple with a start and |
| 1651 | 1651 | // an end value : [0,3], [5-5], [8-10], ... |
| ... | ... | @@ -1656,10 +1656,10 @@ |
| 1656 | 1656 | // ----- Explode the item |
| 1657 | 1657 | $v_item_list = explode("-", $v_work_list[$j]); |
| 1658 | 1658 | $v_size_item_list = sizeof($v_item_list); |
| 1659 | - | |
| 1659 | + | |
| 1660 | 1660 | // ----- TBC : Here we might check that each item is a |
| 1661 | 1661 | // real integer ... |
| 1662 | - | |
| 1662 | + | |
| 1663 | 1663 | // ----- Look for single value |
| 1664 | 1664 | if ($v_size_item_list == 1) { |
| 1665 | 1665 | // ----- Set the option value |
| ... | ... | @@ -1697,7 +1697,7 @@ |
| 1697 | 1697 | } |
| 1698 | 1698 | $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start']; |
| 1699 | 1699 | } |
| 1700 | - | |
| 1700 | + | |
| 1701 | 1701 | // ----- Sort the items |
| 1702 | 1702 | if ($v_sort_flag) { |
| 1703 | 1703 | // TBC : To Be Completed |
| ... | ... | @@ -1829,10 +1829,10 @@ |
| 1829 | 1829 | { |
| 1830 | 1830 | //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrParseAtt", ""); |
| 1831 | 1831 | $v_result=1; |
| 1832 | - | |
| 1832 | + | |
| 1833 | 1833 | // ----- For each file in the list check the attributes |
| 1834 | 1834 | foreach ($p_file_list as $v_key => $v_value) { |
| 1835 | - | |
| 1835 | + | |
| 1836 | 1836 | // ----- Check if the option is supported |
| 1837 | 1837 | if (!isset($v_requested_options[$v_key])) { |
| 1838 | 1838 | // ----- Error log |
| ... | ... | @@ -1854,7 +1854,7 @@ |
| 1854 | 1854 | |
| 1855 | 1855 | $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); |
| 1856 | 1856 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); |
| 1857 | - | |
| 1857 | + | |
| 1858 | 1858 | if ($p_filedescr['filename'] == '') { |
| 1859 | 1859 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1860 | 1860 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); |
| ... | ... | @@ -1922,10 +1922,10 @@ |
| 1922 | 1922 | } |
| 1923 | 1923 | } |
| 1924 | 1924 | } |
| 1925 | - | |
| 1925 | + | |
| 1926 | 1926 | // end foreach |
| 1927 | 1927 | } |
| 1928 | - | |
| 1928 | + | |
| 1929 | 1929 | // ----- Return |
| 1930 | 1930 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); |
| 1931 | 1931 | return $v_result; |
| ... | ... | @@ -1944,21 +1944,21 @@ |
| 1944 | 1944 | { |
| 1945 | 1945 | //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrExpand", ""); |
| 1946 | 1946 | $v_result=1; |
| 1947 | - | |
| 1947 | + | |
| 1948 | 1948 | // ----- Create a result list |
| 1949 | 1949 | $v_result_list = array(); |
| 1950 | - | |
| 1950 | + | |
| 1951 | 1951 | // ----- Look each entry |
| 1952 | 1952 | for ($i=0; $i<sizeof($p_filedescr_list); $i++) { |
| 1953 | 1953 | // ----- Get filedescr |
| 1954 | 1954 | $v_descr = $p_filedescr_list[$i]; |
| 1955 | - | |
| 1955 | + | |
| 1956 | 1956 | // ----- Reduce the filename |
| 1957 | 1957 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filedescr before reduction :'".$v_descr['filename']."'"); |
| 1958 | 1958 | $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename']); |
| 1959 | 1959 | $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']); |
| 1960 | 1960 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filedescr after reduction :'".$v_descr['filename']."'"); |
| 1961 | - | |
| 1961 | + | |
| 1962 | 1962 | // ----- Get type of descr |
| 1963 | 1963 | if (!file_exists($v_descr['filename'])) { |
| 1964 | 1964 | // ----- Error log |
| ... | ... | @@ -1987,13 +1987,13 @@ |
| 1987 | 1987 | // skip |
| 1988 | 1988 | continue; |
| 1989 | 1989 | } |
| 1990 | - | |
| 1990 | + | |
| 1991 | 1991 | // ----- Calculate the stored filename |
| 1992 | 1992 | $this->privCalculateStoredFilename($v_descr, $p_options); |
| 1993 | - | |
| 1993 | + | |
| 1994 | 1994 | // ----- Add the descriptor in result list |
| 1995 | 1995 | $v_result_list[sizeof($v_result_list)] = $v_descr; |
| 1996 | - | |
| 1996 | + | |
| 1997 | 1997 | // ----- Look for folder |
| 1998 | 1998 | if ($v_descr['type'] == 'folder') { |
| 1999 | 1999 | // ----- List of items in folder |
| ... | ... | @@ -2007,17 +2007,17 @@ |
| 2007 | 2007 | if (($v_item_handler == '.') || ($v_item_handler == '..')) { |
| 2008 | 2008 | continue; |
| 2009 | 2009 | } |
| 2010 | - | |
| 2010 | + | |
| 2011 | 2011 | // ----- Compose the full filename |
| 2012 | 2012 | $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; |
| 2013 | - | |
| 2013 | + | |
| 2014 | 2014 | // ----- Look for different stored filename |
| 2015 | 2015 | // Because the name of the folder was changed, the name of the |
| 2016 | 2016 | // files/sub-folders also change |
| 2017 | 2017 | if ($v_descr['stored_filename'] != $v_descr['filename']) { |
| 2018 | 2018 | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; |
| 2019 | 2019 | } |
| 2020 | - | |
| 2020 | + | |
| 2021 | 2021 | $v_dirlist_nb++; |
| 2022 | 2022 | } |
| 2023 | 2023 | } |
| ... | ... | @@ -2025,7 +2025,7 @@ |
| 2025 | 2025 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to open dir '".$v_descr['filename']."' in read mode. Skipped."); |
| 2026 | 2026 | // TBC : unable to open folder in read mode |
| 2027 | 2027 | } |
| 2028 | - | |
| 2028 | + | |
| 2029 | 2029 | // ----- Expand each element of the list |
| 2030 | 2030 | if ($v_dirlist_nb != 0) { |
| 2031 | 2031 | // ----- Expand |
| ... | ... | @@ -2033,7 +2033,7 @@ |
| 2033 | 2033 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); |
| 2034 | 2034 | return $v_result; |
| 2035 | 2035 | } |
| 2036 | - | |
| 2036 | + | |
| 2037 | 2037 | // ----- Concat the resulting list |
| 2038 | 2038 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Merging result list (size '".sizeof($v_result_list)."') with dirlist (size '".sizeof($v_dirlist_descr)."')"); |
| 2039 | 2039 | $v_result_list = array_merge($v_result_list, $v_dirlist_descr); |
| ... | ... | @@ -2042,12 +2042,12 @@ |
| 2042 | 2042 | else { |
| 2043 | 2043 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Nothing in this folder to expand."); |
| 2044 | 2044 | } |
| 2045 | - | |
| 2045 | + | |
| 2046 | 2046 | // ----- Free local array |
| 2047 | 2047 | unset($v_dirlist_descr); |
| 2048 | 2048 | } |
| 2049 | 2049 | } |
| 2050 | - | |
| 2050 | + | |
| 2051 | 2051 | // ----- Get the result list |
| 2052 | 2052 | $p_filedescr_list = $v_result_list; |
| 2053 | 2053 | |
| ... | ... | @@ -2068,7 +2068,7 @@ |
| 2068 | 2068 | //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list"); |
| 2069 | 2069 | $v_result=1; |
| 2070 | 2070 | $v_list_detail = array(); |
| 2071 | - | |
| 2071 | + | |
| 2072 | 2072 | // ----- Magic quotes trick |
| 2073 | 2073 | $this->privDisableMagicQuotes(); |
| 2074 | 2074 | |
| ... | ... | @@ -2429,7 +2429,7 @@ |
| 2429 | 2429 | // Function : privAddFileList() |
| 2430 | 2430 | // Description : |
| 2431 | 2431 | // Parameters : |
| 2432 | - // $p_filedescr_list : An array containing the file description | |
| 2432 | + // $p_filedescr_list : An array containing the file description | |
| 2433 | 2433 | // or directory names to add in the zip |
| 2434 | 2434 | // $p_result_list : list of added files with their properties (specially the status field) |
| 2435 | 2435 | // Return Values : |
| ... | ... | @@ -2449,7 +2449,7 @@ |
| 2449 | 2449 | // ----- Format the filename |
| 2450 | 2450 | $p_filedescr_list[$j]['filename'] |
| 2451 | 2451 | = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); |
| 2452 | - | |
| 2452 | + | |
| 2453 | 2453 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file '".$p_filedescr_list[$j]['filename']."'"); |
| 2454 | 2454 | |
| 2455 | 2455 | // ----- Skip empty file names |
| ... | ... | @@ -2503,7 +2503,7 @@ |
| 2503 | 2503 | { |
| 2504 | 2504 | //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='".$p_filedescr['filename']."'"); |
| 2505 | 2505 | $v_result=1; |
| 2506 | - | |
| 2506 | + | |
| 2507 | 2507 | // ----- Working variable |
| 2508 | 2508 | $p_filename = $p_filedescr['filename']; |
| 2509 | 2509 | |
| ... | ... | @@ -2516,8 +2516,8 @@ |
| 2516 | 2516 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); |
| 2517 | 2517 | return PclZip::errorCode(); |
| 2518 | 2518 | } |
| 2519 | - | |
| 2520 | - // ----- Look for a stored different filename | |
| 2519 | + | |
| 2520 | + // ----- Look for a stored different filename | |
| 2521 | 2521 | if (isset($p_filedescr['stored_filename'])) { |
| 2522 | 2522 | $v_stored_filename = $p_filedescr['stored_filename']; |
| 2523 | 2523 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is NOT the same "'.$v_stored_filename.'"'); |
| ... | ... | @@ -2583,7 +2583,7 @@ |
| 2583 | 2583 | if ($p_header['stored_filename'] == "") { |
| 2584 | 2584 | $p_header['status'] = "filtered"; |
| 2585 | 2585 | } |
| 2586 | - | |
| 2586 | + | |
| 2587 | 2587 | // ----- Check the path length |
| 2588 | 2588 | if (strlen($p_header['stored_filename']) > 0xFF) { |
| 2589 | 2589 | $p_header['status'] = 'filename_too_long'; |
| ... | ... | @@ -2630,13 +2630,13 @@ |
| 2630 | 2630 | $p_header['compressed_size'] = strlen($v_content_compressed); |
| 2631 | 2631 | $p_header['compression'] = 8; |
| 2632 | 2632 | } |
| 2633 | - | |
| 2633 | + | |
| 2634 | 2634 | // ----- Look for encryption |
| 2635 | 2635 | /* |
| 2636 | 2636 | if ((isset($p_options[PCLZIP_OPT_CRYPT])) |
| 2637 | 2637 | && ($p_options[PCLZIP_OPT_CRYPT] != "")) { |
| 2638 | 2638 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File need to be crypted ...."); |
| 2639 | - | |
| 2639 | + | |
| 2640 | 2640 | // Should be a random header |
| 2641 | 2641 | $v_header = 'xxxxxxxxxxxx'; |
| 2642 | 2642 | $v_content_compressed = PclZipUtilZipEncrypt($v_content_compressed, |
| ... | ... | @@ -2644,10 +2644,10 @@ |
| 2644 | 2644 | $v_header, |
| 2645 | 2645 | $p_header['crc'], |
| 2646 | 2646 | "test"); |
| 2647 | - | |
| 2647 | + | |
| 2648 | 2648 | $p_header['compressed_size'] += 12; |
| 2649 | 2649 | $p_header['flag'] = 1; |
| 2650 | - | |
| 2650 | + | |
| 2651 | 2651 | // ----- Add the header to the data |
| 2652 | 2652 | $v_content_compressed = $v_header.$v_content_compressed; |
| 2653 | 2653 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size after header : ".strlen($v_content_compressed).""); |
| ... | ... | @@ -2662,9 +2662,9 @@ |
| 2662 | 2662 | } |
| 2663 | 2663 | |
| 2664 | 2664 | // ----- Write the compressed (or not) content |
| 2665 | - @fwrite($this->zip_fd, | |
| 2665 | + @fwrite($this->zip_fd, | |
| 2666 | 2666 | $v_content_compressed, $p_header['compressed_size']); |
| 2667 | - | |
| 2667 | + | |
| 2668 | 2668 | // ----- Close the file |
| 2669 | 2669 | @fclose($v_file); |
| 2670 | 2670 | } |
| ... | ... | @@ -2730,7 +2730,7 @@ |
| 2730 | 2730 | { |
| 2731 | 2731 | //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCalculateStoredFilename", "filename='".$p_filedescr['filename']."'"); |
| 2732 | 2732 | $v_result=1; |
| 2733 | - | |
| 2733 | + | |
| 2734 | 2734 | // ----- Working variables |
| 2735 | 2735 | $p_filename = $p_filedescr['filename']; |
| 2736 | 2736 | if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { |
| ... | ... | @@ -2757,7 +2757,7 @@ |
| 2757 | 2757 | $v_stored_filename = $p_filedescr['new_full_name']; |
| 2758 | 2758 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing full name of '".$p_filename."' for '".$v_stored_filename."'"); |
| 2759 | 2759 | } |
| 2760 | - | |
| 2760 | + | |
| 2761 | 2761 | // ----- Look for path and/or short name change |
| 2762 | 2762 | else { |
| 2763 | 2763 | |
| ... | ... | @@ -2788,7 +2788,7 @@ |
| 2788 | 2788 | |
| 2789 | 2789 | if ( (substr($p_filename, 0, 2) == "./") |
| 2790 | 2790 | || (substr($p_remove_dir, 0, 2) == "./")) { |
| 2791 | - | |
| 2791 | + | |
| 2792 | 2792 | if ( (substr($p_filename, 0, 2) == "./") |
| 2793 | 2793 | && (substr($p_remove_dir, 0, 2) != "./")) { |
| 2794 | 2794 | $p_remove_dir = "./".$p_remove_dir; |
| ... | ... | @@ -2828,7 +2828,7 @@ |
| 2828 | 2828 | $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); |
| 2829 | 2829 | $p_filedescr['stored_filename'] = $v_stored_filename; |
| 2830 | 2830 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Stored filename will be '".$p_filedescr['stored_filename']."', strlen ".strlen($p_filedescr['stored_filename'])); |
| 2831 | - | |
| 2831 | + | |
| 2832 | 2832 | // ----- Return |
| 2833 | 2833 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); |
| 2834 | 2834 | return $v_result; |
| ... | ... | @@ -2991,7 +2991,7 @@ |
| 2991 | 2991 | { |
| 2992 | 2992 | // ----- Magic quotes trick |
| 2993 | 2993 | $this->privSwapBackMagicQuotes(); |
| 2994 | - | |
| 2994 | + | |
| 2995 | 2995 | // ----- Error log |
| 2996 | 2996 | PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
| 2997 | 2997 | |
| ... | ... | @@ -3270,7 +3270,7 @@ |
| 3270 | 3270 | else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
| 3271 | 3271 | && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { |
| 3272 | 3272 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'"); |
| 3273 | - | |
| 3273 | + | |
| 3274 | 3274 | // ----- Look if the index is in the list |
| 3275 | 3275 | for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) { |
| 3276 | 3276 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]"); |
| ... | ... | @@ -3310,7 +3310,7 @@ |
| 3310 | 3310 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); |
| 3311 | 3311 | |
| 3312 | 3312 | $this->privSwapBackMagicQuotes(); |
| 3313 | - | |
| 3313 | + | |
| 3314 | 3314 | PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, |
| 3315 | 3315 | "Filename '".$v_header['stored_filename']."' is " |
| 3316 | 3316 | ."compressed by an unsupported compression " |
| ... | ... | @@ -3320,7 +3320,7 @@ |
| 3320 | 3320 | return PclZip::errorCode(); |
| 3321 | 3321 | } |
| 3322 | 3322 | } |
| 3323 | - | |
| 3323 | + | |
| 3324 | 3324 | // ----- Check encrypted files |
| 3325 | 3325 | if (($v_extract) && (($v_header['flag'] & 1) == 1)) { |
| 3326 | 3326 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported file encryption"); |
| ... | ... | @@ -3357,7 +3357,7 @@ |
| 3357 | 3357 | |
| 3358 | 3358 | $v_extract = false; |
| 3359 | 3359 | } |
| 3360 | - | |
| 3360 | + | |
| 3361 | 3361 | // ----- Look for real extraction |
| 3362 | 3362 | if ($v_extract) |
| 3363 | 3363 | { |
| ... | ... | @@ -3411,7 +3411,7 @@ |
| 3411 | 3411 | |
| 3412 | 3412 | // ----- Next extracted file |
| 3413 | 3413 | $v_nb_extracted++; |
| 3414 | - | |
| 3414 | + | |
| 3415 | 3415 | // ----- Look for user callback abort |
| 3416 | 3416 | if ($v_result1 == 2) { |
| 3417 | 3417 | break; |
| ... | ... | @@ -3563,13 +3563,13 @@ |
| 3563 | 3563 | if ($p_path != '') { |
| 3564 | 3564 | $p_entry['filename'] = $p_path."/".$p_entry['filename']; |
| 3565 | 3565 | } |
| 3566 | - | |
| 3566 | + | |
| 3567 | 3567 | // ----- Check a base_dir_restriction |
| 3568 | 3568 | if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { |
| 3569 | 3569 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Check the extract directory restriction"); |
| 3570 | 3570 | $v_inclusion |
| 3571 | 3571 | = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], |
| 3572 | - $p_entry['filename']); | |
| 3572 | + $p_entry['filename']); | |
| 3573 | 3573 | if ($v_inclusion == 0) { |
| 3574 | 3574 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_EXTRACT_DIR_RESTRICTION is selected, file is outside restriction"); |
| 3575 | 3575 | |
| ... | ... | @@ -3599,7 +3599,7 @@ |
| 3599 | 3599 | $p_entry['status'] = "skipped"; |
| 3600 | 3600 | $v_result = 1; |
| 3601 | 3601 | } |
| 3602 | - | |
| 3602 | + | |
| 3603 | 3603 | // ----- Look for abort result |
| 3604 | 3604 | if ($v_result == 2) { |
| 3605 | 3605 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); |
| ... | ... | @@ -3631,7 +3631,7 @@ |
| 3631 | 3631 | |
| 3632 | 3632 | // ----- Change the file status |
| 3633 | 3633 | $p_entry['status'] = "already_a_directory"; |
| 3634 | - | |
| 3634 | + | |
| 3635 | 3635 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3636 | 3636 | // For historical reason first PclZip implementation does not stop |
| 3637 | 3637 | // when this kind of error occurs. |
| ... | ... | @@ -3764,7 +3764,7 @@ |
| 3764 | 3764 | $v_binary_data = pack('a'.$v_read_size, $v_buffer); |
| 3765 | 3765 | @fwrite($v_dest_file, $v_binary_data, $v_read_size); |
| 3766 | 3766 | */ |
| 3767 | - @fwrite($v_dest_file, $v_buffer, $v_read_size); | |
| 3767 | + @fwrite($v_dest_file, $v_buffer, $v_read_size); | |
| 3768 | 3768 | $v_size -= $v_read_size; |
| 3769 | 3769 | } |
| 3770 | 3770 | |
| ... | ... | @@ -3773,7 +3773,7 @@ |
| 3773 | 3773 | |
| 3774 | 3774 | // ----- Change the file mtime |
| 3775 | 3775 | touch($p_entry['filename'], $p_entry['mtime']); |
| 3776 | - | |
| 3776 | + | |
| 3777 | 3777 | |
| 3778 | 3778 | } |
| 3779 | 3779 | else { |
| ... | ... | @@ -3786,11 +3786,11 @@ |
| 3786 | 3786 | // ----- Read the encryption header |
| 3787 | 3787 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read 12 encryption header bytes"); |
| 3788 | 3788 | $v_encryption_header = @fread($this->zip_fd, 12); |
| 3789 | - | |
| 3789 | + | |
| 3790 | 3790 | // ----- Read the encrypted & compressed file in a buffer |
| 3791 | 3791 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".($p_entry['compressed_size']-12)."' compressed & encrypted bytes"); |
| 3792 | 3792 | $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']-12); |
| 3793 | - | |
| 3793 | + | |
| 3794 | 3794 | // ----- Decrypt the buffer |
| 3795 | 3795 | $this->privDecrypt($v_encryption_header, $v_buffer, |
| 3796 | 3796 | $p_entry['compressed_size']-12, $p_entry['crc']); |
| ... | ... | @@ -3802,7 +3802,7 @@ |
| 3802 | 3802 | // ----- Read the compressed file in a buffer (one shot) |
| 3803 | 3803 | $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
| 3804 | 3804 | } |
| 3805 | - | |
| 3805 | + | |
| 3806 | 3806 | // ----- Decompress the file |
| 3807 | 3807 | $v_file_content = @gzinflate($v_buffer); |
| 3808 | 3808 | unset($v_buffer); |
| ... | ... | @@ -3812,11 +3812,11 @@ |
| 3812 | 3812 | // ----- Change the file status |
| 3813 | 3813 | // TBC |
| 3814 | 3814 | $p_entry['status'] = "error"; |
| 3815 | - | |
| 3815 | + | |
| 3816 | 3816 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); |
| 3817 | 3817 | return $v_result; |
| 3818 | 3818 | } |
| 3819 | - | |
| 3819 | + | |
| 3820 | 3820 | // ----- Opening destination file |
| 3821 | 3821 | if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
| 3822 | 3822 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode"); |
| ... | ... | @@ -3855,7 +3855,7 @@ |
| 3855 | 3855 | if ($p_entry['status'] == "aborted") { |
| 3856 | 3856 | $p_entry['status'] = "skipped"; |
| 3857 | 3857 | } |
| 3858 | - | |
| 3858 | + | |
| 3859 | 3859 | // ----- Look for post-extract callback |
| 3860 | 3860 | elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { |
| 3861 | 3861 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction"); |
| ... | ... | @@ -3964,7 +3964,7 @@ |
| 3964 | 3964 | |
| 3965 | 3965 | // ----- Read the compressed file in a buffer (one shot) |
| 3966 | 3966 | $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
| 3967 | - | |
| 3967 | + | |
| 3968 | 3968 | // ----- Decompress the file |
| 3969 | 3969 | $v_file_content = gzinflate($v_buffer); |
| 3970 | 3970 | unset($v_buffer); |
| ... | ... | @@ -4053,7 +4053,7 @@ |
| 4053 | 4053 | |
| 4054 | 4054 | // ----- Reading the file |
| 4055 | 4055 | $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); |
| 4056 | - | |
| 4056 | + | |
| 4057 | 4057 | // ----- Decompress the file |
| 4058 | 4058 | if (($p_string = @gzinflate($v_data)) === FALSE) { |
| 4059 | 4059 | // TBC |
| ... | ... | @@ -4803,7 +4803,7 @@ |
| 4803 | 4803 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); |
| 4804 | 4804 | return $v_result; |
| 4805 | 4805 | } |
| 4806 | - | |
| 4806 | + | |
| 4807 | 4807 | // ----- Check that local file header is same as central file header |
| 4808 | 4808 | if ($this->privCheckFileHeaders($v_local_header, |
| 4809 | 4809 | $v_header_list[$i]) != 1) { |
| ... | ... | @@ -4896,11 +4896,11 @@ |
| 4896 | 4896 | // TBC : I should test the result ... |
| 4897 | 4897 | //@rename($v_zip_temp_name, $this->zipname); |
| 4898 | 4898 | PclZipUtilRename($v_zip_temp_name, $this->zipname); |
| 4899 | - | |
| 4899 | + | |
| 4900 | 4900 | // ----- Destroy the temporary archive |
| 4901 | 4901 | unset($v_temp_zip); |
| 4902 | 4902 | } |
| 4903 | - | |
| 4903 | + | |
| 4904 | 4904 | // ----- Remove every files : reset the file |
| 4905 | 4905 | else if ($v_central_dir['entries'] != 0) { |
| 4906 | 4906 | $this->privCloseFd(); |
| ... | ... | @@ -5315,13 +5315,13 @@ |
| 5315 | 5315 | { |
| 5316 | 5316 | //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDecrypt', "size=".$p_size.""); |
| 5317 | 5317 | $v_result=1; |
| 5318 | - | |
| 5318 | + | |
| 5319 | 5319 | // ----- To Be Modified ;-) |
| 5320 | 5320 | $v_pwd = "test"; |
| 5321 | - | |
| 5321 | + | |
| 5322 | 5322 | $p_buffer = PclZipUtilZipDecrypt($p_buffer, $p_size, $p_encryption_header, |
| 5323 | 5323 | $p_crc, $v_pwd); |
| 5324 | - | |
| 5324 | + | |
| 5325 | 5325 | // ----- Return |
| 5326 | 5326 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); |
| 5327 | 5327 | return $v_result; |
| ... | ... | @@ -5471,7 +5471,7 @@ |
| 5471 | 5471 | } |
| 5472 | 5472 | } |
| 5473 | 5473 | } |
| 5474 | - | |
| 5474 | + | |
| 5475 | 5475 | // ----- Look for skip |
| 5476 | 5476 | if ($v_skip > 0) { |
| 5477 | 5477 | while ($v_skip > 0) { |
| ... | ... | @@ -5506,7 +5506,7 @@ |
| 5506 | 5506 | { |
| 5507 | 5507 | //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'"); |
| 5508 | 5508 | $v_result = 1; |
| 5509 | - | |
| 5509 | + | |
| 5510 | 5510 | // ----- Look for path beginning by ./ |
| 5511 | 5511 | if ( ($p_dir == '.') |
| 5512 | 5512 | || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { |
| ... | ... | @@ -5697,7 +5697,7 @@ |
| 5697 | 5697 | function PclZipUtilOptionText($p_option) |
| 5698 | 5698 | { |
| 5699 | 5699 | //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'"); |
| 5700 | - | |
| 5700 | + | |
| 5701 | 5701 | $v_list = get_defined_constants(); |
| 5702 | 5702 | for (reset($v_list); $v_key = key($v_list); next($v_list)) { |
| 5703 | 5703 | $v_prefix = substr($v_key, 0, 10); |
| ... | ... | @@ -5709,7 +5709,7 @@ |
| 5709 | 5709 | return $v_key; |
| 5710 | 5710 | } |
| 5711 | 5711 | } |
| 5712 | - | |
| 5712 | + | |
| 5713 | 5713 | $v_result = 'Unknown'; |
| 5714 | 5714 | |
| 5715 | 5715 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); | ... | ... |