diff --git a/lib/pclzip/pclzip.class.php b/lib/pclzip/pclzip.class.php index 8c8614982f..33f3b28ba1 100644 --- a/lib/pclzip/pclzip.class.php +++ b/lib/pclzip/pclzip.class.php @@ -29,7 +29,7 @@ if (!defined('PCLZIP_READ_BLOCK_SIZE')) { define( 'PCLZIP_READ_BLOCK_SIZE', 2048 ); } - + // ----- File list separator // In version 1.x of PclZip, the separator for file list is a space // (which is not a very smart choice, specifically for windows paths !). @@ -68,7 +68,7 @@ // ----- Optional threshold ratio for use of temporary files // Pclzip sense the size of the file to add/extract and decide to - // use or not temporary file. The algorythm is looking for + // use or not temporary file. The algorythm is looking for // memory_limit of PHP and apply a ratio. // threshold = memory_limit * ratio. // Recommended values are under 0.5. Default 0.47. @@ -152,7 +152,7 @@ define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 ); define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias - + // ----- File description attributes define( 'PCLZIP_ATT_FILE_NAME', 79001 ); define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 ); @@ -198,7 +198,7 @@ // ----- Internal error handling var $error_code = 1; var $error_string = ''; - + // ----- Current status of the magic_quotes_runtime // This value store the php configuration for magic_quotes // The class can then disable the magic_quotes and reset it after @@ -332,7 +332,7 @@ } } } - + // ----- Look for default option values $this->privOptionDefaultThreshold($v_options); @@ -341,16 +341,16 @@ $v_att_list = array(); $v_filedescr_list = array(); $p_result_list = array(); - + // ----- Look if the $p_filelist is really an array if (is_array($p_filelist)) { - + // ----- Look if the first element is also an array // This will mean that this is a file description entry if (isset($p_filelist[0]) && is_array($p_filelist[0])) { $v_att_list = $p_filelist; } - + // ----- The list is a list of string names else { $v_string_list = $p_filelist; @@ -368,7 +368,7 @@ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); return 0; } - + // ----- Reformat the string list if (sizeof($v_string_list) != 0) { foreach ($v_string_list as $v_string) { @@ -379,7 +379,7 @@ } } } - + // ----- For each file in the list check the attributes $v_supported_attributes = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' @@ -528,16 +528,16 @@ $v_att_list = array(); $v_filedescr_list = array(); $p_result_list = array(); - + // ----- Look if the $p_filelist is really an array if (is_array($p_filelist)) { - + // ----- Look if the first element is also an array // This will mean that this is a file description entry if (isset($p_filelist[0]) && is_array($p_filelist[0])) { $v_att_list = $p_filelist; } - + // ----- The list is a list of string names else { $v_string_list = $p_filelist; @@ -555,14 +555,14 @@ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); return 0; } - + // ----- Reformat the string list if (sizeof($v_string_list) != 0) { foreach ($v_string_list as $v_string) { $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; } } - + // ----- For each file in the list check the attributes $v_supported_attributes = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' @@ -996,7 +996,7 @@ // Options : // PCLZIP_OPT_BY_INDEX : // PCLZIP_OPT_BY_NAME : - // PCLZIP_OPT_BY_EREG : + // PCLZIP_OPT_BY_EREG : // PCLZIP_OPT_BY_PREG : // Return Values : // 0 on failure, @@ -1064,7 +1064,7 @@ // -------------------------------------------------------------------------------- function deleteByIndex($p_index) { - + $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); // ----- Return @@ -1114,7 +1114,7 @@ if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) { $this->privSwapBackMagicQuotes(); - + // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); @@ -1426,7 +1426,7 @@ function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) { $v_result=1; - + // ----- Read the options $i=0; while ($i<$p_size) { @@ -1466,13 +1466,13 @@ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); return PclZip::errorCode(); } - + // ----- Check for incompatible options if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); return PclZip::errorCode(); } - + // ----- Check the value $v_value = $p_options_list[$i+1]; if ((!is_integer($v_value)) || ($v_value<0)) { @@ -1491,7 +1491,7 @@ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); return PclZip::errorCode(); } - + $v_result_list[$p_options_list[$i]] = true; break; @@ -1506,7 +1506,7 @@ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'"); return PclZip::errorCode(); } - + $v_result_list[$p_options_list[$i]] = true; break; @@ -1655,7 +1655,7 @@ // ----- Return return PclZip::errorCode(); } - + // ----- Reduce the index list // each index item in the list must be a couple with a start and // an end value : [0,3], [5-5], [8-10], ... @@ -1666,10 +1666,10 @@ // ----- Explode the item $v_item_list = explode("-", $v_work_list[$j]); $v_size_item_list = sizeof($v_item_list); - + // ----- TBC : Here we might check that each item is a // real integer ... - + // ----- Look for single value if ($v_size_item_list == 1) { // ----- Set the option value @@ -1703,7 +1703,7 @@ } $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start']; } - + // ----- Sort the items if ($v_sort_flag) { // TBC : To Be Completed @@ -1806,10 +1806,10 @@ } } } - + // ----- Look for default values if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { - + } // ----- Return @@ -1826,12 +1826,12 @@ function privOptionDefaultThreshold(&$p_options) { $v_result=1; - + if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) { return $v_result; } - + // ----- Get 'memory_limit' configuration value $v_memory_limit = ini_get('memory_limit'); $v_memory_limit = trim($v_memory_limit); @@ -1846,15 +1846,15 @@ $v_memory_limit = $v_memory_limit*1048576; if($last == 'k') $v_memory_limit = $v_memory_limit*1024; - + $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO); - + // ----- Sanity check : No threshold if value lower than 1M if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) { unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]); } - + // ----- Return return $v_result; } @@ -1871,10 +1871,10 @@ function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) { $v_result=1; - + // ----- For each file in the list check the attributes foreach ($p_file_list as $v_key => $v_value) { - + // ----- Check if the option is supported if (!isset($v_requested_options[$v_key])) { // ----- Error log @@ -1893,7 +1893,7 @@ } $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); - + if ($p_filedescr['filename'] == '') { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); return PclZip::errorCode(); @@ -1974,10 +1974,10 @@ } } } - + // end foreach } - + // ----- Return return $v_result; } @@ -1990,7 +1990,7 @@ // or a string to be added as file. For any other type of files (link, other) // just ignore the item. // Then prepare the information that will be stored for that file. - // When its a folder, expand the folder with all the files that are in that + // When its a folder, expand the folder with all the files that are in that // folder (recursively). // Parameters : // Return Values : @@ -2000,20 +2000,20 @@ function privFileDescrExpand(&$p_filedescr_list, &$p_options) { $v_result=1; - + // ----- Create a result list $v_result_list = array(); - + // ----- Look each entry for ($i=0; $iprivCalculateStoredFilename($v_descr, $p_options); - + // ----- Add the descriptor in result list $v_result_list[sizeof($v_result_list)] = $v_descr; - + // ----- Look for folder if ($v_descr['type'] == 'folder') { // ----- List of items in folder @@ -2064,10 +2064,10 @@ if (($v_item_handler == '.') || ($v_item_handler == '..')) { continue; } - + // ----- Compose the full filename $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; - + // ----- Look for different stored filename // Because the name of the folder was changed, the name of the // files/sub-folders also change @@ -2080,34 +2080,34 @@ $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; } } - + $v_dirlist_nb++; } - + @closedir($v_folder_handler); } else { // TBC : unable to open folder in read mode } - + // ----- Expand each element of the list if ($v_dirlist_nb != 0) { // ----- Expand if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) { return $v_result; } - + // ----- Concat the resulting list $v_result_list = array_merge($v_result_list, $v_dirlist_descr); } else { } - + // ----- Free local array unset($v_dirlist_descr); } } - + // ----- Get the result list $p_filedescr_list = $v_result_list; @@ -2126,7 +2126,7 @@ { $v_result=1; $v_list_detail = array(); - + // ----- Magic quotes trick $this->privDisableMagicQuotes(); @@ -2456,7 +2456,7 @@ // Function : privAddFileList() // Description : // Parameters : - // $p_filedescr_list : An array containing the file description + // $p_filedescr_list : An array containing the file description // or directory names to add in the zip // $p_result_list : list of added files with their properties (specially the status field) // Return Values : @@ -2474,7 +2474,7 @@ // ----- Format the filename $p_filedescr_list[$j]['filename'] = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); - + // ----- Skip empty file names // TBC : Can this be possible ? not checked in DescrParseAtt ? @@ -2526,7 +2526,7 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) { $v_result=1; - + // ----- Working variable $p_filename = $p_filedescr['filename']; @@ -2538,8 +2538,8 @@ // ----- Return return PclZip::errorCode(); } - - // ----- Look for a stored different filename + + // ----- Look for a stored different filename /* TBC : Removed if (isset($p_filedescr['stored_filename'])) { $v_stored_filename = $p_filedescr['stored_filename']; @@ -2564,7 +2564,7 @@ $p_header['offset'] = 0; $p_header['filename'] = $p_filename; // TBC : Removed $p_header['stored_filename'] = $v_stored_filename; - $p_header['stored_filename'] = $p_filedescr['stored_filename']; + $p_header['stored_filename'] = strpos(helper::getOS(), 'Windows') !== false ? mb_convert_encoding($p_filedescr['stored_filename'],'GB2312','UTF-8') : $p_filedescr['stored_filename']; $p_header['extra'] = ''; $p_header['status'] = 'ok'; $p_header['index'] = -1; @@ -2574,20 +2574,20 @@ $p_header['external'] = 0x00000000; $p_header['size'] = filesize($p_filename); } - + // ----- Look for regular folder else if ($p_filedescr['type']=='folder') { $p_header['external'] = 0x00000010; $p_header['mtime'] = filemtime($p_filename); $p_header['size'] = filesize($p_filename); } - + // ----- Look for virtual file else if ($p_filedescr['type'] == 'virtual_file') { $p_header['external'] = 0x00000000; $p_header['size'] = strlen($p_filedescr['content']); } - + // ----- Look for filetime if (isset($p_filedescr['mtime'])) { @@ -2639,7 +2639,7 @@ if ($p_header['stored_filename'] == "") { $p_header['status'] = "filtered"; } - + // ----- Check the path length if (strlen($p_header['stored_filename']) > 0xFF) { $p_header['status'] = 'filename_too_long'; @@ -2651,7 +2651,7 @@ // ----- Look for a file if ($p_filedescr['type'] == 'file') { // ----- Look for using temporary file to zip - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) + if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) { @@ -2660,7 +2660,7 @@ return $v_result; } } - + // ----- Use "in memory" zip algo else { @@ -2678,14 +2678,14 @@ // ----- Calculate the CRC $p_header['crc'] = @crc32($v_content); - + // ----- Look for no compression if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { // ----- Set header parameters $p_header['compressed_size'] = $p_header['size']; $p_header['compression'] = 0; } - + // ----- Look for normal compression else { // ----- Compress the content @@ -2695,7 +2695,7 @@ $p_header['compressed_size'] = strlen($v_content); $p_header['compression'] = 8; } - + // ----- Call the header generation if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { @fclose($v_file); @@ -2711,19 +2711,19 @@ // ----- Look for a virtual file (a file from string) else if ($p_filedescr['type'] == 'virtual_file') { - + $v_content = $p_filedescr['content']; // ----- Calculate the CRC $p_header['crc'] = @crc32($v_content); - + // ----- Look for no compression if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { // ----- Set header parameters $p_header['compressed_size'] = $p_header['size']; $p_header['compression'] = 0; } - + // ----- Look for normal compression else { // ----- Compress the content @@ -2733,7 +2733,7 @@ $p_header['compressed_size'] = strlen($v_content); $p_header['compression'] = 8; } - + // ----- Call the header generation if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { @fclose($v_file); @@ -2799,7 +2799,7 @@ function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) { $v_result=PCLZIP_ERR_NO_ERROR; - + // ----- Working variable $p_filename = $p_filedescr['filename']; @@ -2894,7 +2894,7 @@ // ----- Unlink the temporary file @unlink($v_gzip_temp_name); - + // ----- Return return $v_result; } @@ -2911,7 +2911,7 @@ function privCalculateStoredFilename(&$p_filedescr, &$p_options) { $v_result=1; - + // ----- Working variables $p_filename = $p_filedescr['filename']; if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { @@ -2939,7 +2939,7 @@ // ----- Remove drive letter if any $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']); } - + // ----- Look for path and/or short name change else { @@ -2969,7 +2969,7 @@ if ( (substr($p_filename, 0, 2) == "./") || (substr($p_remove_dir, 0, 2) == "./")) { - + if ( (substr($p_filename, 0, 2) == "./") && (substr($p_remove_dir, 0, 2) != "./")) { $p_remove_dir = "./".$p_remove_dir; @@ -2992,10 +2992,10 @@ } } } - + // ----- Remove drive letter if any $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename); - + // ----- Look for path to add if ($p_add_dir != "") { if (substr($p_add_dir, -1) == "/") @@ -3008,7 +3008,7 @@ // ----- Filename (reduce the path of stored name) $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); $p_filedescr['stored_filename'] = $v_stored_filename; - + // ----- Return return $v_result; } @@ -3159,7 +3159,7 @@ { // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); - + // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); @@ -3390,7 +3390,7 @@ // ----- Look for extract by ereg rule // ereg() is deprecated with PHP 5.3 - /* + /* else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { @@ -3412,7 +3412,7 @@ // ----- Look for extract by index rule else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { - + // ----- Look if the index is in the list for ($j=$j_start; ($jprivSwapBackMagicQuotes(); - + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, "Filename '".$v_header['stored_filename']."' is " ."compressed by an unsupported compression " @@ -3454,7 +3454,7 @@ return PclZip::errorCode(); } } - + // ----- Check encrypted files if (($v_extract) && (($v_header['flag'] & 1) == 1)) { $v_header['status'] = 'unsupported_encryption'; @@ -3486,7 +3486,7 @@ $v_extract = false; } - + // ----- Look for real extraction if ($v_extract) { @@ -3535,7 +3535,7 @@ // ----- Next extracted file $v_nb_extracted++; - + // ----- Look for user callback abort if ($v_result1 == 2) { break; @@ -3671,12 +3671,12 @@ if ($p_path != '') { $p_entry['filename'] = $p_path."/".$p_entry['filename']; } - + // ----- Check a base_dir_restriction if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { $v_inclusion = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], - $p_entry['filename']); + $p_entry['filename']); if ($v_inclusion == 0) { PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, @@ -3704,7 +3704,7 @@ $p_entry['status'] = "skipped"; $v_result = 1; } - + // ----- Look for abort result if ($v_result == 2) { // ----- This status is internal and will be changed in 'skipped' @@ -3731,7 +3731,7 @@ // ----- Change the file status $p_entry['status'] = "already_a_directory"; - + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR // For historical reason first PclZip implementation does not stop // when this kind of error occurs. @@ -3804,10 +3804,10 @@ $v_dir_to_check = dirname($p_entry['filename']); if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { - + // ----- Change the file status $p_entry['status'] = "path_creation_fail"; - + // ----- Return //return $v_result; $v_result = 1; @@ -3846,7 +3846,7 @@ $v_binary_data = pack('a'.$v_read_size, $v_buffer); @fwrite($v_dest_file, $v_binary_data, $v_read_size); */ - @fwrite($v_dest_file, $v_buffer, $v_read_size); + @fwrite($v_dest_file, $v_buffer, $v_read_size); $v_size -= $v_read_size; } @@ -3855,7 +3855,7 @@ // ----- Change the file mtime touch($p_entry['filename'], $p_entry['mtime']); - + } else { @@ -3868,7 +3868,7 @@ // ----- Look for using temporary file to unzip - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) + if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) { @@ -3877,42 +3877,42 @@ return $v_result; } } - + // ----- Look for extract in memory else { - + // ----- Read the compressed file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); - + // ----- Decompress the file $v_file_content = @gzinflate($v_buffer); unset($v_buffer); if ($v_file_content === FALSE) { - + // ----- Change the file status // TBC $p_entry['status'] = "error"; - + return $v_result; } - + // ----- Opening destination file if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { - + // ----- Change the file status $p_entry['status'] = "write_error"; - + return $v_result; } - + // ----- Write the uncompressed data @fwrite($v_dest_file, $v_file_content, $p_entry['size']); unset($v_file_content); - + // ----- Closing the destination file @fclose($v_dest_file); - + } // ----- Change the file mtime @@ -3933,7 +3933,7 @@ if ($p_entry['status'] == "aborted") { $p_entry['status'] = "skipped"; } - + // ----- Look for post-extract callback elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { @@ -3967,7 +3967,7 @@ function privExtractFileUsingTempFile(&$p_entry, &$p_options) { $v_result=1; - + // ----- Creates a temporary file $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) { @@ -4028,7 +4028,7 @@ // ----- Delete the temporary file @unlink($v_gzip_temp_name); - + // ----- Return return $v_result; } @@ -4106,7 +4106,7 @@ // ----- Read the compressed file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); - + // ----- Decompress the file $v_file_content = gzinflate($v_buffer); unset($v_buffer); @@ -4187,7 +4187,7 @@ $p_entry['status'] = "skipped"; $v_result = 1; } - + // ----- Look for abort result if ($v_result == 2) { // ----- This status is internal and will be changed in 'skipped' @@ -4209,41 +4209,41 @@ // ----- Look for not compressed file // if ($p_entry['compressed_size'] == $p_entry['size']) if ($p_entry['compression'] == 0) { - + // ----- Reading the file $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); } else { - + // ----- Reading the file $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); - + // ----- Decompress the file if (($p_string = @gzinflate($v_data)) === FALSE) { // TBC } } - + // ----- Trace } else { // TBC : error : can not extract a folder in a string } - + } // ----- Change abort status if ($p_entry['status'] == "aborted") { $p_entry['status'] = "skipped"; } - + // ----- Look for post-extract callback elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_entry, $v_local_header); - + // ----- Swap the content to header $v_local_header['content'] = $p_string; $p_string = ''; @@ -4504,7 +4504,7 @@ } if ($p_local_header['filename_len'] != $p_central_header['filename_len']) { } - + // ----- Look for flag bit 3 if (($p_local_header['flag'] & 8) == 8) { $p_local_header['size'] = $p_central_header['size']; @@ -4590,9 +4590,9 @@ // ----- Add the byte //$v_bytes = ($v_bytes << 8) | Ord($v_byte); - // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number - // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. - $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); + // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number + // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. + $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); // ----- Compare the bytes if ($v_bytes == 0x504b0506) @@ -4870,7 +4870,7 @@ // ----- Return return $v_result; } - + // ----- Check that local file header is same as central file header if ($this->privCheckFileHeaders($v_local_header, $v_header_list[$i]) != 1) { @@ -4954,11 +4954,11 @@ // TBC : I should test the result ... //@rename($v_zip_temp_name, $this->zipname); PclZipUtilRename($v_zip_temp_name, $this->zipname); - + // ----- Destroy the temporary archive unset($v_temp_zip); } - + // ----- Remove every files : reset the file else if ($v_central_dir['entries'] != 0) { $this->privCloseFd(); @@ -5445,7 +5445,7 @@ } } } - + // ----- Look for skip if ($v_skip > 0) { while ($v_skip > 0) { @@ -5478,7 +5478,7 @@ function PclZipUtilPathInclusion($p_dir, $p_path) { $v_result = 1; - + // ----- Look for path beginning by ./ if ( ($p_dir == '.') || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { @@ -5646,7 +5646,7 @@ // -------------------------------------------------------------------------------- function PclZipUtilOptionText($p_option) { - + $v_list = get_defined_constants(); for (reset($v_list); $v_key = key($v_list); next($v_list)) { $v_prefix = substr($v_key, 0, 10); @@ -5657,7 +5657,7 @@ return $v_key; } } - + $v_result = 'Unknown'; return $v_result; diff --git a/lib/scm/gitrepo.class.php b/lib/scm/gitrepo.class.php index 8e15b8b80f..335768ffb5 100644 --- a/lib/scm/gitrepo.class.php +++ b/lib/scm/gitrepo.class.php @@ -702,7 +702,6 @@ class GitRepo $files = ''; foreach($gitDir as $path) { - if(strpos(helper::getOS(), 'windows') !== false) $path = iconv("UTF-8", "GB2312", $path); if(!in_array($path, array('.', '..', '.git'))) $files .= $this->root . DS . "$path,"; } diff --git a/lib/scm/gogs.class.php b/lib/scm/gogs.class.php index 848bf0ccdb..739fe97dce 100644 --- a/lib/scm/gogs.class.php +++ b/lib/scm/gogs.class.php @@ -721,10 +721,8 @@ class Gogs $files = ''; foreach($gitDir as $path) { - if(strpos(helper::getOS(), 'Windows') !== false) $path = mb_convert_encoding($path, "GB2312", 'UTF-8'); if(!in_array($path, array('.', '..', '.git'))) $files .= $this->root . DS . "$path,"; } - //a(explode(',', $files)); die; $app->loadClass('pclzip', true); $fileName = $savePath . DS . "{$this->repo->name}_$branch.zip"; diff --git a/lib/scm/subversion.class.php b/lib/scm/subversion.class.php index 48f0930a28..1f96c6e6f2 100644 --- a/lib/scm/subversion.class.php +++ b/lib/scm/subversion.class.php @@ -701,8 +701,7 @@ class Subversion /* Get repo name. */ $pathList = explode('/', trim($this->root, '/')); $repoDir = $savePath . DS . end($pathList); - execCmd(escapeCmd("$this->client export $this->root $repoDir")); - + $res = execCmd($this->replaceAuth(escapeCmd("$this->client export $this->root $repoDir"))); $fileName = $savePath . DS . "{$this->repo->name}.zip"; $app->loadClass('pclzip', true); $zip = new pclzip($fileName);