- Timestamp:
- Jul 7, 2009, 10:27:37 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/charlies_content/getid3/getid3/module.archive.szip.php
r3318 r3544 1 1 <?php 2 // +----------------------------------------------------------------------+ 3 // | PHP version 5 | 4 // +----------------------------------------------------------------------+ 5 // | Copyright (c) 2002-2006 James Heinrich, Allan Hansen | 6 // +----------------------------------------------------------------------+ 7 // | This source file is subject to version 2 of the GPL license, | 8 // | that is bundled with this package in the file license.txt and is | 9 // | available through the world-wide-web at the following url: | 10 // | http://www.gnu.org/copyleft/gpl.html | 11 // +----------------------------------------------------------------------+ 12 // | getID3() - http://getid3.sourceforge.net or http://www.getid3.org | 13 // +----------------------------------------------------------------------+ 14 // | Authors: James Heinrich <infoØgetid3*org> | 15 // | Allan Hansen <ahØartemis*dk> | 16 // +----------------------------------------------------------------------+ 17 // | module.archive.szip.php | 18 // | module for analyzing SZIP compressed files | 19 // | dependencies: NONE | 20 // +----------------------------------------------------------------------+ 21 // 22 // $Id$ 2 ///////////////////////////////////////////////////////////////// 3 /// getID3() by James Heinrich <info@getid3.org> // 4 // available at http://getid3.sourceforge.net // 5 // or http://www.getid3.org // 6 ///////////////////////////////////////////////////////////////// 7 // See readme.txt for more details // 8 ///////////////////////////////////////////////////////////////// 9 // // 10 // module.archive.szip.php // 11 // module for analyzing SZIP compressed files // 12 // dependencies: NONE // 13 // /// 14 ///////////////////////////////////////////////////////////////// 23 15 24 25 26 class getid3_szip extends getid3_handler 16 17 class getid3_szip 27 18 { 28 19 29 public function Analyze() { 30 31 $getid3 = $this->getid3; 20 function getid3_szip(&$fd, &$ThisFileInfo) { 32 21 33 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);34 $szip_rkau = fread($getid3->fp, 6);35 36 // Magic bytes: 'SZ'."\x0A\x04" 37 38 $getid3->info['fileformat'] = 'szip'; 22 fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET); 23 $SZIPHeader = fread($fd, 6); 24 if (substr($SZIPHeader, 0, 4) != 'SZ'."\x0A\x04") { 25 $ThisFileInfo['error'][] = 'Expecting "SZ[x0A][x04]" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($SZIPHeader, 0, 4).'"'; 26 return false; 27 } 39 28 40 $getid3->info['szip']['major_version'] = getid3_lib::BigEndian2Int(substr($szip_rkau, 4, 1)); 41 $getid3->info['szip']['minor_version'] = getid3_lib::BigEndian2Int(substr($szip_rkau, 5, 1)); 29 $ThisFileInfo['fileformat'] = 'szip'; 42 30 43 while (!feof($getid3->fp)) { 44 $next_block_id = fread($getid3->fp, 2); 45 switch ($next_block_id) { 46 case 'SZ': 47 // Note that szip files can be concatenated, this has the same effect as 48 // concatenating the files. this also means that global header blocks 49 // might be present between directory/data blocks. 50 fseek($getid3->fp, 4, SEEK_CUR); 51 break; 31 $ThisFileInfo['szip']['major_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 4, 1)); 32 $ThisFileInfo['szip']['minor_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 5, 1)); 52 33 53 case 'BH': 54 $bh_header_bytes = getid3_lib::BigEndian2Int(fread($getid3->fp, 3)); 55 $bh_header_data = fread($getid3->fp, $bh_header_bytes); 56 $bh_header_offset = 0; 57 while (strpos($bh_header_data, "\x00", $bh_header_offset) > 0) { 58 //filename as \0 terminated string (empty string indicates end) 59 //owner as \0 terminated string (empty is same as last file) 60 //group as \0 terminated string (empty is same as last file) 61 //3 byte filelength in this block 62 //2 byte access flags 63 //4 byte creation time (like in unix) 64 //4 byte modification time (like in unix) 65 //4 byte access time (like in unix) 34 while (!feof($fd)) { 35 $NextBlockID = fread($fd, 2); 36 switch ($NextBlockID) { 37 case 'SZ': 38 // Note that szip files can be concatenated, this has the same effect as 39 // concatenating the files. this also means that global header blocks 40 // might be present between directory/data blocks. 41 fseek($fd, 4, SEEK_CUR); 42 break; 66 43 67 $bh_data_array['filename'] = substr($bh_header_data, $bh_header_offset, strcspn($bh_header_data, "\x00")); 68 $bh_header_offset += (strlen($bh_data_array['filename']) + 1); 44 case 'BH': 45 $BHheaderbytes = getid3_lib::BigEndian2Int(fread($fd, 3)); 46 $BHheaderdata = fread($fd, $BHheaderbytes); 47 $BHheaderoffset = 0; 48 while (strpos($BHheaderdata, "\x00", $BHheaderoffset) > 0) { 49 //filename as \0 terminated string (empty string indicates end) 50 //owner as \0 terminated string (empty is same as last file) 51 //group as \0 terminated string (empty is same as last file) 52 //3 byte filelength in this block 53 //2 byte access flags 54 //4 byte creation time (like in unix) 55 //4 byte modification time (like in unix) 56 //4 byte access time (like in unix) 69 57 70 $bh_data_array['owner'] = substr($bh_header_data, $bh_header_offset, strcspn($bh_header_data, "\x00"));71 $bh_header_offset += (strlen($bh_data_array['owner']) + 1);58 $BHdataArray['filename'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, "\x00")); 59 $BHheaderoffset += (strlen($BHdataArray['filename']) + 1); 72 60 73 $bh_data_array['group'] = substr($bh_header_data, $bh_header_offset, strcspn($bh_header_data, "\x00"));74 $bh_header_offset += (strlen($bh_data_array['group']) + 1);61 $BHdataArray['owner'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, "\x00")); 62 $BHheaderoffset += (strlen($BHdataArray['owner']) + 1); 75 63 76 $bh_data_array['filelength'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 3));77 $bh_header_offset += 3;64 $BHdataArray['group'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, "\x00")); 65 $BHheaderoffset += (strlen($BHdataArray['group']) + 1); 78 66 79 $bh_data_array['access_flags'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 2));80 $bh_header_offset += 2;67 $BHdataArray['filelength'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 3)); 68 $BHheaderoffset += 3; 81 69 82 $bh_data_array['creation_time'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 4));83 $bh_header_offset += 4;70 $BHdataArray['access_flags'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 2)); 71 $BHheaderoffset += 2; 84 72 85 $bh_data_array['modification_time'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 4));86 $bh_header_offset += 4;73 $BHdataArray['creation_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4)); 74 $BHheaderoffset += 4; 87 75 88 $bh_data_array['access_time'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 4));89 $bh_header_offset += 4;76 $BHdataArray['modification_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4)); 77 $BHheaderoffset += 4; 90 78 91 $getid3->info['szip']['BH'][] = $bh_data_array; 92 } 93 break; 79 $BHdataArray['access_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4)); 80 $BHheaderoffset += 4; 94 81 95 default: 96 break 2; 97 } 98 } 82 $ThisFileInfo['szip']['BH'][] = $BHdataArray; 83 } 84 break; 99 85 100 return true; 101 } 86 default: 87 break 2; 88 } 89 } 90 91 return true; 92 93 } 102 94 103 95 }
Note: See TracChangeset
for help on using the changeset viewer.