Edit File by line
/home/barbar84/www/extracte.../filemang...
File: pclzip.lib.php
$this->privCloseFd();
[3500] Fix | Delete
[3501] Fix | Delete
$this->privSwapBackMagicQuotes();
[3502] Fix | Delete
[3503] Fix | Delete
// ----- Error log
[3504] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
[3505] Fix | Delete
[3506] Fix | Delete
// ----- Return
[3507] Fix | Delete
return PclZip::errorCode();
[3508] Fix | Delete
}
[3509] Fix | Delete
[3510] Fix | Delete
// ----- Look for extraction as string
[3511] Fix | Delete
if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
[3512] Fix | Delete
[3513] Fix | Delete
$v_string = '';
[3514] Fix | Delete
[3515] Fix | Delete
// ----- Extracting the file
[3516] Fix | Delete
$v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
[3517] Fix | Delete
if ($v_result1 < 1) {
[3518] Fix | Delete
$this->privCloseFd();
[3519] Fix | Delete
$this->privSwapBackMagicQuotes();
[3520] Fix | Delete
return $v_result1;
[3521] Fix | Delete
}
[3522] Fix | Delete
[3523] Fix | Delete
// ----- Get the only interesting attributes
[3524] Fix | Delete
if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
[3525] Fix | Delete
{
[3526] Fix | Delete
// ----- Close the zip file
[3527] Fix | Delete
$this->privCloseFd();
[3528] Fix | Delete
$this->privSwapBackMagicQuotes();
[3529] Fix | Delete
[3530] Fix | Delete
return $v_result;
[3531] Fix | Delete
}
[3532] Fix | Delete
[3533] Fix | Delete
// ----- Set the file content
[3534] Fix | Delete
$p_file_list[$v_nb_extracted]['content'] = $v_string;
[3535] Fix | Delete
[3536] Fix | Delete
// ----- Next extracted file
[3537] Fix | Delete
$v_nb_extracted++;
[3538] Fix | Delete
[3539] Fix | Delete
// ----- Look for user callback abort
[3540] Fix | Delete
if ($v_result1 == 2) {
[3541] Fix | Delete
break;
[3542] Fix | Delete
}
[3543] Fix | Delete
}
[3544] Fix | Delete
// ----- Look for extraction in standard output
[3545] Fix | Delete
elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
[3546] Fix | Delete
&& ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
[3547] Fix | Delete
// ----- Extracting the file in standard output
[3548] Fix | Delete
$v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
[3549] Fix | Delete
if ($v_result1 < 1) {
[3550] Fix | Delete
$this->privCloseFd();
[3551] Fix | Delete
$this->privSwapBackMagicQuotes();
[3552] Fix | Delete
return $v_result1;
[3553] Fix | Delete
}
[3554] Fix | Delete
[3555] Fix | Delete
// ----- Get the only interesting attributes
[3556] Fix | Delete
if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
[3557] Fix | Delete
$this->privCloseFd();
[3558] Fix | Delete
$this->privSwapBackMagicQuotes();
[3559] Fix | Delete
return $v_result;
[3560] Fix | Delete
}
[3561] Fix | Delete
[3562] Fix | Delete
// ----- Look for user callback abort
[3563] Fix | Delete
if ($v_result1 == 2) {
[3564] Fix | Delete
break;
[3565] Fix | Delete
}
[3566] Fix | Delete
}
[3567] Fix | Delete
// ----- Look for normal extraction
[3568] Fix | Delete
else {
[3569] Fix | Delete
// ----- Extracting the file
[3570] Fix | Delete
$v_result1 = $this->privExtractFile($v_header,
[3571] Fix | Delete
$p_path, $p_reCopy_path,
[3572] Fix | Delete
$p_reCopy_all_path,
[3573] Fix | Delete
$p_options);
[3574] Fix | Delete
if ($v_result1 < 1) {
[3575] Fix | Delete
$this->privCloseFd();
[3576] Fix | Delete
$this->privSwapBackMagicQuotes();
[3577] Fix | Delete
return $v_result1;
[3578] Fix | Delete
}
[3579] Fix | Delete
[3580] Fix | Delete
// ----- Get the only interesting attributes
[3581] Fix | Delete
if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
[3582] Fix | Delete
{
[3583] Fix | Delete
// ----- Close the zip file
[3584] Fix | Delete
$this->privCloseFd();
[3585] Fix | Delete
$this->privSwapBackMagicQuotes();
[3586] Fix | Delete
[3587] Fix | Delete
return $v_result;
[3588] Fix | Delete
}
[3589] Fix | Delete
[3590] Fix | Delete
// ----- Look for user callback abort
[3591] Fix | Delete
if ($v_result1 == 2) {
[3592] Fix | Delete
break;
[3593] Fix | Delete
}
[3594] Fix | Delete
}
[3595] Fix | Delete
}
[3596] Fix | Delete
}
[3597] Fix | Delete
[3598] Fix | Delete
// ----- Close the zip file
[3599] Fix | Delete
$this->privCloseFd();
[3600] Fix | Delete
$this->privSwapBackMagicQuotes();
[3601] Fix | Delete
[3602] Fix | Delete
// ----- Return
[3603] Fix | Delete
return $v_result;
[3604] Fix | Delete
}
[3605] Fix | Delete
// --------------------------------------------------------------------------------
[3606] Fix | Delete
[3607] Fix | Delete
// --------------------------------------------------------------------------------
[3608] Fix | Delete
// Function : privExtractFile()
[3609] Fix | Delete
// Description :
[3610] Fix | Delete
// Parameters :
[3611] Fix | Delete
// Return Values :
[3612] Fix | Delete
//
[3613] Fix | Delete
// 1 : ... ?
[3614] Fix | Delete
// PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
[3615] Fix | Delete
// --------------------------------------------------------------------------------
[3616] Fix | Delete
function privExtractFile(&$p_entry, $p_path, $p_reCopy_path, $p_reCopy_all_path, &$p_options)
[3617] Fix | Delete
{
[3618] Fix | Delete
$v_result=1;
[3619] Fix | Delete
[3620] Fix | Delete
// ----- Read the file header
[3621] Fix | Delete
if (($v_result = $this->privReadFileHeader($v_header)) != 1)
[3622] Fix | Delete
{
[3623] Fix | Delete
// ----- Return
[3624] Fix | Delete
return $v_result;
[3625] Fix | Delete
}
[3626] Fix | Delete
[3627] Fix | Delete
[3628] Fix | Delete
// ----- Check that the file header is coherent with $p_entry info
[3629] Fix | Delete
if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
[3630] Fix | Delete
// TBC
[3631] Fix | Delete
}
[3632] Fix | Delete
[3633] Fix | Delete
// ----- Look for all path to reCopy
[3634] Fix | Delete
if ($p_reCopy_all_path == true) {
[3635] Fix | Delete
// ----- Look for folder entry that not need to be extracted
[3636] Fix | Delete
if (($p_entry['external']&0x00000010)==0x00000010) {
[3637] Fix | Delete
[3638] Fix | Delete
$p_entry['status'] = "filtered";
[3639] Fix | Delete
[3640] Fix | Delete
return $v_result;
[3641] Fix | Delete
}
[3642] Fix | Delete
[3643] Fix | Delete
// ----- Get the basename of the path
[3644] Fix | Delete
$p_entry['filename'] = basename($p_entry['filename']);
[3645] Fix | Delete
}
[3646] Fix | Delete
[3647] Fix | Delete
// ----- Look for path to reCopy
[3648] Fix | Delete
else if ($p_reCopy_path != "")
[3649] Fix | Delete
{
[3650] Fix | Delete
if (PclZipUtilPathInclusion($p_reCopy_path, $p_entry['filename']) == 2)
[3651] Fix | Delete
{
[3652] Fix | Delete
[3653] Fix | Delete
// ----- Change the file status
[3654] Fix | Delete
$p_entry['status'] = "filtered";
[3655] Fix | Delete
[3656] Fix | Delete
// ----- Return
[3657] Fix | Delete
return $v_result;
[3658] Fix | Delete
}
[3659] Fix | Delete
[3660] Fix | Delete
$p_reCopy_path_size = strlen($p_reCopy_path);
[3661] Fix | Delete
if (substr($p_entry['filename'], 0, $p_reCopy_path_size) == $p_reCopy_path)
[3662] Fix | Delete
{
[3663] Fix | Delete
[3664] Fix | Delete
// ----- ReCopy the path
[3665] Fix | Delete
$p_entry['filename'] = substr($p_entry['filename'], $p_reCopy_path_size);
[3666] Fix | Delete
[3667] Fix | Delete
}
[3668] Fix | Delete
}
[3669] Fix | Delete
[3670] Fix | Delete
// ----- Add the path
[3671] Fix | Delete
if ($p_path != '') {
[3672] Fix | Delete
$p_entry['filename'] = $p_path."/".$p_entry['filename'];
[3673] Fix | Delete
}
[3674] Fix | Delete
[3675] Fix | Delete
// ----- Check a base_dir_restriction
[3676] Fix | Delete
if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
[3677] Fix | Delete
$v_inclusion
[3678] Fix | Delete
= PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
[3679] Fix | Delete
$p_entry['filename']);
[3680] Fix | Delete
if ($v_inclusion == 0) {
[3681] Fix | Delete
[3682] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
[3683] Fix | Delete
"Filename '".$p_entry['filename']."' is "
[3684] Fix | Delete
."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
[3685] Fix | Delete
[3686] Fix | Delete
return PclZip::errorCode();
[3687] Fix | Delete
}
[3688] Fix | Delete
}
[3689] Fix | Delete
[3690] Fix | Delete
// ----- Look for pre-extract callback
[3691] Fix | Delete
if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
[3692] Fix | Delete
[3693] Fix | Delete
// ----- Generate a local information
[3694] Fix | Delete
$v_local_header = array();
[3695] Fix | Delete
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
[3696] Fix | Delete
[3697] Fix | Delete
// ----- Call the callback
[3698] Fix | Delete
// Here I do not use call_user_func() because I need to send a reference to the
[3699] Fix | Delete
// header.
[3700] Fix | Delete
// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
[3701] Fix | Delete
$v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
[3702] Fix | Delete
if ($v_result == 0) {
[3703] Fix | Delete
// ----- Change the file status
[3704] Fix | Delete
$p_entry['status'] = "skipped";
[3705] Fix | Delete
$v_result = 1;
[3706] Fix | Delete
}
[3707] Fix | Delete
[3708] Fix | Delete
// ----- Look for abort result
[3709] Fix | Delete
if ($v_result == 2) {
[3710] Fix | Delete
// ----- This status is internal and will be changed in 'skipped'
[3711] Fix | Delete
$p_entry['status'] = "aborted";
[3712] Fix | Delete
$v_result = PCLZIP_ERR_USER_ABORTED;
[3713] Fix | Delete
}
[3714] Fix | Delete
[3715] Fix | Delete
// ----- Update the informations
[3716] Fix | Delete
// Only some fields can be modified
[3717] Fix | Delete
$p_entry['filename'] = $v_local_header['filename'];
[3718] Fix | Delete
}
[3719] Fix | Delete
[3720] Fix | Delete
[3721] Fix | Delete
// ----- Look if extraction should be done
[3722] Fix | Delete
if ($p_entry['status'] == 'ok') {
[3723] Fix | Delete
[3724] Fix | Delete
// ----- Look for specific actions while the file exist
[3725] Fix | Delete
if (file_exists($p_entry['filename']))
[3726] Fix | Delete
{
[3727] Fix | Delete
[3728] Fix | Delete
// ----- Look if file is a directory
[3729] Fix | Delete
if (is_dir($p_entry['filename']))
[3730] Fix | Delete
{
[3731] Fix | Delete
[3732] Fix | Delete
// ----- Change the file status
[3733] Fix | Delete
$p_entry['status'] = "already_a_directory";
[3734] Fix | Delete
[3735] Fix | Delete
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
[3736] Fix | Delete
// For historical reason first PclZip implementation does not stop
[3737] Fix | Delete
// when this kind of error occurs.
[3738] Fix | Delete
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
[3739] Fix | Delete
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
[3740] Fix | Delete
[3741] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
[3742] Fix | Delete
"Filename '".$p_entry['filename']."' is "
[3743] Fix | Delete
."already used by an existing directory");
[3744] Fix | Delete
[3745] Fix | Delete
return PclZip::errorCode();
[3746] Fix | Delete
}
[3747] Fix | Delete
}
[3748] Fix | Delete
// ----- Look if file is write protected
[3749] Fix | Delete
else if (!is_writeable($p_entry['filename']))
[3750] Fix | Delete
{
[3751] Fix | Delete
[3752] Fix | Delete
// ----- Change the file status
[3753] Fix | Delete
$p_entry['status'] = "write_protected";
[3754] Fix | Delete
[3755] Fix | Delete
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
[3756] Fix | Delete
// For historical reason first PclZip implementation does not stop
[3757] Fix | Delete
// when this kind of error occurs.
[3758] Fix | Delete
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
[3759] Fix | Delete
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
[3760] Fix | Delete
[3761] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
[3762] Fix | Delete
"Filename '".$p_entry['filename']."' exists "
[3763] Fix | Delete
."and is write protected");
[3764] Fix | Delete
[3765] Fix | Delete
return PclZip::errorCode();
[3766] Fix | Delete
}
[3767] Fix | Delete
}
[3768] Fix | Delete
[3769] Fix | Delete
// ----- Look if the extracted file is older
[3770] Fix | Delete
else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
[3771] Fix | Delete
{
[3772] Fix | Delete
// ----- Change the file status
[3773] Fix | Delete
if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
[3774] Fix | Delete
&& ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
[3775] Fix | Delete
}
[3776] Fix | Delete
else {
[3777] Fix | Delete
$p_entry['status'] = "newer_exist";
[3778] Fix | Delete
[3779] Fix | Delete
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
[3780] Fix | Delete
// For historical reason first PclZip implementation does not stop
[3781] Fix | Delete
// when this kind of error occurs.
[3782] Fix | Delete
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
[3783] Fix | Delete
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
[3784] Fix | Delete
[3785] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
[3786] Fix | Delete
"Newer version of '".$p_entry['filename']."' exists "
[3787] Fix | Delete
."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
[3788] Fix | Delete
[3789] Fix | Delete
return PclZip::errorCode();
[3790] Fix | Delete
}
[3791] Fix | Delete
}
[3792] Fix | Delete
}
[3793] Fix | Delete
else {
[3794] Fix | Delete
}
[3795] Fix | Delete
}
[3796] Fix | Delete
[3797] Fix | Delete
// ----- Check the directory availability and create it if necessary
[3798] Fix | Delete
else {
[3799] Fix | Delete
if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
[3800] Fix | Delete
$v_dir_to_check = $p_entry['filename'];
[3801] Fix | Delete
else if (!strstr($p_entry['filename'], "/"))
[3802] Fix | Delete
$v_dir_to_check = "";
[3803] Fix | Delete
else
[3804] Fix | Delete
$v_dir_to_check = dirname($p_entry['filename']);
[3805] Fix | Delete
[3806] Fix | Delete
if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
[3807] Fix | Delete
[3808] Fix | Delete
// ----- Change the file status
[3809] Fix | Delete
$p_entry['status'] = "path_creation_fail";
[3810] Fix | Delete
[3811] Fix | Delete
// ----- Return
[3812] Fix | Delete
//return $v_result;
[3813] Fix | Delete
$v_result = 1;
[3814] Fix | Delete
}
[3815] Fix | Delete
}
[3816] Fix | Delete
}
[3817] Fix | Delete
[3818] Fix | Delete
// ----- Look if extraction should be done
[3819] Fix | Delete
if ($p_entry['status'] == 'ok') {
[3820] Fix | Delete
[3821] Fix | Delete
// ----- Do the extraction (if not a folder)
[3822] Fix | Delete
if (!(($p_entry['external']&0x00000010)==0x00000010))
[3823] Fix | Delete
{
[3824] Fix | Delete
// ----- Look for not compressed file
[3825] Fix | Delete
if ($p_entry['compression'] == 0) {
[3826] Fix | Delete
[3827] Fix | Delete
// ----- Opening destination file
[3828] Fix | Delete
if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
[3829] Fix | Delete
{
[3830] Fix | Delete
[3831] Fix | Delete
// ----- Change the file status
[3832] Fix | Delete
$p_entry['status'] = "write_error";
[3833] Fix | Delete
[3834] Fix | Delete
// ----- Return
[3835] Fix | Delete
return $v_result;
[3836] Fix | Delete
}
[3837] Fix | Delete
[3838] Fix | Delete
[3839] Fix | Delete
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
[3840] Fix | Delete
$v_size = $p_entry['compressed_size'];
[3841] Fix | Delete
while ($v_size != 0)
[3842] Fix | Delete
{
[3843] Fix | Delete
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
[3844] Fix | Delete
$v_buffer = @fread($this->zip_fd, $v_read_size);
[3845] Fix | Delete
/* Try to speed up the code
[3846] Fix | Delete
$v_binary_data = pack('a'.$v_read_size, $v_buffer);
[3847] Fix | Delete
@fwrite($v_dest_file, $v_binary_data, $v_read_size);
[3848] Fix | Delete
*/
[3849] Fix | Delete
@fwrite($v_dest_file, $v_buffer, $v_read_size);
[3850] Fix | Delete
$v_size -= $v_read_size;
[3851] Fix | Delete
}
[3852] Fix | Delete
[3853] Fix | Delete
// ----- Closing the destination file
[3854] Fix | Delete
fclose($v_dest_file);
[3855] Fix | Delete
[3856] Fix | Delete
// ----- Change the file mtime
[3857] Fix | Delete
touch($p_entry['filename'], $p_entry['mtime']);
[3858] Fix | Delete
[3859] Fix | Delete
[3860] Fix | Delete
}
[3861] Fix | Delete
else {
[3862] Fix | Delete
// ----- TBC
[3863] Fix | Delete
// Need to be finished
[3864] Fix | Delete
if (($p_entry['flag'] & 1) == 1) {
[3865] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
[3866] Fix | Delete
return PclZip::errorCode();
[3867] Fix | Delete
}
[3868] Fix | Delete
[3869] Fix | Delete
[3870] Fix | Delete
// ----- Look for using temporary file to unzip
[3871] Fix | Delete
if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
[3872] Fix | Delete
&& (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
[3873] Fix | Delete
|| (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
[3874] Fix | Delete
&& ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
[3875] Fix | Delete
$v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
[3876] Fix | Delete
if ($v_result < PCLZIP_ERR_NO_ERROR) {
[3877] Fix | Delete
return $v_result;
[3878] Fix | Delete
}
[3879] Fix | Delete
}
[3880] Fix | Delete
[3881] Fix | Delete
// ----- Look for extract in memory
[3882] Fix | Delete
else {
[3883] Fix | Delete
[3884] Fix | Delete
[3885] Fix | Delete
// ----- Read the compressed file in a buffer (one shot)
[3886] Fix | Delete
$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
[3887] Fix | Delete
[3888] Fix | Delete
// ----- Decompress the file
[3889] Fix | Delete
$v_file_content = @gzinflate($v_buffer);
[3890] Fix | Delete
unset($v_buffer);
[3891] Fix | Delete
if ($v_file_content === FALSE) {
[3892] Fix | Delete
[3893] Fix | Delete
// ----- Change the file status
[3894] Fix | Delete
// TBC
[3895] Fix | Delete
$p_entry['status'] = "error";
[3896] Fix | Delete
[3897] Fix | Delete
return $v_result;
[3898] Fix | Delete
}
[3899] Fix | Delete
[3900] Fix | Delete
// ----- Opening destination file
[3901] Fix | Delete
if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
[3902] Fix | Delete
[3903] Fix | Delete
// ----- Change the file status
[3904] Fix | Delete
$p_entry['status'] = "write_error";
[3905] Fix | Delete
[3906] Fix | Delete
return $v_result;
[3907] Fix | Delete
}
[3908] Fix | Delete
[3909] Fix | Delete
// ----- Write the uncompressed data
[3910] Fix | Delete
@fwrite($v_dest_file, $v_file_content, $p_entry['size']);
[3911] Fix | Delete
unset($v_file_content);
[3912] Fix | Delete
[3913] Fix | Delete
// ----- Closing the destination file
[3914] Fix | Delete
@fclose($v_dest_file);
[3915] Fix | Delete
[3916] Fix | Delete
}
[3917] Fix | Delete
[3918] Fix | Delete
// ----- Change the file mtime
[3919] Fix | Delete
@touch($p_entry['filename'], $p_entry['mtime']);
[3920] Fix | Delete
}
[3921] Fix | Delete
[3922] Fix | Delete
// ----- Look for chmod option
[3923] Fix | Delete
if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
[3924] Fix | Delete
[3925] Fix | Delete
// ----- Change the mode of the file
[3926] Fix | Delete
@chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
[3927] Fix | Delete
}
[3928] Fix | Delete
[3929] Fix | Delete
}
[3930] Fix | Delete
}
[3931] Fix | Delete
[3932] Fix | Delete
// ----- Change abort status
[3933] Fix | Delete
if ($p_entry['status'] == "aborted") {
[3934] Fix | Delete
$p_entry['status'] = "skipped";
[3935] Fix | Delete
}
[3936] Fix | Delete
[3937] Fix | Delete
// ----- Look for post-extract callback
[3938] Fix | Delete
elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
[3939] Fix | Delete
[3940] Fix | Delete
// ----- Generate a local information
[3941] Fix | Delete
$v_local_header = array();
[3942] Fix | Delete
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
[3943] Fix | Delete
[3944] Fix | Delete
// ----- Call the callback
[3945] Fix | Delete
// Here I do not use call_user_func() because I need to send a reference to the
[3946] Fix | Delete
// header.
[3947] Fix | Delete
// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
[3948] Fix | Delete
$v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
[3949] Fix | Delete
[3950] Fix | Delete
// ----- Look for abort result
[3951] Fix | Delete
if ($v_result == 2) {
[3952] Fix | Delete
$v_result = PCLZIP_ERR_USER_ABORTED;
[3953] Fix | Delete
}
[3954] Fix | Delete
}
[3955] Fix | Delete
[3956] Fix | Delete
// ----- Return
[3957] Fix | Delete
return $v_result;
[3958] Fix | Delete
}
[3959] Fix | Delete
// --------------------------------------------------------------------------------
[3960] Fix | Delete
[3961] Fix | Delete
// --------------------------------------------------------------------------------
[3962] Fix | Delete
// Function : privExtractFileUsingTempFile()
[3963] Fix | Delete
// Description :
[3964] Fix | Delete
// Parameters :
[3965] Fix | Delete
// Return Values :
[3966] Fix | Delete
// --------------------------------------------------------------------------------
[3967] Fix | Delete
function privExtractFileUsingTempFile(&$p_entry, &$p_options)
[3968] Fix | Delete
{
[3969] Fix | Delete
$v_result=1;
[3970] Fix | Delete
[3971] Fix | Delete
// ----- Creates a temporary file
[3972] Fix | Delete
$v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
[3973] Fix | Delete
if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
[3974] Fix | Delete
fclose($v_file);
[3975] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
[3976] Fix | Delete
return PclZip::errorCode();
[3977] Fix | Delete
}
[3978] Fix | Delete
[3979] Fix | Delete
[3980] Fix | Delete
// ----- Write gz file format header
[3981] Fix | Delete
$v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
[3982] Fix | Delete
@fwrite($v_dest_file, $v_binary_data, 10);
[3983] Fix | Delete
[3984] Fix | Delete
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
[3985] Fix | Delete
$v_size = $p_entry['compressed_size'];
[3986] Fix | Delete
while ($v_size != 0)
[3987] Fix | Delete
{
[3988] Fix | Delete
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
[3989] Fix | Delete
$v_buffer = @fread($this->zip_fd, $v_read_size);
[3990] Fix | Delete
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
[3991] Fix | Delete
@fwrite($v_dest_file, $v_buffer, $v_read_size);
[3992] Fix | Delete
$v_size -= $v_read_size;
[3993] Fix | Delete
}
[3994] Fix | Delete
[3995] Fix | Delete
// ----- Write gz file format footer
[3996] Fix | Delete
$v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
[3997] Fix | Delete
@fwrite($v_dest_file, $v_binary_data, 8);
[3998] Fix | Delete
[3999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function