Edit File by line
/home/barbar84/www/extracte.../filemang...
File: pclzip.lib.php
// ----- Close the temporary file
[4000] Fix | Delete
@fclose($v_dest_file);
[4001] Fix | Delete
[4002] Fix | Delete
// ----- Opening destination file
[4003] Fix | Delete
if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
[4004] Fix | Delete
$p_entry['status'] = "write_error";
[4005] Fix | Delete
return $v_result;
[4006] Fix | Delete
}
[4007] Fix | Delete
[4008] Fix | Delete
// ----- Open the temporary gz file
[4009] Fix | Delete
if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
[4010] Fix | Delete
@fclose($v_dest_file);
[4011] Fix | Delete
$p_entry['status'] = "read_error";
[4012] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
[4013] Fix | Delete
return PclZip::errorCode();
[4014] Fix | Delete
}
[4015] Fix | Delete
[4016] Fix | Delete
[4017] Fix | Delete
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
[4018] Fix | Delete
$v_size = $p_entry['size'];
[4019] Fix | Delete
while ($v_size != 0) {
[4020] Fix | Delete
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
[4021] Fix | Delete
$v_buffer = @gzread($v_src_file, $v_read_size);
[4022] Fix | Delete
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
[4023] Fix | Delete
@fwrite($v_dest_file, $v_buffer, $v_read_size);
[4024] Fix | Delete
$v_size -= $v_read_size;
[4025] Fix | Delete
}
[4026] Fix | Delete
@fclose($v_dest_file);
[4027] Fix | Delete
@gzclose($v_src_file);
[4028] Fix | Delete
[4029] Fix | Delete
// ----- Delete the temporary file
[4030] Fix | Delete
@unlink($v_gzip_temp_name);
[4031] Fix | Delete
[4032] Fix | Delete
// ----- Return
[4033] Fix | Delete
return $v_result;
[4034] Fix | Delete
}
[4035] Fix | Delete
// --------------------------------------------------------------------------------
[4036] Fix | Delete
[4037] Fix | Delete
// --------------------------------------------------------------------------------
[4038] Fix | Delete
// Function : privExtractFileInOutput()
[4039] Fix | Delete
// Description :
[4040] Fix | Delete
// Parameters :
[4041] Fix | Delete
// Return Values :
[4042] Fix | Delete
// --------------------------------------------------------------------------------
[4043] Fix | Delete
function privExtractFileInOutput(&$p_entry, &$p_options)
[4044] Fix | Delete
{
[4045] Fix | Delete
$v_result=1;
[4046] Fix | Delete
[4047] Fix | Delete
// ----- Read the file header
[4048] Fix | Delete
if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
[4049] Fix | Delete
return $v_result;
[4050] Fix | Delete
}
[4051] Fix | Delete
[4052] Fix | Delete
[4053] Fix | Delete
// ----- Check that the file header is coherent with $p_entry info
[4054] Fix | Delete
if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
[4055] Fix | Delete
// TBC
[4056] Fix | Delete
}
[4057] Fix | Delete
[4058] Fix | Delete
// ----- Look for pre-extract callback
[4059] Fix | Delete
if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
[4060] Fix | Delete
[4061] Fix | Delete
// ----- Generate a local information
[4062] Fix | Delete
$v_local_header = array();
[4063] Fix | Delete
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
[4064] Fix | Delete
[4065] Fix | Delete
// ----- Call the callback
[4066] Fix | Delete
// Here I do not use call_user_func() because I need to send a reference to the
[4067] Fix | Delete
// header.
[4068] Fix | Delete
// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
[4069] Fix | Delete
$v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
[4070] Fix | Delete
if ($v_result == 0) {
[4071] Fix | Delete
// ----- Change the file status
[4072] Fix | Delete
$p_entry['status'] = "skipped";
[4073] Fix | Delete
$v_result = 1;
[4074] Fix | Delete
}
[4075] Fix | Delete
[4076] Fix | Delete
// ----- Look for abort result
[4077] Fix | Delete
if ($v_result == 2) {
[4078] Fix | Delete
// ----- This status is internal and will be changed in 'skipped'
[4079] Fix | Delete
$p_entry['status'] = "aborted";
[4080] Fix | Delete
$v_result = PCLZIP_ERR_USER_ABORTED;
[4081] Fix | Delete
}
[4082] Fix | Delete
[4083] Fix | Delete
// ----- Update the informations
[4084] Fix | Delete
// Only some fields can be modified
[4085] Fix | Delete
$p_entry['filename'] = $v_local_header['filename'];
[4086] Fix | Delete
}
[4087] Fix | Delete
[4088] Fix | Delete
// ----- Trace
[4089] Fix | Delete
[4090] Fix | Delete
// ----- Look if extraction should be done
[4091] Fix | Delete
if ($p_entry['status'] == 'ok') {
[4092] Fix | Delete
[4093] Fix | Delete
// ----- Do the extraction (if not a folder)
[4094] Fix | Delete
if (!(($p_entry['external']&0x00000010)==0x00000010)) {
[4095] Fix | Delete
// ----- Look for not compressed file
[4096] Fix | Delete
if ($p_entry['compressed_size'] == $p_entry['size']) {
[4097] Fix | Delete
[4098] Fix | Delete
// ----- Read the file in a buffer (one shot)
[4099] Fix | Delete
$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
[4100] Fix | Delete
[4101] Fix | Delete
// ----- Send the file to the output
[4102] Fix | Delete
echo $v_buffer;
[4103] Fix | Delete
unset($v_buffer);
[4104] Fix | Delete
}
[4105] Fix | Delete
else {
[4106] Fix | Delete
[4107] Fix | Delete
// ----- Read the compressed file in a buffer (one shot)
[4108] Fix | Delete
$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
[4109] Fix | Delete
[4110] Fix | Delete
// ----- Decompress the file
[4111] Fix | Delete
$v_file_content = gzinflate($v_buffer);
[4112] Fix | Delete
unset($v_buffer);
[4113] Fix | Delete
[4114] Fix | Delete
// ----- Send the file to the output
[4115] Fix | Delete
echo $v_file_content;
[4116] Fix | Delete
unset($v_file_content);
[4117] Fix | Delete
}
[4118] Fix | Delete
}
[4119] Fix | Delete
}
[4120] Fix | Delete
[4121] Fix | Delete
// ----- Change abort status
[4122] Fix | Delete
if ($p_entry['status'] == "aborted") {
[4123] Fix | Delete
$p_entry['status'] = "skipped";
[4124] Fix | Delete
}
[4125] Fix | Delete
[4126] Fix | Delete
// ----- Look for post-extract callback
[4127] Fix | Delete
elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
[4128] Fix | Delete
[4129] Fix | Delete
// ----- Generate a local information
[4130] Fix | Delete
$v_local_header = array();
[4131] Fix | Delete
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
[4132] Fix | Delete
[4133] Fix | Delete
// ----- Call the callback
[4134] Fix | Delete
// Here I do not use call_user_func() because I need to send a reference to the
[4135] Fix | Delete
// header.
[4136] Fix | Delete
// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
[4137] Fix | Delete
$v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
[4138] Fix | Delete
[4139] Fix | Delete
// ----- Look for abort result
[4140] Fix | Delete
if ($v_result == 2) {
[4141] Fix | Delete
$v_result = PCLZIP_ERR_USER_ABORTED;
[4142] Fix | Delete
}
[4143] Fix | Delete
}
[4144] Fix | Delete
[4145] Fix | Delete
return $v_result;
[4146] Fix | Delete
}
[4147] Fix | Delete
// --------------------------------------------------------------------------------
[4148] Fix | Delete
[4149] Fix | Delete
// --------------------------------------------------------------------------------
[4150] Fix | Delete
// Function : privExtractFileAsString()
[4151] Fix | Delete
// Description :
[4152] Fix | Delete
// Parameters :
[4153] Fix | Delete
// Return Values :
[4154] Fix | Delete
// --------------------------------------------------------------------------------
[4155] Fix | Delete
function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
[4156] Fix | Delete
{
[4157] Fix | Delete
$v_result=1;
[4158] Fix | Delete
[4159] Fix | Delete
// ----- Read the file header
[4160] Fix | Delete
$v_header = array();
[4161] Fix | Delete
if (($v_result = $this->privReadFileHeader($v_header)) != 1)
[4162] Fix | Delete
{
[4163] Fix | Delete
// ----- Return
[4164] Fix | Delete
return $v_result;
[4165] Fix | Delete
}
[4166] Fix | Delete
[4167] Fix | Delete
[4168] Fix | Delete
// ----- Check that the file header is coherent with $p_entry info
[4169] Fix | Delete
if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
[4170] Fix | Delete
// TBC
[4171] Fix | Delete
}
[4172] Fix | Delete
[4173] Fix | Delete
// ----- Look for pre-extract callback
[4174] Fix | Delete
if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
[4175] Fix | Delete
[4176] Fix | Delete
// ----- Generate a local information
[4177] Fix | Delete
$v_local_header = array();
[4178] Fix | Delete
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
[4179] Fix | Delete
[4180] Fix | Delete
// ----- Call the callback
[4181] Fix | Delete
// Here I do not use call_user_func() because I need to send a reference to the
[4182] Fix | Delete
// header.
[4183] Fix | Delete
// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
[4184] Fix | Delete
$v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
[4185] Fix | Delete
if ($v_result == 0) {
[4186] Fix | Delete
// ----- Change the file status
[4187] Fix | Delete
$p_entry['status'] = "skipped";
[4188] Fix | Delete
$v_result = 1;
[4189] Fix | Delete
}
[4190] Fix | Delete
[4191] Fix | Delete
// ----- Look for abort result
[4192] Fix | Delete
if ($v_result == 2) {
[4193] Fix | Delete
// ----- This status is internal and will be changed in 'skipped'
[4194] Fix | Delete
$p_entry['status'] = "aborted";
[4195] Fix | Delete
$v_result = PCLZIP_ERR_USER_ABORTED;
[4196] Fix | Delete
}
[4197] Fix | Delete
[4198] Fix | Delete
// ----- Update the informations
[4199] Fix | Delete
// Only some fields can be modified
[4200] Fix | Delete
$p_entry['filename'] = $v_local_header['filename'];
[4201] Fix | Delete
}
[4202] Fix | Delete
[4203] Fix | Delete
[4204] Fix | Delete
// ----- Look if extraction should be done
[4205] Fix | Delete
if ($p_entry['status'] == 'ok') {
[4206] Fix | Delete
[4207] Fix | Delete
// ----- Do the extraction (if not a folder)
[4208] Fix | Delete
if (!(($p_entry['external']&0x00000010)==0x00000010)) {
[4209] Fix | Delete
// ----- Look for not compressed file
[4210] Fix | Delete
// if ($p_entry['compressed_size'] == $p_entry['size'])
[4211] Fix | Delete
if ($p_entry['compression'] == 0) {
[4212] Fix | Delete
[4213] Fix | Delete
// ----- Reading the file
[4214] Fix | Delete
$p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
[4215] Fix | Delete
}
[4216] Fix | Delete
else {
[4217] Fix | Delete
[4218] Fix | Delete
// ----- Reading the file
[4219] Fix | Delete
$v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
[4220] Fix | Delete
[4221] Fix | Delete
// ----- Decompress the file
[4222] Fix | Delete
if (($p_string = @gzinflate($v_data)) === FALSE) {
[4223] Fix | Delete
// TBC
[4224] Fix | Delete
}
[4225] Fix | Delete
}
[4226] Fix | Delete
[4227] Fix | Delete
// ----- Trace
[4228] Fix | Delete
}
[4229] Fix | Delete
else {
[4230] Fix | Delete
// TBC : error : can not extract a folder in a string
[4231] Fix | Delete
}
[4232] Fix | Delete
[4233] Fix | Delete
}
[4234] Fix | Delete
[4235] Fix | Delete
// ----- Change abort status
[4236] Fix | Delete
if ($p_entry['status'] == "aborted") {
[4237] Fix | Delete
$p_entry['status'] = "skipped";
[4238] Fix | Delete
}
[4239] Fix | Delete
[4240] Fix | Delete
// ----- Look for post-extract callback
[4241] Fix | Delete
elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
[4242] Fix | Delete
[4243] Fix | Delete
// ----- Generate a local information
[4244] Fix | Delete
$v_local_header = array();
[4245] Fix | Delete
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
[4246] Fix | Delete
[4247] Fix | Delete
// ----- Swap the content to header
[4248] Fix | Delete
$v_local_header['content'] = $p_string;
[4249] Fix | Delete
$p_string = '';
[4250] Fix | Delete
[4251] Fix | Delete
// ----- Call the callback
[4252] Fix | Delete
// Here I do not use call_user_func() because I need to send a reference to the
[4253] Fix | Delete
// header.
[4254] Fix | Delete
// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
[4255] Fix | Delete
$v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
[4256] Fix | Delete
[4257] Fix | Delete
// ----- Swap back the content to header
[4258] Fix | Delete
$p_string = $v_local_header['content'];
[4259] Fix | Delete
unset($v_local_header['content']);
[4260] Fix | Delete
[4261] Fix | Delete
// ----- Look for abort result
[4262] Fix | Delete
if ($v_result == 2) {
[4263] Fix | Delete
$v_result = PCLZIP_ERR_USER_ABORTED;
[4264] Fix | Delete
}
[4265] Fix | Delete
}
[4266] Fix | Delete
[4267] Fix | Delete
// ----- Return
[4268] Fix | Delete
return $v_result;
[4269] Fix | Delete
}
[4270] Fix | Delete
// --------------------------------------------------------------------------------
[4271] Fix | Delete
[4272] Fix | Delete
// --------------------------------------------------------------------------------
[4273] Fix | Delete
// Function : privReadFileHeader()
[4274] Fix | Delete
// Description :
[4275] Fix | Delete
// Parameters :
[4276] Fix | Delete
// Return Values :
[4277] Fix | Delete
// --------------------------------------------------------------------------------
[4278] Fix | Delete
function privReadFileHeader(&$p_header)
[4279] Fix | Delete
{
[4280] Fix | Delete
$v_result=1;
[4281] Fix | Delete
[4282] Fix | Delete
// ----- Read the 4 bytes signature
[4283] Fix | Delete
$v_binary_data = @fread($this->zip_fd, 4);
[4284] Fix | Delete
$v_data = unpack('Vid', $v_binary_data);
[4285] Fix | Delete
[4286] Fix | Delete
// ----- Check signature
[4287] Fix | Delete
if ($v_data['id'] != 0x04034b50)
[4288] Fix | Delete
{
[4289] Fix | Delete
[4290] Fix | Delete
// ----- Error log
[4291] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
[4292] Fix | Delete
[4293] Fix | Delete
// ----- Return
[4294] Fix | Delete
return PclZip::errorCode();
[4295] Fix | Delete
}
[4296] Fix | Delete
[4297] Fix | Delete
// ----- Read the first 42 bytes of the header
[4298] Fix | Delete
$v_binary_data = fread($this->zip_fd, 26);
[4299] Fix | Delete
[4300] Fix | Delete
// ----- Look for invalid block size
[4301] Fix | Delete
if (strlen($v_binary_data) != 26)
[4302] Fix | Delete
{
[4303] Fix | Delete
$p_header['filename'] = "";
[4304] Fix | Delete
$p_header['status'] = "invalid_header";
[4305] Fix | Delete
[4306] Fix | Delete
// ----- Error log
[4307] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
[4308] Fix | Delete
[4309] Fix | Delete
// ----- Return
[4310] Fix | Delete
return PclZip::errorCode();
[4311] Fix | Delete
}
[4312] Fix | Delete
[4313] Fix | Delete
// ----- Extract the values
[4314] Fix | Delete
$v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
[4315] Fix | Delete
[4316] Fix | Delete
// ----- Get filename
[4317] Fix | Delete
$p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
[4318] Fix | Delete
[4319] Fix | Delete
// ----- Get extra_fields
[4320] Fix | Delete
if ($v_data['extra_len'] != 0) {
[4321] Fix | Delete
$p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
[4322] Fix | Delete
}
[4323] Fix | Delete
else {
[4324] Fix | Delete
$p_header['extra'] = '';
[4325] Fix | Delete
}
[4326] Fix | Delete
[4327] Fix | Delete
// ----- Extract properties
[4328] Fix | Delete
$p_header['version_extracted'] = $v_data['version'];
[4329] Fix | Delete
$p_header['compression'] = $v_data['compression'];
[4330] Fix | Delete
$p_header['size'] = $v_data['size'];
[4331] Fix | Delete
$p_header['compressed_size'] = $v_data['compressed_size'];
[4332] Fix | Delete
$p_header['crc'] = $v_data['crc'];
[4333] Fix | Delete
$p_header['flag'] = $v_data['flag'];
[4334] Fix | Delete
$p_header['filename_len'] = $v_data['filename_len'];
[4335] Fix | Delete
[4336] Fix | Delete
// ----- Recuperate date in UNIX format
[4337] Fix | Delete
$p_header['mdate'] = $v_data['mdate'];
[4338] Fix | Delete
$p_header['mtime'] = $v_data['mtime'];
[4339] Fix | Delete
if ($p_header['mdate'] && $p_header['mtime'])
[4340] Fix | Delete
{
[4341] Fix | Delete
// ----- Extract time
[4342] Fix | Delete
$v_hour = ($p_header['mtime'] & 0xF800) >> 11;
[4343] Fix | Delete
$v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
[4344] Fix | Delete
$v_seconde = ($p_header['mtime'] & 0x001F)*2;
[4345] Fix | Delete
[4346] Fix | Delete
// ----- Extract date
[4347] Fix | Delete
$v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
[4348] Fix | Delete
$v_month = ($p_header['mdate'] & 0x01E0) >> 5;
[4349] Fix | Delete
$v_day = $p_header['mdate'] & 0x001F;
[4350] Fix | Delete
[4351] Fix | Delete
// ----- Get UNIX date format
[4352] Fix | Delete
$p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
[4353] Fix | Delete
[4354] Fix | Delete
}
[4355] Fix | Delete
else
[4356] Fix | Delete
{
[4357] Fix | Delete
$p_header['mtime'] = time();
[4358] Fix | Delete
}
[4359] Fix | Delete
[4360] Fix | Delete
// TBC
[4361] Fix | Delete
//for(reset($v_data); $key = key($v_data); next($v_data)) {
[4362] Fix | Delete
//}
[4363] Fix | Delete
[4364] Fix | Delete
// ----- Set the stored filename
[4365] Fix | Delete
$p_header['stored_filename'] = $p_header['filename'];
[4366] Fix | Delete
[4367] Fix | Delete
// ----- Set the status field
[4368] Fix | Delete
$p_header['status'] = "ok";
[4369] Fix | Delete
[4370] Fix | Delete
// ----- Return
[4371] Fix | Delete
return $v_result;
[4372] Fix | Delete
}
[4373] Fix | Delete
// --------------------------------------------------------------------------------
[4374] Fix | Delete
[4375] Fix | Delete
// --------------------------------------------------------------------------------
[4376] Fix | Delete
// Function : privReadCentralFileHeader()
[4377] Fix | Delete
// Description :
[4378] Fix | Delete
// Parameters :
[4379] Fix | Delete
// Return Values :
[4380] Fix | Delete
// --------------------------------------------------------------------------------
[4381] Fix | Delete
function privReadCentralFileHeader(&$p_header)
[4382] Fix | Delete
{
[4383] Fix | Delete
$v_result=1;
[4384] Fix | Delete
[4385] Fix | Delete
// ----- Read the 4 bytes signature
[4386] Fix | Delete
$v_binary_data = @fread($this->zip_fd, 4);
[4387] Fix | Delete
$v_data = unpack('Vid', $v_binary_data);
[4388] Fix | Delete
[4389] Fix | Delete
// ----- Check signature
[4390] Fix | Delete
if ($v_data['id'] != 0x02014b50)
[4391] Fix | Delete
{
[4392] Fix | Delete
[4393] Fix | Delete
// ----- Error log
[4394] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
[4395] Fix | Delete
[4396] Fix | Delete
// ----- Return
[4397] Fix | Delete
return PclZip::errorCode();
[4398] Fix | Delete
}
[4399] Fix | Delete
[4400] Fix | Delete
// ----- Read the first 42 bytes of the header
[4401] Fix | Delete
$v_binary_data = fread($this->zip_fd, 42);
[4402] Fix | Delete
[4403] Fix | Delete
// ----- Look for invalid block size
[4404] Fix | Delete
if (strlen($v_binary_data) != 42)
[4405] Fix | Delete
{
[4406] Fix | Delete
$p_header['filename'] = "";
[4407] Fix | Delete
$p_header['status'] = "invalid_header";
[4408] Fix | Delete
[4409] Fix | Delete
// ----- Error log
[4410] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
[4411] Fix | Delete
[4412] Fix | Delete
// ----- Return
[4413] Fix | Delete
return PclZip::errorCode();
[4414] Fix | Delete
}
[4415] Fix | Delete
[4416] Fix | Delete
// ----- Extract the values
[4417] Fix | Delete
$p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
[4418] Fix | Delete
[4419] Fix | Delete
// ----- Get filename
[4420] Fix | Delete
if ($p_header['filename_len'] != 0)
[4421] Fix | Delete
$p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
[4422] Fix | Delete
else
[4423] Fix | Delete
$p_header['filename'] = '';
[4424] Fix | Delete
[4425] Fix | Delete
// ----- Get extra
[4426] Fix | Delete
if ($p_header['extra_len'] != 0)
[4427] Fix | Delete
$p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
[4428] Fix | Delete
else
[4429] Fix | Delete
$p_header['extra'] = '';
[4430] Fix | Delete
[4431] Fix | Delete
// ----- Get comment
[4432] Fix | Delete
if ($p_header['comment_len'] != 0)
[4433] Fix | Delete
$p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
[4434] Fix | Delete
else
[4435] Fix | Delete
$p_header['comment'] = '';
[4436] Fix | Delete
[4437] Fix | Delete
// ----- Extract properties
[4438] Fix | Delete
[4439] Fix | Delete
// ----- Recuperate date in UNIX format
[4440] Fix | Delete
//if ($p_header['mdate'] && $p_header['mtime'])
[4441] Fix | Delete
// TBC : bug : this was ignoring time with 0/0/0
[4442] Fix | Delete
if (1)
[4443] Fix | Delete
{
[4444] Fix | Delete
// ----- Extract time
[4445] Fix | Delete
$v_hour = ($p_header['mtime'] & 0xF800) >> 11;
[4446] Fix | Delete
$v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
[4447] Fix | Delete
$v_seconde = ($p_header['mtime'] & 0x001F)*2;
[4448] Fix | Delete
[4449] Fix | Delete
// ----- Extract date
[4450] Fix | Delete
$v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
[4451] Fix | Delete
$v_month = ($p_header['mdate'] & 0x01E0) >> 5;
[4452] Fix | Delete
$v_day = $p_header['mdate'] & 0x001F;
[4453] Fix | Delete
[4454] Fix | Delete
// ----- Get UNIX date format
[4455] Fix | Delete
$p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
[4456] Fix | Delete
[4457] Fix | Delete
}
[4458] Fix | Delete
else
[4459] Fix | Delete
{
[4460] Fix | Delete
$p_header['mtime'] = time();
[4461] Fix | Delete
}
[4462] Fix | Delete
[4463] Fix | Delete
// ----- Set the stored filename
[4464] Fix | Delete
$p_header['stored_filename'] = $p_header['filename'];
[4465] Fix | Delete
[4466] Fix | Delete
// ----- Set default status to ok
[4467] Fix | Delete
$p_header['status'] = 'ok';
[4468] Fix | Delete
[4469] Fix | Delete
// ----- Look if it is a directory
[4470] Fix | Delete
if (substr($p_header['filename'], -1) == '/') {
[4471] Fix | Delete
//$p_header['external'] = 0x41FF0010;
[4472] Fix | Delete
$p_header['external'] = 0x00000010;
[4473] Fix | Delete
}
[4474] Fix | Delete
[4475] Fix | Delete
[4476] Fix | Delete
// ----- Return
[4477] Fix | Delete
return $v_result;
[4478] Fix | Delete
}
[4479] Fix | Delete
// --------------------------------------------------------------------------------
[4480] Fix | Delete
[4481] Fix | Delete
// --------------------------------------------------------------------------------
[4482] Fix | Delete
// Function : privCheckFileHeaders()
[4483] Fix | Delete
// Description :
[4484] Fix | Delete
// Parameters :
[4485] Fix | Delete
// Return Values :
[4486] Fix | Delete
// 1 on success,
[4487] Fix | Delete
// 0 on error;
[4488] Fix | Delete
// --------------------------------------------------------------------------------
[4489] Fix | Delete
function privCheckFileHeaders(&$p_local_header, &$p_central_header)
[4490] Fix | Delete
{
[4491] Fix | Delete
$v_result=1;
[4492] Fix | Delete
[4493] Fix | Delete
// ----- Check the static values
[4494] Fix | Delete
// TBC
[4495] Fix | Delete
if ($p_local_header['filename'] != $p_central_header['filename']) {
[4496] Fix | Delete
}
[4497] Fix | Delete
if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
[4498] Fix | Delete
}
[4499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function