function PclZip::privReadFileHeader in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php \PclZip::privReadFileHeader()
4 calls to PclZip::privReadFileHeader()
- PclZip::privDeleteByRule in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ PCLZip/ pclzip.lib.php - PclZip::privExtractFile in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ PCLZip/ pclzip.lib.php - PclZip::privExtractFileAsString in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ PCLZip/ pclzip.lib.php - PclZip::privExtractFileInOutput in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ PCLZip/ pclzip.lib.php
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ PCLZip/ pclzip.lib.php, line 4277
Class
Code
function privReadFileHeader(&$p_header) {
$v_result = 1;
// ----- Read the 4 bytes signature
$v_binary_data = @fread($this->zip_fd, 4);
$v_data = unpack('Vid', $v_binary_data);
// ----- Check signature
if ($v_data['id'] != 0x4034b50) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
// ----- Return
return PclZip::errorCode();
}
// ----- Read the first 42 bytes of the header
$v_binary_data = fread($this->zip_fd, 26);
// ----- Look for invalid block size
if (strlen($v_binary_data) != 26) {
$p_header['filename'] = "";
$p_header['status'] = "invalid_header";
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : " . strlen($v_binary_data));
// ----- Return
return PclZip::errorCode();
}
// ----- Extract the values
$v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
// ----- Get filename
$p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
// ----- Get extra_fields
if ($v_data['extra_len'] != 0) {
$p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
}
else {
$p_header['extra'] = '';
}
// ----- Extract properties
$p_header['version_extracted'] = $v_data['version'];
$p_header['compression'] = $v_data['compression'];
$p_header['size'] = $v_data['size'];
$p_header['compressed_size'] = $v_data['compressed_size'];
$p_header['crc'] = $v_data['crc'];
$p_header['flag'] = $v_data['flag'];
$p_header['filename_len'] = $v_data['filename_len'];
// ----- Recuperate date in UNIX format
$p_header['mdate'] = $v_data['mdate'];
$p_header['mtime'] = $v_data['mtime'];
if ($p_header['mdate'] && $p_header['mtime']) {
// ----- Extract time
$v_hour = ($p_header['mtime'] & 0xf800) >> 11;
$v_minute = ($p_header['mtime'] & 0x7e0) >> 5;
$v_seconde = ($p_header['mtime'] & 0x1f) * 2;
// ----- Extract date
$v_year = (($p_header['mdate'] & 0xfe00) >> 9) + 1980;
$v_month = ($p_header['mdate'] & 0x1e0) >> 5;
$v_day = $p_header['mdate'] & 0x1f;
// ----- Get UNIX date format
$p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
}
else {
$p_header['mtime'] = time();
}
// TBC
//for(reset($v_data); $key = key($v_data); next($v_data)) {
//}
// ----- Set the stored filename
$p_header['stored_filename'] = $p_header['filename'];
// ----- Set the status field
$p_header['status'] = "ok";
// ----- Return
return $v_result;
}