source: extensions/charlies_content/getid3/getid3/module.archive.szip.php @ 3318

Last change on this file since 3318 was 3318, checked in by vdigital, 15 years ago

+ Add Charlies' content to depository

  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
RevLine 
[3318]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: module.archive.szip.php 3318 2009-05-20 21:54:10Z vdigital $
23
24       
25       
26class getid3_szip extends getid3_handler
27{
28
29    public function Analyze() {
30       
31        $getid3 = $this->getid3;
32
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';
39
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));
42
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;
52
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)
66
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);
69
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);
72
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);
75
76                        $bh_data_array['filelength'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 3));
77                        $bh_header_offset += 3;
78
79                        $bh_data_array['access_flags'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 2));
80                        $bh_header_offset += 2;
81
82                        $bh_data_array['creation_time'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 4));
83                        $bh_header_offset += 4;
84
85                        $bh_data_array['modification_time'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 4));
86                        $bh_header_offset += 4;
87
88                        $bh_data_array['access_time'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 4));
89                        $bh_header_offset += 4;
90
91                        $getid3->info['szip']['BH'][] = $bh_data_array;
92                    }
93                    break;
94
95                default:
96                    break 2;
97            }
98        }
99
100        return true;
101    }
102
103}
104
105?>
Note: See TracBrowser for help on using the repository browser.