function PclZip::privReadEndCentralDir in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php \PclZip::privReadEndCentralDir()
6 calls to PclZip::privReadEndCentralDir()
- PclZip::privAdd in vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php
- PclZip::privDeleteByRule in vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php
- PclZip::privExtractByRule in vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php
- PclZip::privList in vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php
- PclZip::privMerge in vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php
... See full list
File
- vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php, line 4525
Class
- PclZip
Code
function privReadEndCentralDir(&$p_central_dir) {
$v_result = 1;
$v_size = filesize($this->zipname);
@fseek($this->zip_fd, $v_size);
if (@ftell($this->zip_fd) != $v_size) {
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \'' . $this->zipname . '\'');
return PclZip::errorCode();
}
$v_found = 0;
if ($v_size > 26) {
@fseek($this->zip_fd, $v_size - 22);
if (($v_pos = @ftell($this->zip_fd)) != $v_size - 22) {
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \'' . $this->zipname . '\'');
return PclZip::errorCode();
}
$v_binary_data = @fread($this->zip_fd, 4);
$v_data = @unpack('Vid', $v_binary_data);
if ($v_data['id'] == 0x6054b50) {
$v_found = 1;
}
$v_pos = ftell($this->zip_fd);
}
if (!$v_found) {
$v_maximum_size = 65557;
if ($v_maximum_size > $v_size) {
$v_maximum_size = $v_size;
}
@fseek($this->zip_fd, $v_size - $v_maximum_size);
if (@ftell($this->zip_fd) != $v_size - $v_maximum_size) {
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \'' . $this->zipname . '\'');
return PclZip::errorCode();
}
$v_pos = ftell($this->zip_fd);
$v_bytes = 0x0;
while ($v_pos < $v_size) {
$v_byte = @fread($this->zip_fd, 1);
$v_bytes = ($v_bytes & 0xffffff) << 8 | Ord($v_byte);
if ($v_bytes == 0x504b0506) {
$v_pos++;
break;
}
$v_pos++;
}
if ($v_pos == $v_size) {
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
return PclZip::errorCode();
}
}
$v_binary_data = fread($this->zip_fd, 18);
if (strlen($v_binary_data) != 18) {
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : " . strlen($v_binary_data));
return PclZip::errorCode();
}
$v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
if ($v_pos + $v_data['comment_size'] + 18 != $v_size) {
if (0) {
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'The central dir is not at the end of the archive.' . ' Some trailing bytes exists after the archive.');
return PclZip::errorCode();
}
}
if ($v_data['comment_size'] != 0) {
$p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
}
else {
$p_central_dir['comment'] = '';
}
$p_central_dir['entries'] = $v_data['entries'];
$p_central_dir['disk_entries'] = $v_data['disk_entries'];
$p_central_dir['offset'] = $v_data['offset'];
$p_central_dir['size'] = $v_data['size'];
$p_central_dir['disk'] = $v_data['disk'];
$p_central_dir['disk_start'] = $v_data['disk_start'];
return $v_result;
}