51 $info = &$this->getid3->info;
53 $info[
'fileformat'] =
'gzip';
56 $unpack_header =
'a1id1/a1id2/a1cmethod/a1flags/a4mtime/a1xflags/a1os';
61 if (
$info[
'filesize'] >
$info[
'php_memory_limit']) {
62 $info[
'error'][] =
'File is too large (' . number_format(
$info[
'filesize']) .
' bytes) to read into memory (limit: ' . number_format(
$info[
'php_memory_limit'] / 1048576) .
'MB)';
66 fseek($this->getid3->fp, 0);
67 $buffer = fread($this->getid3->fp,
$info[
'filesize']);
69 $arr_members = explode(
"\x1F\x8B\x08", $buffer);
71 $is_wrong_members =
false;
72 $num_members = intval(count($arr_members));
73 for ($i = 0; $i < $num_members; $i++) {
74 if (strlen($arr_members[$i]) == 0) {
77 $buf =
"\x1F\x8B\x08" . $arr_members[$i];
79 $attr = unpack($unpack_header, substr($buf, 0, $start_length));
82 $arr_members[$i - 1] .= $buf;
83 $arr_members[$i] =
'';
84 $is_wrong_members =
true;
88 if (!$is_wrong_members) {
97 for ($i = 0; $i < $num_members; $i++) {
98 if (strlen($arr_members[$i]) == 0) {
101 $thisInfo = &
$info[
'gzip'][
'member_header'][++$idx];
103 $buff =
"\x1F\x8B\x08" . $arr_members[$i];
105 $attr = unpack($unpack_header, substr($buff, 0, $start_length));
107 $thisInfo[
'raw'][
'id1'] = ord($attr[
'cmethod']);
108 $thisInfo[
'raw'][
'id2'] = ord($attr[
'cmethod']);
109 $thisInfo[
'raw'][
'cmethod'] = ord($attr[
'cmethod']);
110 $thisInfo[
'raw'][
'os'] = ord($attr[
'os']);
111 $thisInfo[
'raw'][
'xflags'] = ord($attr[
'xflags']);
112 $thisInfo[
'raw'][
'flags'] = ord($attr[
'flags']);
114 $thisInfo[
'flags'][
'crc16'] = (bool) ($thisInfo[
'raw'][
'flags'] & 0x02);
115 $thisInfo[
'flags'][
'extra'] = (bool) ($thisInfo[
'raw'][
'flags'] & 0x04);
116 $thisInfo[
'flags'][
'filename'] = (bool) ($thisInfo[
'raw'][
'flags'] & 0x08);
117 $thisInfo[
'flags'][
'comment'] = (bool) ($thisInfo[
'raw'][
'flags'] & 0x10);
119 $thisInfo[
'compression'] = $this->
get_xflag_type($thisInfo[
'raw'][
'xflags']);
121 $thisInfo[
'os'] = $this->
get_os_type($thisInfo[
'raw'][
'os']);
122 if (!$thisInfo[
'os']) {
123 $info[
'error'][] =
'Read error on gzip file';
129 $arr_xsubfield =
array();
134 if ($thisInfo[
'flags'][
'extra']) {
135 $w_xlen = substr($buff, $fpointer, 2);
139 $thisInfo[
'raw'][
'xfield'] = substr($buff, $fpointer, $xlen);
149 $si1 = ord(substr($buff, $fpointer + $idx++, 1));
150 $si2 = ord(substr($buff, $fpointer + $idx++, 1));
151 if (($si1 == 0x41) && ($si2 == 0x70)) {
152 $w_xsublen = substr($buff, $fpointer + $idx, 2);
155 $arr_xsubfield[] = substr($buff, $fpointer + $idx,
169 $thisInfo[
'filename'] = preg_replace(
'#\.gz$#i',
'',
171 if ($thisInfo[
'flags'][
'filename']) {
173 if (ord($buff[$fpointer]) == 0) {
177 $thisInfo[
'filename'] .= $buff[$fpointer];
185 if ($thisInfo[
'flags'][
'comment']) {
187 if (ord($buff[$fpointer]) == 0) {
191 $thisInfo[
'comment'] .= $buff[$fpointer];
199 if ($thisInfo[
'flags'][
'crc16']) {
200 $w_crc = substr($buff, $fpointer, 2);
219 $thisInfo[
'filesize']));
221 if ($this->option_gzip_parse_contents) {
226 if (function_exists(
'gzinflate')) {
227 $cdata = substr($buff, $fpointer);
228 $cdata = substr($cdata, 0, strlen($cdata) - 8);
229 $csize = strlen($cdata);
230 $inflated = gzinflate($cdata);
233 $thisInfo[
'crc32_valid'] = (bool) (sprintf(
'%u',
234 crc32($inflated)) == $thisInfo[
'crc32']);
237 $formattest = substr($inflated, 0, 32774);
239 $determined_format = $getid3_temp->GetFileFormat($formattest);
243 $determined_format[
'module'] = (isset($determined_format[
'module']) ? $determined_format[
'module'] :
'');
244 switch ($determined_format[
'module']) {
247 if (class_exists($determined_format[
'class'])) {
249 'getID3')) ===
false) {
251 $info[
'error'][] =
'Unable to create temp file to parse TAR inside GZIP file';
254 if ($fp_temp_tar = fopen($temp_tar_filename,
256 fwrite($fp_temp_tar, $inflated);
257 fclose($fp_temp_tar);
259 $getid3_temp->openfile($temp_tar_filename);
260 $getid3_tar =
new Tar($getid3_temp);
261 $getid3_tar->analyze();
262 $info[
'gzip'][
'member_header'][$idx][
'tar'] = $getid3_temp->info[
'tar'];
263 unset($getid3_temp, $getid3_tar);
264 unlink($temp_tar_filename);
266 $info[
'error'][] =
'Unable to fopen() temp file to parse TAR inside GZIP file';
293 static $os_type =
array(
294 '0' =>
'FAT filesystem (MS-DOS, OS/2, NT/Win32)',
296 '2' =>
'VMS (or OpenVMS)',
300 '6' =>
'HPFS filesystem (OS/2, NT)',
305 '11' =>
'NTFS filesystem (NT)',
307 '13' =>
'Acorn RISCOS',
311 return (isset($os_type[$key]) ? $os_type[$key] :
'');
323 static $xflag_type =
array(
325 '2' =>
'maximum compression',
326 '4' =>
'fastest algorithm' 329 return (isset($xflag_type[$key]) ? $xflag_type[$key] :
'');
static CreateDeepArray($ArrayPath, $Separator, $Value)
GetId3() by James Heinrich info@getid3.org //.
GetId3() by James Heinrich info@getid3.org //.
GetId3() by James Heinrich info@getid3.org //.
get_os_type($key)
Converts the OS type.
get_xflag_type($key)
Converts the eXtra FLags.
Create styles array
The data for the language used.
static array_merge_clobber($array1, $array2)
static LittleEndian2Int($byteword, $signed=false)
$option_gzip_parse_contents