Updated to 2.4 Final. From notes: This resolve a lots of bad formated archive errors.
Merged from MOODLE_15_STABLE
This commit is contained in:
+239
-55
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
// --------------------------------------------------------------------------------
|
||||
// PhpConcept Library - Zip Module 2.4-RC1
|
||||
// PhpConcept Library - Zip Module 2.4
|
||||
// --------------------------------------------------------------------------------
|
||||
// License GNU/LGPL - Vincent Blavet - November 2004
|
||||
// http://www.phpconcept.net
|
||||
@@ -63,7 +63,7 @@
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
// ----- Global variables
|
||||
$g_pclzip_version = "2.4-RC1";
|
||||
$g_pclzip_version = "2.4";
|
||||
|
||||
// ----- Error codes
|
||||
// -1 : Unable to open file in binary write mode
|
||||
@@ -161,6 +161,11 @@
|
||||
// ----- 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
|
||||
var $magic_quotes_status;
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// Function : PclZip()
|
||||
@@ -184,6 +189,7 @@
|
||||
// ----- Set the attributes
|
||||
$this->zipname = $p_zipname;
|
||||
$this->zip_fd = 0;
|
||||
$this->magic_quotes_status = -1;
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1);
|
||||
@@ -639,7 +645,8 @@
|
||||
|
||||
// ----- Set default values
|
||||
$v_options = array();
|
||||
$v_path = "./";
|
||||
// $v_path = "./";
|
||||
$v_path = '';
|
||||
$v_remove_path = "";
|
||||
$v_remove_all_path = false;
|
||||
|
||||
@@ -797,7 +804,8 @@
|
||||
|
||||
// ----- Set default values
|
||||
$v_options = array();
|
||||
$v_path = "./";
|
||||
// $v_path = "./";
|
||||
$v_path = '';
|
||||
$v_remove_path = "";
|
||||
$v_remove_all_path = false;
|
||||
|
||||
@@ -921,10 +929,15 @@
|
||||
// Function :
|
||||
// delete([$p_option, $p_option_value, ...])
|
||||
// Description :
|
||||
// This method removes files from the archive.
|
||||
// If no parameters are given, then all the archive is emptied.
|
||||
// Parameters :
|
||||
// None
|
||||
// None or optional arguments.
|
||||
// Options :
|
||||
// PCLZIP_OPT_BY_INDEX :
|
||||
// PCLZIP_OPT_BY_NAME :
|
||||
// PCLZIP_OPT_BY_EREG :
|
||||
// PCLZIP_OPT_BY_PREG :
|
||||
// Return Values :
|
||||
// 0 on failure,
|
||||
// The list of the files which are still present in the archive.
|
||||
@@ -951,52 +964,38 @@
|
||||
$v_size = func_num_args();
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
|
||||
|
||||
// ----- Look for no arguments
|
||||
if ($v_size <= 0) {
|
||||
// ----- Error log
|
||||
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing arguments");
|
||||
// ----- Look for arguments
|
||||
if ($v_size > 0) {
|
||||
// ----- Get the arguments
|
||||
$v_arg_list = &func_get_args();
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----- Get the arguments
|
||||
$v_arg_list = &func_get_args();
|
||||
|
||||
// ----- Parse the options
|
||||
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
|
||||
// ----- Parse the options
|
||||
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
|
||||
array (PCLZIP_OPT_BY_NAME => 'optional',
|
||||
PCLZIP_OPT_BY_EREG => 'optional',
|
||||
PCLZIP_OPT_BY_PREG => 'optional',
|
||||
PCLZIP_OPT_BY_INDEX => 'optional' ));
|
||||
if ($v_result != 1) {
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
|
||||
return 0;
|
||||
if ($v_result != 1) {
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ----- Check that at least one rule is set
|
||||
if ( (!isset($v_options[PCLZIP_OPT_BY_NAME]))
|
||||
&& (!isset($v_options[PCLZIP_OPT_BY_EREG]))
|
||||
&& (!isset($v_options[PCLZIP_OPT_BY_PREG]))
|
||||
&& (!isset($v_options[PCLZIP_OPT_BY_INDEX]))) {
|
||||
// ----- Error log
|
||||
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "At least one filtering rule must be set");
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
|
||||
return 0;
|
||||
}
|
||||
// ----- Magic quotes trick
|
||||
$this->privDisableMagicQuotes();
|
||||
|
||||
// ----- Call the delete fct
|
||||
$v_list = array();
|
||||
if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1)
|
||||
{
|
||||
if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
|
||||
$this->privSwapBackMagicQuotes();
|
||||
unset($v_list);
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
|
||||
return(0);
|
||||
}
|
||||
|
||||
// ----- Magic quotes trick
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list);
|
||||
return $v_list;
|
||||
@@ -1042,8 +1041,12 @@
|
||||
// ----- Reset the error handler
|
||||
$this->privErrorReset();
|
||||
|
||||
// ----- Magic quotes trick
|
||||
$this->privDisableMagicQuotes();
|
||||
|
||||
// ----- Check archive
|
||||
if (!$this->privCheckFormat()) {
|
||||
$this->privSwapBackMagicQuotes();
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
|
||||
return(0);
|
||||
}
|
||||
@@ -1061,6 +1064,8 @@
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
|
||||
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');
|
||||
|
||||
@@ -1073,6 +1078,7 @@
|
||||
$v_central_dir = array();
|
||||
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
|
||||
{
|
||||
$this->privSwapBackMagicQuotes();
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
|
||||
return 0;
|
||||
}
|
||||
@@ -1086,6 +1092,9 @@
|
||||
$v_prop['status'] = 'ok';
|
||||
}
|
||||
|
||||
// ----- Magic quotes trick
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop);
|
||||
return $v_prop;
|
||||
@@ -1739,6 +1748,9 @@
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list, result_list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
|
||||
$v_result=1;
|
||||
$v_list_detail = array();
|
||||
|
||||
// ----- Magic quotes trick
|
||||
$this->privDisableMagicQuotes();
|
||||
|
||||
// ----- Open the file in write mode
|
||||
if (($v_result = $this->privOpenFd('wb')) != 1)
|
||||
@@ -1754,6 +1766,9 @@
|
||||
// ----- Close
|
||||
$this->privCloseFd();
|
||||
|
||||
// ----- Magic quotes trick
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
@@ -1784,11 +1799,16 @@
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
}
|
||||
// ----- Magic quotes trick
|
||||
$this->privDisableMagicQuotes();
|
||||
|
||||
// ----- Open the zip file
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
|
||||
if (($v_result=$this->privOpenFd('rb')) != 1)
|
||||
{
|
||||
// ----- Magic quotes trick
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
@@ -1799,6 +1819,7 @@
|
||||
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
|
||||
{
|
||||
$this->privCloseFd();
|
||||
$this->privSwapBackMagicQuotes();
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
}
|
||||
@@ -1816,6 +1837,7 @@
|
||||
if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
|
||||
{
|
||||
$this->privCloseFd();
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
|
||||
|
||||
@@ -1850,6 +1872,7 @@
|
||||
fclose($v_zip_temp_fd);
|
||||
$this->privCloseFd();
|
||||
@unlink($v_zip_temp_name);
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
@@ -1880,6 +1903,7 @@
|
||||
fclose($v_zip_temp_fd);
|
||||
$this->privCloseFd();
|
||||
@unlink($v_zip_temp_name);
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
@@ -1912,6 +1936,7 @@
|
||||
{
|
||||
// ----- Reset the file list
|
||||
unset($v_header_list);
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
@@ -1929,6 +1954,9 @@
|
||||
// ----- Close the temporary file
|
||||
@fclose($v_zip_temp_fd);
|
||||
|
||||
// ----- Magic quotes trick
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Delete the zip file
|
||||
// TBC : I should test the result ...
|
||||
@unlink($this->zipname);
|
||||
@@ -2419,9 +2447,13 @@
|
||||
}
|
||||
|
||||
// ----- Write the compressed (or not) content
|
||||
/* Try to speed up the code
|
||||
$v_binary_data = pack('a'.$p_header['compressed_size'],
|
||||
$v_content_compressed);
|
||||
@fwrite($this->zip_fd, $v_binary_data, $p_header['compressed_size']);
|
||||
*/
|
||||
@fwrite($this->zip_fd,
|
||||
$v_content_compressed, $p_header['compressed_size']);
|
||||
|
||||
// ----- Close the file
|
||||
@fclose($v_file);
|
||||
@@ -2628,10 +2660,16 @@
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list");
|
||||
$v_result=1;
|
||||
|
||||
// ----- Magic quotes trick
|
||||
$this->privDisableMagicQuotes();
|
||||
|
||||
// ----- Open the zip file
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
|
||||
if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
|
||||
{
|
||||
// ----- Magic quotes trick
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Error log
|
||||
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
|
||||
|
||||
@@ -2644,6 +2682,7 @@
|
||||
$v_central_dir = array();
|
||||
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
|
||||
{
|
||||
$this->privSwapBackMagicQuotes();
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
}
|
||||
@@ -2655,6 +2694,8 @@
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
|
||||
if (@fseek($this->zip_fd, $v_central_dir['offset']))
|
||||
{
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Error log
|
||||
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
|
||||
|
||||
@@ -2670,6 +2711,7 @@
|
||||
// ----- Read the file header
|
||||
if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
|
||||
{
|
||||
$this->privSwapBackMagicQuotes();
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
}
|
||||
@@ -2683,6 +2725,9 @@
|
||||
// ----- Close the zip file
|
||||
$this->privCloseFd();
|
||||
|
||||
// ----- Magic quotes trick
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
@@ -2750,8 +2795,14 @@
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
|
||||
$v_result=1;
|
||||
|
||||
// ----- Magic quotes trick
|
||||
$this->privDisableMagicQuotes();
|
||||
|
||||
// ----- Check the path
|
||||
if (($p_path == "") || ((substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../") && (substr($p_path,1,2)!=":/")))
|
||||
if ( ($p_path == "")
|
||||
|| ( (substr($p_path, 0, 1) != "/")
|
||||
&& (substr($p_path, 0, 3) != "../")
|
||||
&& (substr($p_path,1,2)!=":/")))
|
||||
$p_path = "./".$p_path;
|
||||
|
||||
// ----- Reduce the path last (and duplicated) '/'
|
||||
@@ -2777,6 +2828,7 @@
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
|
||||
if (($v_result = $this->privOpenFd('rb')) != 1)
|
||||
{
|
||||
$this->privSwapBackMagicQuotes();
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
}
|
||||
@@ -2787,6 +2839,7 @@
|
||||
{
|
||||
// ----- Close the zip file
|
||||
$this->privCloseFd();
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
@@ -2809,6 +2862,7 @@
|
||||
{
|
||||
// ----- Close the zip file
|
||||
$this->privCloseFd();
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Error log
|
||||
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
|
||||
@@ -2825,6 +2879,7 @@
|
||||
{
|
||||
// ----- Close the zip file
|
||||
$this->privCloseFd();
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
@@ -2932,6 +2987,8 @@
|
||||
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
|
||||
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
|
||||
"Filename '".$v_header['stored_filename']."' is "
|
||||
."compressed by an unsupported compression "
|
||||
@@ -2952,6 +3009,8 @@
|
||||
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
|
||||
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
|
||||
"Unsupported encryption for "
|
||||
." filename '".$v_header['stored_filename']
|
||||
@@ -2969,6 +3028,7 @@
|
||||
$p_file_list[$v_nb_extracted++]);
|
||||
if ($v_result != 1) {
|
||||
$this->privCloseFd();
|
||||
$this->privSwapBackMagicQuotes();
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
}
|
||||
@@ -2990,6 +3050,8 @@
|
||||
// ----- Close the zip file
|
||||
$this->privCloseFd();
|
||||
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Error log
|
||||
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
|
||||
|
||||
@@ -3006,6 +3068,7 @@
|
||||
$v_result1 = $this->privExtractFileAsString($v_header, $v_string);
|
||||
if ($v_result1 < 1) {
|
||||
$this->privCloseFd();
|
||||
$this->privSwapBackMagicQuotes();
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
|
||||
return $v_result1;
|
||||
}
|
||||
@@ -3015,6 +3078,7 @@
|
||||
{
|
||||
// ----- Close the zip file
|
||||
$this->privCloseFd();
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
@@ -3038,6 +3102,7 @@
|
||||
$v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
|
||||
if ($v_result1 < 1) {
|
||||
$this->privCloseFd();
|
||||
$this->privSwapBackMagicQuotes();
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
|
||||
return $v_result1;
|
||||
}
|
||||
@@ -3045,6 +3110,7 @@
|
||||
// ----- Get the only interesting attributes
|
||||
if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
|
||||
$this->privCloseFd();
|
||||
$this->privSwapBackMagicQuotes();
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
}
|
||||
@@ -3063,6 +3129,7 @@
|
||||
$p_options);
|
||||
if ($v_result1 < 1) {
|
||||
$this->privCloseFd();
|
||||
$this->privSwapBackMagicQuotes();
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
|
||||
return $v_result1;
|
||||
}
|
||||
@@ -3072,6 +3139,7 @@
|
||||
{
|
||||
// ----- Close the zip file
|
||||
$this->privCloseFd();
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
@@ -3087,6 +3155,7 @@
|
||||
|
||||
// ----- Close the zip file
|
||||
$this->privCloseFd();
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
@@ -3351,9 +3420,12 @@
|
||||
{
|
||||
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");
|
||||
$v_buffer = fread($this->zip_fd, $v_read_size);
|
||||
$v_buffer = @fread($this->zip_fd, $v_read_size);
|
||||
/* Try to speed up the code
|
||||
$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);
|
||||
$v_size -= $v_read_size;
|
||||
}
|
||||
|
||||
@@ -3743,6 +3815,8 @@
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\'');
|
||||
$p_header['flag'] = $v_data['flag'];
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\'');
|
||||
$p_header['filename_len'] = $v_data['filename_len'];
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename_len : \''.$p_header['filename_len'].'\'');
|
||||
|
||||
// ----- Recuperate date in UNIX format
|
||||
$p_header['mdate'] = $v_data['mdate'];
|
||||
@@ -4317,6 +4391,10 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "No argument mean remove all file");
|
||||
$v_found = true;
|
||||
}
|
||||
|
||||
// ----- Look for deletion
|
||||
if ($v_found)
|
||||
@@ -4911,6 +4989,86 @@
|
||||
}
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// Function : privDisableMagicQuotes()
|
||||
// Description :
|
||||
// Parameters :
|
||||
// Return Values :
|
||||
// --------------------------------------------------------------------------------
|
||||
function privDisableMagicQuotes()
|
||||
{
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDisableMagicQuotes', "");
|
||||
$v_result=1;
|
||||
|
||||
// ----- Look if function exists
|
||||
if ( (!function_exists("get_magic_quotes_runtime"))
|
||||
|| (!function_exists("set_magic_quotes_runtime"))) {
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported");
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
}
|
||||
|
||||
// ----- Look if already done
|
||||
if ($this->magic_quotes_status != -1) {
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote already disabled");
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
}
|
||||
|
||||
// ----- Get and memorize the magic_quote value
|
||||
$this->magic_quotes_status = @get_magic_quotes_runtime();
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Current magic_quotes_runtime status is '".($this->magic_quotes_status==0?'disable':'enable')."'");
|
||||
|
||||
// ----- Disable magic_quotes
|
||||
if ($this->magic_quotes_status == 1) {
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Disable magic_quotes");
|
||||
@set_magic_quotes_runtime(0);
|
||||
}
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
}
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// Function : privSwapBackMagicQuotes()
|
||||
// Description :
|
||||
// Parameters :
|
||||
// Return Values :
|
||||
// --------------------------------------------------------------------------------
|
||||
function privSwapBackMagicQuotes()
|
||||
{
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privSwapBackMagicQuotes', "");
|
||||
$v_result=1;
|
||||
|
||||
// ----- Look if function exists
|
||||
if ( (!function_exists("get_magic_quotes_runtime"))
|
||||
|| (!function_exists("set_magic_quotes_runtime"))) {
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported");
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
}
|
||||
|
||||
// ----- Look if something to do
|
||||
if ($this->magic_quotes_status != -1) {
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote not modified");
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
}
|
||||
|
||||
// ----- Swap back magic_quotes
|
||||
if ($this->magic_quotes_status == 1) {
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Enable back magic_quotes");
|
||||
@set_magic_quotes_runtime($this->magic_quotes_status);
|
||||
}
|
||||
|
||||
// ----- Return
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
|
||||
return $v_result;
|
||||
}
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
// End of class
|
||||
// --------------------------------------------------------------------------------
|
||||
@@ -4927,33 +5085,59 @@
|
||||
$v_result = "";
|
||||
|
||||
// ----- Look for not empty path
|
||||
if ($p_dir != "")
|
||||
{
|
||||
if ($p_dir != "") {
|
||||
// ----- Explode path by directory names
|
||||
$v_list = explode("/", $p_dir);
|
||||
|
||||
// ----- Study directories from last to first
|
||||
for ($i=sizeof($v_list)-1; $i>=0; $i--)
|
||||
{
|
||||
$v_skip = 0;
|
||||
for ($i=sizeof($v_list)-1; $i>=0; $i--) {
|
||||
// ----- Look for current path
|
||||
if ($v_list[$i] == ".")
|
||||
{
|
||||
if ($v_list[$i] == ".") {
|
||||
// ----- Ignore this directory
|
||||
// Should be the first $i=0, but no check is done
|
||||
}
|
||||
else if ($v_list[$i] == "..")
|
||||
{
|
||||
// ----- Ignore it and ignore the $i-1
|
||||
$i--;
|
||||
else if ($v_list[$i] == "..") {
|
||||
$v_skip++;
|
||||
}
|
||||
else if (($v_list[$i] == "") && ($i!=(sizeof($v_list)-1)) && ($i!=0))
|
||||
{
|
||||
// ----- Ignore only the double '//' in path,
|
||||
// but not the first and last '/'
|
||||
else if ($v_list[$i] == "") {
|
||||
// ----- First '/' i.e. root slash
|
||||
if ($i == 0) {
|
||||
$v_result = "/".$v_result;
|
||||
if ($v_skip > 0) {
|
||||
// ----- It is an invalid path, so the path is not modified
|
||||
// TBC
|
||||
$v_result = $p_dir;
|
||||
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid path is unchanged");
|
||||
$v_skip = 0;
|
||||
}
|
||||
}
|
||||
// ----- Last '/' i.e. indicates a directory
|
||||
else if ($i == (sizeof($v_list)-1)) {
|
||||
$v_result = $v_list[$i];
|
||||
}
|
||||
// ----- Double '/' inside the path
|
||||
else {
|
||||
// ----- Ignore only the double '//' in path,
|
||||
// but not the first and last '/'
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
|
||||
else {
|
||||
// ----- Look for item to skip
|
||||
if ($v_skip > 0) {
|
||||
$v_skip--;
|
||||
}
|
||||
else {
|
||||
$v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----- Look for skip
|
||||
if ($v_skip > 0) {
|
||||
while ($v_skip > 0) {
|
||||
$v_result = '../'.$v_result;
|
||||
$v_skip--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-2
@@ -1,5 +1,5 @@
|
||||
// --------------------------------------------------------------------------------
|
||||
// PclZip 2.4-RC1 - readme.txt
|
||||
// PclZip 2.4 - readme.txt
|
||||
// --------------------------------------------------------------------------------
|
||||
// License GNU/LGPL - November 2004
|
||||
// Vincent Blavet - [email protected]
|
||||
@@ -31,7 +31,15 @@
|
||||
2 - What's new
|
||||
==============
|
||||
|
||||
Version 2.4-RC1 :
|
||||
Version 2.4 :
|
||||
- Code improvment : try to speed up the code by removing unusefull call to pack()
|
||||
- Correct bug in delete() : delete() should be called with no argument. This was not
|
||||
the case in 2.3. This is corrected in 2.4.
|
||||
- Correct a bug in path_inclusion function. When the path has several '../../', the
|
||||
result was bad.
|
||||
- Add a check for magic_quotes_runtime configuration. If enabled, PclZip will
|
||||
disable it while working and det it back to its original value.
|
||||
This resolve a lots of bad formated archive errors.
|
||||
- Bug correction : PclZip now correctly unzip file in some specific situation,
|
||||
when compressed content has same size as uncompressed content.
|
||||
- Bug correction : When selecting option 'PCLZIP_OPT_REMOVE_ALL_PATH',
|
||||
|
||||
Reference in New Issue
Block a user