Edit File by line
/home/barbar84/www/extracte.../filemang...
File: pclzip.lib.php
if ($p_local_header['flag'] != $p_central_header['flag']) {
[4500] Fix | Delete
}
[4501] Fix | Delete
if ($p_local_header['compression'] != $p_central_header['compression']) {
[4502] Fix | Delete
}
[4503] Fix | Delete
if ($p_local_header['mtime'] != $p_central_header['mtime']) {
[4504] Fix | Delete
}
[4505] Fix | Delete
if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
[4506] Fix | Delete
}
[4507] Fix | Delete
[4508] Fix | Delete
// ----- Look for flag bit 3
[4509] Fix | Delete
if (($p_local_header['flag'] & 8) == 8) {
[4510] Fix | Delete
$p_local_header['size'] = $p_central_header['size'];
[4511] Fix | Delete
$p_local_header['compressed_size'] = $p_central_header['compressed_size'];
[4512] Fix | Delete
$p_local_header['crc'] = $p_central_header['crc'];
[4513] Fix | Delete
}
[4514] Fix | Delete
[4515] Fix | Delete
// ----- Return
[4516] Fix | Delete
return $v_result;
[4517] Fix | Delete
}
[4518] Fix | Delete
// --------------------------------------------------------------------------------
[4519] Fix | Delete
[4520] Fix | Delete
// --------------------------------------------------------------------------------
[4521] Fix | Delete
// Function : privReadEndCentralDir()
[4522] Fix | Delete
// Description :
[4523] Fix | Delete
// Parameters :
[4524] Fix | Delete
// Return Values :
[4525] Fix | Delete
// --------------------------------------------------------------------------------
[4526] Fix | Delete
function privReadEndCentralDir(&$p_central_dir)
[4527] Fix | Delete
{
[4528] Fix | Delete
$v_result=1;
[4529] Fix | Delete
[4530] Fix | Delete
// ----- Go to the end of the zip file
[4531] Fix | Delete
$v_size = filesize($this->zipname);
[4532] Fix | Delete
@fseek($this->zip_fd, $v_size);
[4533] Fix | Delete
if (@ftell($this->zip_fd) != $v_size)
[4534] Fix | Delete
{
[4535] Fix | Delete
// ----- Error log
[4536] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
[4537] Fix | Delete
[4538] Fix | Delete
// ----- Return
[4539] Fix | Delete
return PclZip::errorCode();
[4540] Fix | Delete
}
[4541] Fix | Delete
[4542] Fix | Delete
// ----- First try : look if this is an archive with no commentaries (most of the time)
[4543] Fix | Delete
// in this case the end of central dir is at 22 bytes of the file end
[4544] Fix | Delete
$v_found = 0;
[4545] Fix | Delete
if ($v_size > 26) {
[4546] Fix | Delete
@fseek($this->zip_fd, $v_size-22);
[4547] Fix | Delete
if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
[4548] Fix | Delete
{
[4549] Fix | Delete
// ----- Error log
[4550] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
[4551] Fix | Delete
[4552] Fix | Delete
// ----- Return
[4553] Fix | Delete
return PclZip::errorCode();
[4554] Fix | Delete
}
[4555] Fix | Delete
[4556] Fix | Delete
// ----- Read for bytes
[4557] Fix | Delete
$v_binary_data = @fread($this->zip_fd, 4);
[4558] Fix | Delete
$v_data = @unpack('Vid', $v_binary_data);
[4559] Fix | Delete
[4560] Fix | Delete
// ----- Check signature
[4561] Fix | Delete
if ($v_data['id'] == 0x06054b50) {
[4562] Fix | Delete
$v_found = 1;
[4563] Fix | Delete
}
[4564] Fix | Delete
[4565] Fix | Delete
$v_pos = ftell($this->zip_fd);
[4566] Fix | Delete
}
[4567] Fix | Delete
[4568] Fix | Delete
// ----- Go back to the maximum possible size of the Central Dir End Record
[4569] Fix | Delete
if (!$v_found) {
[4570] Fix | Delete
$v_maximum_size = 65557; // 0xFFFF + 22;
[4571] Fix | Delete
if ($v_maximum_size > $v_size)
[4572] Fix | Delete
$v_maximum_size = $v_size;
[4573] Fix | Delete
@fseek($this->zip_fd, $v_size-$v_maximum_size);
[4574] Fix | Delete
if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
[4575] Fix | Delete
{
[4576] Fix | Delete
// ----- Error log
[4577] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
[4578] Fix | Delete
[4579] Fix | Delete
// ----- Return
[4580] Fix | Delete
return PclZip::errorCode();
[4581] Fix | Delete
}
[4582] Fix | Delete
[4583] Fix | Delete
// ----- Read byte per byte in order to find the signature
[4584] Fix | Delete
$v_pos = ftell($this->zip_fd);
[4585] Fix | Delete
$v_bytes = 0x00000000;
[4586] Fix | Delete
while ($v_pos < $v_size)
[4587] Fix | Delete
{
[4588] Fix | Delete
// ----- Read a byte
[4589] Fix | Delete
$v_byte = @fread($this->zip_fd, 1);
[4590] Fix | Delete
[4591] Fix | Delete
// ----- Add the byte
[4592] Fix | Delete
//$v_bytes = ($v_bytes << 8) | Ord($v_byte);
[4593] Fix | Delete
// Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
[4594] Fix | Delete
// Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
[4595] Fix | Delete
$v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
[4596] Fix | Delete
[4597] Fix | Delete
// ----- Compare the bytes
[4598] Fix | Delete
if ($v_bytes == 0x504b0506)
[4599] Fix | Delete
{
[4600] Fix | Delete
$v_pos++;
[4601] Fix | Delete
break;
[4602] Fix | Delete
}
[4603] Fix | Delete
[4604] Fix | Delete
$v_pos++;
[4605] Fix | Delete
}
[4606] Fix | Delete
[4607] Fix | Delete
// ----- Look if not found end of central dir
[4608] Fix | Delete
if ($v_pos == $v_size)
[4609] Fix | Delete
{
[4610] Fix | Delete
[4611] Fix | Delete
// ----- Error log
[4612] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
[4613] Fix | Delete
[4614] Fix | Delete
// ----- Return
[4615] Fix | Delete
return PclZip::errorCode();
[4616] Fix | Delete
}
[4617] Fix | Delete
}
[4618] Fix | Delete
[4619] Fix | Delete
// ----- Read the first 18 bytes of the header
[4620] Fix | Delete
$v_binary_data = fread($this->zip_fd, 18);
[4621] Fix | Delete
[4622] Fix | Delete
// ----- Look for invalid block size
[4623] Fix | Delete
if (strlen($v_binary_data) != 18)
[4624] Fix | Delete
{
[4625] Fix | Delete
[4626] Fix | Delete
// ----- Error log
[4627] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
[4628] Fix | Delete
[4629] Fix | Delete
// ----- Return
[4630] Fix | Delete
return PclZip::errorCode();
[4631] Fix | Delete
}
[4632] Fix | Delete
[4633] Fix | Delete
// ----- Extract the values
[4634] Fix | Delete
$v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
[4635] Fix | Delete
[4636] Fix | Delete
// ----- Check the global size
[4637] Fix | Delete
if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
[4638] Fix | Delete
[4639] Fix | Delete
// ----- ReCopyd in release 2.2 see readme file
[4640] Fix | Delete
// The check of the file size is a little too strict.
[4641] Fix | Delete
// Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
[4642] Fix | Delete
// While decrypted, zip has training 0 bytes
[4643] Fix | Delete
if (0) {
[4644] Fix | Delete
// ----- Error log
[4645] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
[4646] Fix | Delete
'The central dir is not at the end of the archive.'
[4647] Fix | Delete
.' Some trailing bytes exists after the archive.');
[4648] Fix | Delete
[4649] Fix | Delete
// ----- Return
[4650] Fix | Delete
return PclZip::errorCode();
[4651] Fix | Delete
}
[4652] Fix | Delete
}
[4653] Fix | Delete
[4654] Fix | Delete
// ----- Get comment
[4655] Fix | Delete
if ($v_data['comment_size'] != 0) {
[4656] Fix | Delete
$p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
[4657] Fix | Delete
}
[4658] Fix | Delete
else
[4659] Fix | Delete
$p_central_dir['comment'] = '';
[4660] Fix | Delete
[4661] Fix | Delete
$p_central_dir['entries'] = $v_data['entries'];
[4662] Fix | Delete
$p_central_dir['disk_entries'] = $v_data['disk_entries'];
[4663] Fix | Delete
$p_central_dir['offset'] = $v_data['offset'];
[4664] Fix | Delete
$p_central_dir['size'] = $v_data['size'];
[4665] Fix | Delete
$p_central_dir['disk'] = $v_data['disk'];
[4666] Fix | Delete
$p_central_dir['disk_start'] = $v_data['disk_start'];
[4667] Fix | Delete
[4668] Fix | Delete
// TBC
[4669] Fix | Delete
//for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
[4670] Fix | Delete
//}
[4671] Fix | Delete
[4672] Fix | Delete
// ----- Return
[4673] Fix | Delete
return $v_result;
[4674] Fix | Delete
}
[4675] Fix | Delete
// --------------------------------------------------------------------------------
[4676] Fix | Delete
[4677] Fix | Delete
// --------------------------------------------------------------------------------
[4678] Fix | Delete
// Function : privDeleteByRule()
[4679] Fix | Delete
// Description :
[4680] Fix | Delete
// Parameters :
[4681] Fix | Delete
// Return Values :
[4682] Fix | Delete
// --------------------------------------------------------------------------------
[4683] Fix | Delete
function privDeleteByRule(&$p_result_list, &$p_options)
[4684] Fix | Delete
{
[4685] Fix | Delete
$v_result=1;
[4686] Fix | Delete
$v_list_detail = array();
[4687] Fix | Delete
[4688] Fix | Delete
// ----- Open the zip file
[4689] Fix | Delete
if (($v_result=$this->privOpenFd('rb')) != 1)
[4690] Fix | Delete
{
[4691] Fix | Delete
// ----- Return
[4692] Fix | Delete
return $v_result;
[4693] Fix | Delete
}
[4694] Fix | Delete
[4695] Fix | Delete
// ----- Read the central directory informations
[4696] Fix | Delete
$v_central_dir = array();
[4697] Fix | Delete
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
[4698] Fix | Delete
{
[4699] Fix | Delete
$this->privCloseFd();
[4700] Fix | Delete
return $v_result;
[4701] Fix | Delete
}
[4702] Fix | Delete
[4703] Fix | Delete
// ----- Go to beginning of File
[4704] Fix | Delete
@rewind($this->zip_fd);
[4705] Fix | Delete
[4706] Fix | Delete
// ----- Scan all the files
[4707] Fix | Delete
// ----- Start at beginning of Central Dir
[4708] Fix | Delete
$v_pos_entry = $v_central_dir['offset'];
[4709] Fix | Delete
@rewind($this->zip_fd);
[4710] Fix | Delete
if (@fseek($this->zip_fd, $v_pos_entry))
[4711] Fix | Delete
{
[4712] Fix | Delete
// ----- Close the zip file
[4713] Fix | Delete
$this->privCloseFd();
[4714] Fix | Delete
[4715] Fix | Delete
// ----- Error log
[4716] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
[4717] Fix | Delete
[4718] Fix | Delete
// ----- Return
[4719] Fix | Delete
return PclZip::errorCode();
[4720] Fix | Delete
}
[4721] Fix | Delete
[4722] Fix | Delete
// ----- Read each entry
[4723] Fix | Delete
$v_header_list = array();
[4724] Fix | Delete
$j_start = 0;
[4725] Fix | Delete
for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
[4726] Fix | Delete
{
[4727] Fix | Delete
[4728] Fix | Delete
// ----- Read the file header
[4729] Fix | Delete
$v_header_list[$v_nb_extracted] = array();
[4730] Fix | Delete
if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
[4731] Fix | Delete
{
[4732] Fix | Delete
// ----- Close the zip file
[4733] Fix | Delete
$this->privCloseFd();
[4734] Fix | Delete
[4735] Fix | Delete
return $v_result;
[4736] Fix | Delete
}
[4737] Fix | Delete
[4738] Fix | Delete
[4739] Fix | Delete
// ----- Store the index
[4740] Fix | Delete
$v_header_list[$v_nb_extracted]['index'] = $i;
[4741] Fix | Delete
[4742] Fix | Delete
// ----- Look for the specific extract rules
[4743] Fix | Delete
$v_found = false;
[4744] Fix | Delete
[4745] Fix | Delete
// ----- Look for extract by name rule
[4746] Fix | Delete
if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
[4747] Fix | Delete
&& ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
[4748] Fix | Delete
[4749] Fix | Delete
// ----- Look if the filename is in the list
[4750] Fix | Delete
for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
[4751] Fix | Delete
[4752] Fix | Delete
// ----- Look for a directory
[4753] Fix | Delete
if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
[4754] Fix | Delete
[4755] Fix | Delete
// ----- Look if the directory is in the filename path
[4756] Fix | Delete
if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
[4757] Fix | Delete
&& (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
[4758] Fix | Delete
$v_found = true;
[4759] Fix | Delete
}
[4760] Fix | Delete
elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
[4761] Fix | Delete
&& ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
[4762] Fix | Delete
$v_found = true;
[4763] Fix | Delete
}
[4764] Fix | Delete
}
[4765] Fix | Delete
// ----- Look for a filename
[4766] Fix | Delete
elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
[4767] Fix | Delete
$v_found = true;
[4768] Fix | Delete
}
[4769] Fix | Delete
}
[4770] Fix | Delete
}
[4771] Fix | Delete
[4772] Fix | Delete
// ----- Look for extract by ereg rule
[4773] Fix | Delete
// ereg() is deprecated with PHP 5.3
[4774] Fix | Delete
/*
[4775] Fix | Delete
else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
[4776] Fix | Delete
&& ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
[4777] Fix | Delete
[4778] Fix | Delete
if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
[4779] Fix | Delete
$v_found = true;
[4780] Fix | Delete
}
[4781] Fix | Delete
}
[4782] Fix | Delete
*/
[4783] Fix | Delete
[4784] Fix | Delete
// ----- Look for extract by preg rule
[4785] Fix | Delete
else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
[4786] Fix | Delete
&& ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
[4787] Fix | Delete
[4788] Fix | Delete
if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
[4789] Fix | Delete
$v_found = true;
[4790] Fix | Delete
}
[4791] Fix | Delete
}
[4792] Fix | Delete
[4793] Fix | Delete
// ----- Look for extract by index rule
[4794] Fix | Delete
else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
[4795] Fix | Delete
&& ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
[4796] Fix | Delete
[4797] Fix | Delete
// ----- Look if the index is in the list
[4798] Fix | Delete
for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
[4799] Fix | Delete
[4800] Fix | Delete
if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
[4801] Fix | Delete
$v_found = true;
[4802] Fix | Delete
}
[4803] Fix | Delete
if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
[4804] Fix | Delete
$j_start = $j+1;
[4805] Fix | Delete
}
[4806] Fix | Delete
[4807] Fix | Delete
if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
[4808] Fix | Delete
break;
[4809] Fix | Delete
}
[4810] Fix | Delete
}
[4811] Fix | Delete
}
[4812] Fix | Delete
else {
[4813] Fix | Delete
$v_found = true;
[4814] Fix | Delete
}
[4815] Fix | Delete
[4816] Fix | Delete
// ----- Look for deletion
[4817] Fix | Delete
if ($v_found)
[4818] Fix | Delete
{
[4819] Fix | Delete
unset($v_header_list[$v_nb_extracted]);
[4820] Fix | Delete
}
[4821] Fix | Delete
else
[4822] Fix | Delete
{
[4823] Fix | Delete
$v_nb_extracted++;
[4824] Fix | Delete
}
[4825] Fix | Delete
}
[4826] Fix | Delete
[4827] Fix | Delete
// ----- Look if something need to be deleted
[4828] Fix | Delete
if ($v_nb_extracted > 0) {
[4829] Fix | Delete
[4830] Fix | Delete
// ----- Creates a temporay file
[4831] Fix | Delete
$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
[4832] Fix | Delete
[4833] Fix | Delete
// ----- Creates a temporary zip archive
[4834] Fix | Delete
$v_temp_zip = new PclZip($v_zip_temp_name);
[4835] Fix | Delete
[4836] Fix | Delete
// ----- Open the temporary zip file in write mode
[4837] Fix | Delete
if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
[4838] Fix | Delete
$this->privCloseFd();
[4839] Fix | Delete
[4840] Fix | Delete
// ----- Return
[4841] Fix | Delete
return $v_result;
[4842] Fix | Delete
}
[4843] Fix | Delete
[4844] Fix | Delete
// ----- Look which file need to be kept
[4845] Fix | Delete
for ($i=0; $i<sizeof($v_header_list); $i++) {
[4846] Fix | Delete
[4847] Fix | Delete
// ----- Calculate the position of the header
[4848] Fix | Delete
@rewind($this->zip_fd);
[4849] Fix | Delete
if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
[4850] Fix | Delete
// ----- Close the zip file
[4851] Fix | Delete
$this->privCloseFd();
[4852] Fix | Delete
$v_temp_zip->privCloseFd();
[4853] Fix | Delete
@unlink($v_zip_temp_name);
[4854] Fix | Delete
[4855] Fix | Delete
// ----- Error log
[4856] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
[4857] Fix | Delete
[4858] Fix | Delete
// ----- Return
[4859] Fix | Delete
return PclZip::errorCode();
[4860] Fix | Delete
}
[4861] Fix | Delete
[4862] Fix | Delete
// ----- Read the file header
[4863] Fix | Delete
$v_local_header = array();
[4864] Fix | Delete
if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
[4865] Fix | Delete
// ----- Close the zip file
[4866] Fix | Delete
$this->privCloseFd();
[4867] Fix | Delete
$v_temp_zip->privCloseFd();
[4868] Fix | Delete
@unlink($v_zip_temp_name);
[4869] Fix | Delete
[4870] Fix | Delete
// ----- Return
[4871] Fix | Delete
return $v_result;
[4872] Fix | Delete
}
[4873] Fix | Delete
[4874] Fix | Delete
// ----- Check that local file header is same as central file header
[4875] Fix | Delete
if ($this->privCheckFileHeaders($v_local_header,
[4876] Fix | Delete
$v_header_list[$i]) != 1) {
[4877] Fix | Delete
// TBC
[4878] Fix | Delete
}
[4879] Fix | Delete
unset($v_local_header);
[4880] Fix | Delete
[4881] Fix | Delete
// ----- Write the file header
[4882] Fix | Delete
if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
[4883] Fix | Delete
// ----- Close the zip file
[4884] Fix | Delete
$this->privCloseFd();
[4885] Fix | Delete
$v_temp_zip->privCloseFd();
[4886] Fix | Delete
@unlink($v_zip_temp_name);
[4887] Fix | Delete
[4888] Fix | Delete
// ----- Return
[4889] Fix | Delete
return $v_result;
[4890] Fix | Delete
}
[4891] Fix | Delete
[4892] Fix | Delete
// ----- Read/write the data block
[4893] Fix | Delete
if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
[4894] Fix | Delete
// ----- Close the zip file
[4895] Fix | Delete
$this->privCloseFd();
[4896] Fix | Delete
$v_temp_zip->privCloseFd();
[4897] Fix | Delete
@unlink($v_zip_temp_name);
[4898] Fix | Delete
[4899] Fix | Delete
// ----- Return
[4900] Fix | Delete
return $v_result;
[4901] Fix | Delete
}
[4902] Fix | Delete
}
[4903] Fix | Delete
[4904] Fix | Delete
// ----- Store the offset of the central dir
[4905] Fix | Delete
$v_offset = @ftell($v_temp_zip->zip_fd);
[4906] Fix | Delete
[4907] Fix | Delete
// ----- Re-Create the Central Dir files header
[4908] Fix | Delete
for ($i=0; $i<sizeof($v_header_list); $i++) {
[4909] Fix | Delete
// ----- Create the file header
[4910] Fix | Delete
if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
[4911] Fix | Delete
$v_temp_zip->privCloseFd();
[4912] Fix | Delete
$this->privCloseFd();
[4913] Fix | Delete
@unlink($v_zip_temp_name);
[4914] Fix | Delete
[4915] Fix | Delete
// ----- Return
[4916] Fix | Delete
return $v_result;
[4917] Fix | Delete
}
[4918] Fix | Delete
[4919] Fix | Delete
// ----- Transform the header to a 'usable' info
[4920] Fix | Delete
$v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
[4921] Fix | Delete
}
[4922] Fix | Delete
[4923] Fix | Delete
[4924] Fix | Delete
// ----- Zip file comment
[4925] Fix | Delete
$v_comment = '';
[4926] Fix | Delete
if (isset($p_options[PCLZIP_OPT_COMMENT])) {
[4927] Fix | Delete
$v_comment = $p_options[PCLZIP_OPT_COMMENT];
[4928] Fix | Delete
}
[4929] Fix | Delete
[4930] Fix | Delete
// ----- Calculate the size of the central header
[4931] Fix | Delete
$v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
[4932] Fix | Delete
[4933] Fix | Delete
// ----- Create the central dir footer
[4934] Fix | Delete
if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
[4935] Fix | Delete
// ----- Reset the file list
[4936] Fix | Delete
unset($v_header_list);
[4937] Fix | Delete
$v_temp_zip->privCloseFd();
[4938] Fix | Delete
$this->privCloseFd();
[4939] Fix | Delete
@unlink($v_zip_temp_name);
[4940] Fix | Delete
[4941] Fix | Delete
// ----- Return
[4942] Fix | Delete
return $v_result;
[4943] Fix | Delete
}
[4944] Fix | Delete
[4945] Fix | Delete
// ----- Close
[4946] Fix | Delete
$v_temp_zip->privCloseFd();
[4947] Fix | Delete
$this->privCloseFd();
[4948] Fix | Delete
[4949] Fix | Delete
// ----- Delete the zip file
[4950] Fix | Delete
// TBC : I should test the result ...
[4951] Fix | Delete
@unlink($this->zipname);
[4952] Fix | Delete
[4953] Fix | Delete
// ----- Rename the temporary file
[4954] Fix | Delete
// TBC : I should test the result ...
[4955] Fix | Delete
//@rename($v_zip_temp_name, $this->zipname);
[4956] Fix | Delete
PclZipUtilRename($v_zip_temp_name, $this->zipname);
[4957] Fix | Delete
[4958] Fix | Delete
// ----- Destroy the temporary archive
[4959] Fix | Delete
unset($v_temp_zip);
[4960] Fix | Delete
}
[4961] Fix | Delete
[4962] Fix | Delete
// ----- ReCopy every files : reset the file
[4963] Fix | Delete
else if ($v_central_dir['entries'] != 0) {
[4964] Fix | Delete
$this->privCloseFd();
[4965] Fix | Delete
[4966] Fix | Delete
if (($v_result = $this->privOpenFd('wb')) != 1) {
[4967] Fix | Delete
return $v_result;
[4968] Fix | Delete
}
[4969] Fix | Delete
[4970] Fix | Delete
if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
[4971] Fix | Delete
return $v_result;
[4972] Fix | Delete
}
[4973] Fix | Delete
[4974] Fix | Delete
$this->privCloseFd();
[4975] Fix | Delete
}
[4976] Fix | Delete
[4977] Fix | Delete
// ----- Return
[4978] Fix | Delete
return $v_result;
[4979] Fix | Delete
}
[4980] Fix | Delete
// --------------------------------------------------------------------------------
[4981] Fix | Delete
[4982] Fix | Delete
// --------------------------------------------------------------------------------
[4983] Fix | Delete
// Function : privDirCheck()
[4984] Fix | Delete
// Description :
[4985] Fix | Delete
// Check if a directory exists, if not it creates it and all the parents directory
[4986] Fix | Delete
// which may be useful.
[4987] Fix | Delete
// Parameters :
[4988] Fix | Delete
// $p_dir : Directory path to check.
[4989] Fix | Delete
// Return Values :
[4990] Fix | Delete
// 1 : OK
[4991] Fix | Delete
// -1 : Unable to create directory
[4992] Fix | Delete
// --------------------------------------------------------------------------------
[4993] Fix | Delete
function privDirCheck($p_dir, $p_is_dir=false)
[4994] Fix | Delete
{
[4995] Fix | Delete
$v_result = 1;
[4996] Fix | Delete
[4997] Fix | Delete
[4998] Fix | Delete
// ----- ReCopy the final '/'
[4999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function