- Timestamp:
- 06/04/08 01:37:02
(6 months ago)
- Author:
- rats
- Message:
* Updated net2ftp to version 0.97
* Updated SquirrelMail to version 1.4.15
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r910 |
r1198 |
|
| 1 | 1 | <?php |
|---|
| 2 | 2 | // -------------------------------------------------------------------------------- |
|---|
| 3 | | // PhpConcept Library - Zip Module 2.5 |
|---|
| | 3 | // PhpConcept Library - Zip Module 2.6 |
|---|
| 4 | 4 | // -------------------------------------------------------------------------------- |
|---|
| 5 | 5 | // License GNU/LGPL - Vincent Blavet - March 2006 |
|---|
| … | … | |
| 23 | 23 | // |
|---|
| 24 | 24 | // -------------------------------------------------------------------------------- |
|---|
| 25 | | // $Id: pclzip.lib.php,v 1.44 2006/03/08 21:23:59 vblavet Exp $ |
|---|
| | 25 | // $Id: pclzip.lib.php,v 1.47 2007/07/20 13:56:07 vblavet Exp $ |
|---|
| 26 | 26 | // -------------------------------------------------------------------------------- |
|---|
| 27 | 27 | |
|---|
| 28 | 28 | // ----- Constants |
|---|
| 29 | | define( 'PCLZIP_READ_BLOCK_SIZE', 2048 ); |
|---|
| | 29 | if (!defined('PCLZIP_READ_BLOCK_SIZE')) { |
|---|
| | 30 | define( 'PCLZIP_READ_BLOCK_SIZE', 2048 ); |
|---|
| | 31 | } |
|---|
| 30 | 32 | |
|---|
| 31 | 33 | // ----- File list separator |
|---|
| … | … | |
| 39 | 41 | //define( 'PCLZIP_SEPARATOR', ' ' ); |
|---|
| 40 | 42 | // Recommanded values for smart separation of filenames. |
|---|
| 41 | | define( 'PCLZIP_SEPARATOR', ',' ); |
|---|
| | 43 | if (!defined('PCLZIP_SEPARATOR')) { |
|---|
| | 44 | define( 'PCLZIP_SEPARATOR', ',' ); |
|---|
| | 45 | } |
|---|
| 42 | 46 | |
|---|
| 43 | 47 | // ----- Error configuration |
|---|
| … | … | |
| 46 | 50 | // you must ensure that you have included PclError library. |
|---|
| 47 | 51 | // [2,...] : reserved for futur use |
|---|
| 48 | | define( 'PCLZIP_ERROR_EXTERNAL', 0 ); |
|---|
| | 52 | if (!defined('PCLZIP_ERROR_EXTERNAL')) { |
|---|
| | 53 | define( 'PCLZIP_ERROR_EXTERNAL', 0 ); |
|---|
| | 54 | } |
|---|
| 49 | 55 | |
|---|
| 50 | 56 | // ----- Optional static temporary directory |
|---|
| … | … | |
| 57 | 63 | // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' ); |
|---|
| 58 | 64 | // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' ); |
|---|
| 59 | | define( 'PCLZIP_TEMPORARY_DIR', '' ); |
|---|
| | 65 | if (!defined('PCLZIP_TEMPORARY_DIR')) { |
|---|
| | 66 | define( 'PCLZIP_TEMPORARY_DIR', '' ); |
|---|
| | 67 | } |
|---|
| 60 | 68 | |
|---|
| 61 | 69 | // -------------------------------------------------------------------------------- |
|---|
| … | … | |
| 64 | 72 | |
|---|
| 65 | 73 | // ----- Global variables |
|---|
| 66 | | $g_pclzip_version = "2.5"; |
|---|
| | 74 | $g_pclzip_version = "2.6"; |
|---|
| 67 | 75 | |
|---|
| 68 | 76 | // ----- Error codes |
|---|
| … | … | |
| 132 | 140 | define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 ); |
|---|
| 133 | 141 | define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 ); |
|---|
| | 142 | define( 'PCLZIP_ATT_FILE_MTIME', 79004 ); |
|---|
| | 143 | define( 'PCLZIP_ATT_FILE_CONTENT', 79005 ); |
|---|
| | 144 | define( 'PCLZIP_ATT_FILE_COMMENT', 79006 ); |
|---|
| 134 | 145 | |
|---|
| 135 | 146 | // ----- Call backs values |
|---|
| … | … | |
| 362 | 373 | ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|---|
| 363 | 374 | ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|---|
| | 375 | ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|---|
| | 376 | ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|---|
| | 377 | ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|---|
| 364 | 378 | ); |
|---|
| 365 | 379 | foreach ($v_att_list as $v_entry) { |
|---|
| … | … | |
| 547 | 561 | ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|---|
| 548 | 562 | ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|---|
| | 563 | ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|---|
| | 564 | ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|---|
| | 565 | ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|---|
| 549 | 566 | ); |
|---|
| 550 | 567 | foreach ($v_att_list as $v_entry) { |
|---|
| … | … | |
| 1482 | 1499 | |
|---|
| 1483 | 1500 | // ----- Get the value |
|---|
| 1484 | | $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false); |
|---|
| | 1501 | $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|---|
| 1485 | 1502 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); |
|---|
| 1486 | 1503 | $i++; |
|---|
| … | … | |
| 1501 | 1518 | if ( is_string($p_options_list[$i+1]) |
|---|
| 1502 | 1519 | && ($p_options_list[$i+1] != '')) { |
|---|
| 1503 | | $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false); |
|---|
| | 1520 | $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|---|
| 1504 | 1521 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); |
|---|
| 1505 | 1522 | $i++; |
|---|
| … | … | |
| 1898 | 1915 | break; |
|---|
| 1899 | 1916 | |
|---|
| | 1917 | // ----- Look for options that takes a string |
|---|
| | 1918 | case PCLZIP_ATT_FILE_COMMENT : |
|---|
| | 1919 | if (!is_string($v_value)) { |
|---|
| | 1920 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|---|
| | 1921 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); |
|---|
| | 1922 | return PclZip::errorCode(); |
|---|
| | 1923 | } |
|---|
| | 1924 | |
|---|
| | 1925 | $p_filedescr['comment'] = $v_value; |
|---|
| | 1926 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); |
|---|
| | 1927 | break; |
|---|
| | 1928 | |
|---|
| | 1929 | case PCLZIP_ATT_FILE_MTIME : |
|---|
| | 1930 | if (!is_integer($v_value)) { |
|---|
| | 1931 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|---|
| | 1932 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); |
|---|
| | 1933 | return PclZip::errorCode(); |
|---|
| | 1934 | } |
|---|
| | 1935 | |
|---|
| | 1936 | $p_filedescr['mtime'] = $v_value; |
|---|
| | 1937 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); |
|---|
| | 1938 | break; |
|---|
| | 1939 | |
|---|
| | 1940 | case PCLZIP_ATT_FILE_CONTENT : |
|---|
| | 1941 | $p_filedescr['content'] = $v_value; |
|---|
| | 1942 | ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); |
|---|
| | 1943 | break; |
|---|
| | 1944 | |
|---|
| 1900 | 1945 | default : |
|---|
| 1901 | 1946 | // ----- Error log |
|---|
| … | … | |
| 1951 | 1996 | // ----- Look each entry |
|---|
| 1952 | 1997 | for ($i=0; $i<sizeof($p_filedescr_list); $i++) { |
|---|
| | 1998 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for file ".$i."."); |
|---|
| | 1999 | |
|---|
| 1953 | 2000 | // ----- Get filedescr |
|---|
| 1954 | 2001 | $v_descr = $p_filedescr_list[$i]; |
|---|
| … | … | |
| 1960 | 2007 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filedescr after reduction :'".$v_descr['filename']."'"); |
|---|
| 1961 | 2008 | |
|---|
| 1962 | | // ----- Get type of descr |
|---|
| 1963 | | if (!file_exists($v_descr['filename'])) { |
|---|
| | 2009 | // ----- Look for real file or folder |
|---|
| | 2010 | if (file_exists($v_descr['filename'])) { |
|---|
| | 2011 | if (@is_file($v_descr['filename'])) { |
|---|
| | 2012 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a file"); |
|---|
| | 2013 | $v_descr['type'] = 'file'; |
|---|
| | 2014 | } |
|---|
| | 2015 | else if (@is_dir($v_descr['filename'])) { |
|---|
| | 2016 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a folder"); |
|---|
| | 2017 | $v_descr['type'] = 'folder'; |
|---|
| | 2018 | } |
|---|
| | 2019 | else if (@is_link($v_descr['filename'])) { |
|---|
| | 2020 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : link"); |
|---|
| | 2021 | // skip |
|---|
| | 2022 | continue; |
|---|
| | 2023 | } |
|---|
| | 2024 | else { |
|---|
| | 2025 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : unknown type"); |
|---|
| | 2026 | // skip |
|---|
| | 2027 | continue; |
|---|
| | 2028 | } |
|---|
| | 2029 | } |
|---|
| | 2030 | |
|---|
| | 2031 | // ----- Look for string added as file |
|---|
| | 2032 | else if (isset($v_descr['content'])) { |
|---|
| | 2033 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a string added as a file"); |
|---|
| | 2034 | $v_descr['type'] = 'virtual_file'; |
|---|
| | 2035 | } |
|---|
| | 2036 | |
|---|
| | 2037 | // ----- Missing file |
|---|
| | 2038 | else { |
|---|
| 1964 | 2039 | // ----- Error log |
|---|
| 1965 | 2040 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_descr['filename']."' does not exists"); |
|---|
| … | … | |
| 1969 | 2044 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); |
|---|
| 1970 | 2045 | return PclZip::errorCode(); |
|---|
| 1971 | | } |
|---|
| 1972 | | if (@is_file($v_descr['filename'])) { |
|---|
| 1973 | | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a file"); |
|---|
| 1974 | | $v_descr['type'] = 'file'; |
|---|
| 1975 | | } |
|---|
| 1976 | | else if (@is_dir($v_descr['filename'])) { |
|---|
| 1977 | | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a folder"); |
|---|
| 1978 | | $v_descr['type'] = 'folder'; |
|---|
| 1979 | | } |
|---|
| 1980 | | else if (@is_link($v_descr['filename'])) { |
|---|
| 1981 | | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : link"); |
|---|
| 1982 | | // skip |
|---|
| 1983 | | continue; |
|---|
| 1984 | | } |
|---|
| 1985 | | else { |
|---|
| 1986 | | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : unknown type"); |
|---|
| 1987 | | // skip |
|---|
| 1988 | | continue; |
|---|
| 1989 | 2046 | } |
|---|
| 1990 | 2047 | |
|---|
| … | … | |
| 2016 | 2073 | // files/sub-folders also change |
|---|
| 2017 | 2074 | if ($v_descr['stored_filename'] != $v_descr['filename']) { |
|---|
| 2018 | | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; |
|---|
| | 2075 | if ($v_descr['stored_filename'] != '') { |
|---|
| | 2076 | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; |
|---|
| | 2077 | } |
|---|
| | 2078 | else { |
|---|
| | 2079 | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; |
|---|
| | 2080 | } |
|---|
| 2019 | 2081 | } |
|---|
| 2020 | 2082 | |
|---|
| 2021 | 2083 | $v_dirlist_nb++; |
|---|
| 2022 | 2084 | } |
|---|
| | 2085 | |
|---|
| | 2086 | @closedir($v_folder_handler); |
|---|
| 2023 | 2087 | } |
|---|
| 2024 | 2088 | else { |
|---|
| … | … | |
| 2461 | 2525 | |
|---|
| 2462 | 2526 | // ----- Check the filename |
|---|
| 2463 | | if (!file_exists($p_filedescr_list[$j]['filename'])) { |
|---|
| | 2527 | if ( ($p_filedescr_list[$j]['type'] != 'virtual_file') |
|---|
| | 2528 | && (!file_exists($p_filedescr_list[$j]['filename']))) { |
|---|
| 2464 | 2529 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_filedescr_list[$j]['filename']."' does not exists"); |
|---|
| 2465 | 2530 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exists"); |
|---|
| … | … | |
| 2469 | 2534 | |
|---|
| 2470 | 2535 | // ----- Look if it is a file or a dir with no all path remove option |
|---|
| 2471 | | if ( (is_file($p_filedescr_list[$j]['filename'])) |
|---|
| 2472 | | || ( is_dir($p_filedescr_list[$j]['filename']) |
|---|
| | 2536 | // or a dir with all its path removed |
|---|
| | 2537 | // if ( (is_file($p_filedescr_list[$j]['filename'])) |
|---|
| | 2538 | // || ( is_dir($p_filedescr_list[$j]['filename']) |
|---|
| | 2539 | if ( ($p_filedescr_list[$j]['type'] == 'file') |
|---|
| | 2540 | || ($p_filedescr_list[$j]['type'] == 'virtual_file') |
|---|
| | 2541 | || ( ($p_filedescr_list[$j]['type'] == 'folder') |
|---|
| 2473 | 2542 | && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) |
|---|
| 2474 | | || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) { |
|---|
| | 2543 | || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) |
|---|
| | 2544 | ) { |
|---|
| 2475 | 2545 | |
|---|
| 2476 | 2546 | // ----- Add the file |
|---|
| … | … | |
| 2519 | 2589 | |
|---|
| 2520 | 2590 | // ----- Look for a stored different filename |
|---|
| | 2591 | /* TBC : Removed |
|---|
| 2521 | 2592 | if (isset($p_filedescr['stored_filename'])) { |
|---|
| 2522 | 2593 | $v_stored_filename = $p_filedescr['stored_filename']; |
|---|
| … | … | |
| 2527 | 2598 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is the same'); |
|---|
| 2528 | 2599 | } |
|---|
| | 2600 | */ |
|---|
| 2529 | 2601 | |
|---|
| 2530 | 2602 | // ----- Set the file properties |
|---|
| … | … | |
| 2534 | 2606 | $p_header['flag'] = 0; |
|---|
| 2535 | 2607 | $p_header['compression'] = 0; |
|---|
| 2536 | | $p_header['mtime'] = filemtime($p_filename); |
|---|
| 2537 | 2608 | $p_header['crc'] = 0; |
|---|
| 2538 | 2609 | $p_header['compressed_size'] = 0; |
|---|
| 2539 | | $p_header['size'] = filesize($p_filename); |
|---|
| 2540 | 2610 | $p_header['filename_len'] = strlen($p_filename); |
|---|
| 2541 | 2611 | $p_header['extra_len'] = 0; |
|---|
| 2542 | | $p_header['comment_len'] = 0; |
|---|
| 2543 | 2612 | $p_header['disk'] = 0; |
|---|
| 2544 | 2613 | $p_header['internal'] = 0; |
|---|
| 2545 | | // $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010); |
|---|
| 2546 | | $p_header['external'] = (is_file($p_filename)?0x00000000:0x00000010); |
|---|
| 2547 | | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header external extension '".sprintf("0x%X",$p_header['external'])."'"); |
|---|
| 2548 | 2614 | $p_header['offset'] = 0; |
|---|
| 2549 | 2615 | $p_header['filename'] = $p_filename; |
|---|
| 2550 | | $p_header['stored_filename'] = $v_stored_filename; |
|---|
| | 2616 | // TBC : Removed $p_header['stored_filename'] = $v_stored_filename; |
|---|
| | 2617 | $p_header['stored_filename'] = $p_filedescr['stored_filename']; |
|---|
| 2551 | 2618 | $p_header['extra'] = ''; |
|---|
| 2552 | | $p_header['comment'] = ''; |
|---|
| 2553 | 2619 | $p_header['status'] = 'ok'; |
|---|
| 2554 | 2620 | $p_header['index'] = -1; |
|---|
| | 2621 | |
|---|
| | 2622 | // ----- Look for regular file |
|---|
| | 2623 | if ($p_filedescr['type']=='file') { |
|---|
| | 2624 | $p_header['external'] = 0x00000000; |
|---|
| | 2625 | $p_header['size'] = filesize($p_filename); |
|---|
| | 2626 | } |
|---|
| | 2627 | |
|---|
| | 2628 | // ----- Look for regular folder |
|---|
| | 2629 | else if ($p_filedescr['type']=='folder') { |
|---|
| | 2630 | $p_header['external'] = 0x00000010; |
|---|
| | 2631 | $p_header['mtime'] = filemtime($p_filename); |
|---|
| | 2632 | $p_header['size'] = filesize($p_filename); |
|---|
| | 2633 | } |
|---|
| | 2634 | |
|---|
| | 2635 | // ----- Look for virtual file |
|---|
| | 2636 | else if ($p_filedescr['type'] == 'virtual_file') { |
|---|
| | 2637 | $p_header['external'] = 0x00000000; |
|---|
| | 2638 | $p_header['size'] = strlen($p_filedescr['content']); |
|---|
| | 2639 | } |
|---|
| | 2640 | |
|---|
| | 2641 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header external extension '".sprintf("0x%X",$p_header['external'])."'"); |
|---|
| | 2642 | |
|---|
| | 2643 | // ----- Look for filetime |
|---|
| | 2644 | if (isset($p_filedescr['mtime'])) { |
|---|
| | 2645 | $p_header['mtime'] = $p_filedescr['mtime']; |
|---|
| | 2646 | } |
|---|
| | 2647 | else if ($p_filedescr['type'] == 'virtual_file') { |
|---|
| | 2648 | $p_header['mtime'] = mktime(); |
|---|
| | 2649 | } |
|---|
| | 2650 | else { |
|---|
| | 2651 | $p_header['mtime'] = filemtime($p_filename); |
|---|
| | 2652 | } |
|---|
| | 2653 | |
|---|
| | 2654 | // ------ Look for file comment |
|---|
| | 2655 | if (isset($p_filedescr['comment'])) { |
|---|
| | 2656 | $p_header['comment_len'] = strlen($p_filedescr['comment']); |
|---|
| | 2657 | $p_header['comment'] = $p_filedescr['comment']; |
|---|
| | 2658 | } |
|---|
| | 2659 | else { |
|---|
| | 2660 | $p_header['comment_len'] = 0; |
|---|
| | 2661 | $p_header['comment'] = ''; |
|---|
| | 2662 | } |
|---|
| 2555 | 2663 | |
|---|
| 2556 | 2664 | // ----- Look for pre-add callback |
|---|
| … | … | |
| 2594 | 2702 | |
|---|
| 2595 | 2703 | // ----- Look for a file |
|---|
| 2596 | | if (is_file($p_filename)) |
|---|
| 2597 | | { |
|---|
| 2598 | | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file"); |
|---|
| 2599 | | // ----- Open the source file |
|---|
| 2600 | | if (($v_file = @fopen($p_filename, "rb")) == 0) { |
|---|
| 2601 | | PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|---|
| 2602 | | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); |
|---|
| 2603 | | return PclZip::errorCode(); |
|---|
| 2604 | | } |
|---|
| 2605 | | |
|---|
| | 2704 | // if (is_file($p_filename)) |
|---|
| | 2705 | if ( ($p_filedescr['type'] == 'file') |
|---|
| | 2706 | || ($p_filedescr['type'] == 'virtual_file')) { |
|---|
| | 2707 | |
|---|
| | 2708 | // ----- Get content from real file |
|---|
| | 2709 | if ($p_filedescr['type'] == 'file') { |
|---|
| | 2710 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file"); |
|---|
| | 2711 | |
|---|
| | 2712 | // ----- Open the source file |
|---|
| | 2713 | if (($v_file = @fopen($p_filename, "rb")) == 0) { |
|---|
| | 2714 | PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|---|
| | 2715 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); |
|---|
| | 2716 | return PclZip::errorCode(); |
|---|
| | 2717 | } |
|---|
| | 2718 | |
|---|
| | 2719 | // ----- Read the file content |
|---|
| | 2720 | $v_content = @fread($v_file, $p_header['size']); |
|---|
| | 2721 | |
|---|
| | 2722 | // ----- Close the file |
|---|
| | 2723 | @fclose($v_file); |
|---|
| | 2724 | } |
|---|
| | 2725 | else if ($p_filedescr['type'] == 'virtual_file') { |
|---|
| | 2726 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Add by string"); |
|---|
| | 2727 | $v_content = $p_filedescr['content']; |
|---|
| | 2728 | } |
|---|
| | 2729 | |
|---|
| | 2730 | // ----- Calculate the CRC |
|---|
| | 2731 | $p_header['crc'] = @crc32($v_content); |
|---|
| | 2732 | |
|---|
| | 2733 | // ----- Look for no compression |
|---|
| 2606 | 2734 | if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { |
|---|
| 2607 | 2735 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed"); |
|---|
| 2608 | | // ----- Read the file content |
|---|
| 2609 | | $v_content_compressed = @fread($v_file, $p_header['size']); |
|---|
| 2610 | | |
|---|
| 2611 | | // ----- Calculate the CRC |
|---|
| 2612 | | $p_header['crc'] = @crc32($v_content_compressed); |
|---|
| 2613 | | |
|---|
| 2614 | 2736 | // ----- Set header parameters |
|---|
| 2615 | 2737 | $p_header['compressed_size'] = $p_header['size']; |
|---|
| 2616 | 2738 | $p_header['compression'] = 0; |
|---|
| 2617 | 2739 | } |
|---|
| | 2740 | |
|---|
| | 2741 | // ----- Look for normal compression |
|---|
| 2618 | 2742 | else { |
|---|
| 2619 | 2743 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed"); |
|---|
| 2620 | | // ----- Read the file content |
|---|
| 2621 | | $v_content = @fread($v_file, $p_header['size']); |
|---|
| 2622 | | |
|---|
| 2623 | | // ----- Calculate the CRC |
|---|
| 2624 | | $p_header['crc'] = @crc32($v_content); |
|---|
| 2625 | | |
|---|
| 2626 | | // ----- Compress the file |
|---|
| 2627 | | $v_content_compressed = @gzdeflate($v_content); |
|---|
| | 2744 | // ----- Compress the content |
|---|
| | 2745 | $v_content = @gzdeflate($v_content); |
|---|
| 2628 | 2746 | |
|---|
| 2629 | 2747 | // ----- Set header parameters |
|---|
| 2630 | | $p_header['compressed_size'] = strlen($v_content_compressed); |
|---|
| | 2748 | $p_header['compressed_size'] = strlen($v_content); |
|---|
| 2631 | 2749 | $p_header['compression'] = 8; |
|---|
| 2632 | 2750 | } |
|---|
| … | … | |
| 2663 | 2781 | |
|---|
| 2664 | 2782 | // ----- Write the compressed (or not) content |
|---|
| 2665 | | @fwrite($this->zip_fd, |
|---|
| 2666 | | $v_content_compressed, $p_header['compressed_size']); |
|---|
| 2667 | | |
|---|
| 2668 | | // ----- Close the file |
|---|
| 2669 | | @fclose($v_file); |
|---|
| | 2783 | @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); |
|---|
| 2670 | 2784 | } |
|---|
| 2671 | 2785 | |
|---|
| 2672 | 2786 | // ----- Look for a directory |
|---|
| 2673 | | else { |
|---|
| | 2787 | else if ($p_filedescr['type'] == 'folder') { |
|---|
| 2674 | 2788 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a folder"); |
|---|
| 2675 | 2789 | // ----- Look for directory last '/' |
|---|
| … | … | |
| 2746 | 2860 | $p_remove_dir = ''; |
|---|
| 2747 | 2861 | } |
|---|
| | 2862 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Remove path ='".$p_remove_dir."'"); |
|---|
| 2748 | 2863 | if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
|---|
| 2749 | 2864 | $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|---|
| … | … | |
| 2784 | 2899 | // ----- Look for partial path remove |
|---|
| 2785 | 2900 | else if ($p_remove_dir != "") { |
|---|
| | 2901 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Partial path to remove"); |
|---|
| 2786 | 2902 | if (substr($p_remove_dir, -1) != '/') |
|---|
| 2787 | 2903 | $p_remove_dir .= "/"; |
|---|
| … | … | |
| 2906 | 3022 | $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|---|
| 2907 | 3023 | $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|---|
| | 3024 | |
|---|
| | 3025 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment size : \''.$p_header['comment_len'].'\''); |
|---|
| 2908 | 3026 | |
|---|
| 2909 | 3027 | // ----- Packed data |
|---|
| … | … | |
| 3072 | 3190 | // $p_info['folder'] = true/false : indicates if the entry is a folder or not. |
|---|
| 3073 | 3191 | // $p_info['status'] = status of the action on the file. |
|---|
| | 3192 | // $p_info['crc'] = CRC of the file content. |
|---|
| 3074 | 3193 | // Parameters : |
|---|
| 3075 | 3194 | // Return Values : |
|---|
| … | … | |
| 3090 | 3209 | $p_info['index'] = $p_header['index']; |
|---|
| 3091 | 3210 | $p_info['status'] = $p_header['status']; |
|---|
| | 3211 | $p_info['crc'] = $p_header['crc']; |
|---|
| 3092 | 3212 | |
|---|
| 3093 | 3213 | // ----- Return |
|---|
| … | … | |
| 3517 | 3637 | |
|---|
| 3518 | 3638 | // ----- Look for all path to remove |
|---|
| 3519 | | |
|---|
| 3520 | 3639 | if ($p_remove_all_path == true) { |
|---|
| 3521 | 3640 | // ----- Look for folder entry that not need to be extracted |
|---|
| … | … | |
| 4290 | 4409 | |
|---|
| 4291 | 4410 | // ----- Recuperate date in UNIX format |
|---|
| 4292 | | if ($p_header['mdate'] && $p_header['mtime']) |
|---|
| | 4411 | //if ($p_header['mdate'] && $p_header['mtime']) |
|---|
| | 4412 | // TBC : bug : this was ignoring time with 0/0/0 |
|---|
| | 4413 | if (1) |
|---|
| 4293 | 4414 | { |
|---|
| 4294 | 4415 | // ----- Extract time |
|---|
| … | … | |
| 4303 | 4424 | |
|---|
| 4304 | 4425 | // ----- Get UNIX date format |
|---|
| 4305 | | $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|---|
| | 4426 | $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|---|
| 4306 | 4427 | |
|---|
| 4307 | 4428 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); |
|---|
| … | … | |
| 4543 | 4664 | |
|---|
| 4544 | 4665 | // ----- Get comment |
|---|
| 4545 | | if ($v_data['comment_size'] != 0) |
|---|
| | 4666 | //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment size : \''.$v_data['comment_size'].'\''); |
|---|
| | 4667 | if ($v_data['comment_size'] != 0) { |
|---|
| 4546 | 4668 | $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); |
|---|
| | 4669 | } |
|---|
| 4547 | 4670 | else |
|---|
| 4548 | 4671 | $p_central_dir['comment'] = ''; |
|---|
| … | … | |
| 4952 | 5075 | |
|---|
| 4953 | 5076 | // ----- Check the directory availability |
|---|
| 4954 | | if ((@is_dir($p_dir)) || ($p_dir == "")) |
|---|
| | 5077 | if ((is_dir($p_dir)) || ($p_dir == "")) |
|---|
| 4955 | 5078 | { |
|---|
| 4956 | 5079 | //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory"); |
|---|
|