diff e2gallerypro/e2upload/Backend/Assets/getid3/module.archive.zip.php @ 3:3f6b44aa6b35 judyates

[svn r4] added ability to buy stuff, from a Prints page, but it doesn't work well with the css, and it also has not been fitted into the perl make system.
author rlm
date Mon, 22 Feb 2010 08:02:39 -0500
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/e2gallerypro/e2upload/Backend/Assets/getid3/module.archive.zip.php	Mon Feb 22 08:02:39 2010 -0500
     1.3 @@ -0,0 +1,510 @@
     1.4 +<?php
     1.5 +// +----------------------------------------------------------------------+
     1.6 +// | PHP version 5                                                        |
     1.7 +// +----------------------------------------------------------------------+
     1.8 +// | Copyright (c) 2002-2006 James Heinrich, Allan Hansen                 |
     1.9 +// +----------------------------------------------------------------------+
    1.10 +// | This source file is subject to version 2 of the GPL license,         |
    1.11 +// | that is bundled with this package in the file license.txt and is     |
    1.12 +// | available through the world-wide-web at the following url:           |
    1.13 +// | http://www.gnu.org/copyleft/gpl.html                                 |
    1.14 +// +----------------------------------------------------------------------+
    1.15 +// | getID3() - http://getid3.sourceforge.net or http://www.getid3.org    |
    1.16 +// +----------------------------------------------------------------------+
    1.17 +// | Authors: James Heinrich <infoØgetid3*org>                            |
    1.18 +// |          Allan Hansen <ahØartemis*dk>                                |
    1.19 +// +----------------------------------------------------------------------+
    1.20 +// | module.archive.zip.php                                               |
    1.21 +// | Module for analyzing pkZip files                                     |
    1.22 +// | dependencies: NONE                                                   |
    1.23 +// +----------------------------------------------------------------------+
    1.24 +//
    1.25 +// $Id: module.archive.zip.php,v 1.4 2006/11/02 10:48:00 ah Exp $
    1.26 +
    1.27 +
    1.28 +
    1.29 +class getid3_zip extends getid3_handler
    1.30 +{
    1.31 +
    1.32 +    public function Analyze() {
    1.33 +
    1.34 +        $getid3 = $this->getid3;
    1.35 +        
    1.36 +        $getid3->info['zip'] = array ();
    1.37 +        $info_zip = &$getid3->info['zip'];
    1.38 +        
    1.39 +        $getid3->info['fileformat'] = 'zip';
    1.40 +        
    1.41 +        $info_zip['encoding'] = 'ISO-8859-1';
    1.42 +        $info_zip['files']    = array ();
    1.43 +        $info_zip['compressed_size'] = $info_zip['uncompressed_size'] = $info_zip['entries_count'] = 0;
    1.44 +
    1.45 +        $eocd_search_data    = '';
    1.46 +        $eocd_search_counter = 0;
    1.47 +        while ($eocd_search_counter++ < 512) {
    1.48 +
    1.49 +            fseek($getid3->fp, -128 * $eocd_search_counter, SEEK_END);
    1.50 +            $eocd_search_data = fread($getid3->fp, 128).$eocd_search_data;
    1.51 +
    1.52 +            if (strstr($eocd_search_data, 'PK'."\x05\x06")) {
    1.53 +
    1.54 +                $eocd_position = strpos($eocd_search_data, 'PK'."\x05\x06");
    1.55 +                fseek($getid3->fp, (-128 * $eocd_search_counter) + $eocd_position, SEEK_END);
    1.56 +                $info_zip['end_central_directory'] = $this->ZIPparseEndOfCentralDirectory();
    1.57 +
    1.58 +                fseek($getid3->fp, $info_zip['end_central_directory']['directory_offset'], SEEK_SET);
    1.59 +                $info_zip['entries_count'] = 0;
    1.60 +                while ($central_directoryentry = $this->ZIPparseCentralDirectory($getid3->fp)) {
    1.61 +                    $info_zip['central_directory'][] = $central_directoryentry;
    1.62 +                    $info_zip['entries_count']++;
    1.63 +                    $info_zip['compressed_size']   += $central_directoryentry['compressed_size'];
    1.64 +                    $info_zip['uncompressed_size'] += $central_directoryentry['uncompressed_size'];
    1.65 +
    1.66 +                    if ($central_directoryentry['uncompressed_size'] > 0) {
    1.67 +                        $info_zip['files'] = getid3_zip::array_merge_clobber($info_zip['files'], getid3_zip::CreateDeepArray($central_directoryentry['filename'], '/', $central_directoryentry['uncompressed_size']));
    1.68 +                    }
    1.69 +                }
    1.70 +
    1.71 +                if ($info_zip['entries_count'] == 0) {
    1.72 +                    throw new getid3_exception('No Central Directory entries found (truncated file?)');
    1.73 +                }
    1.74 +
    1.75 +                if (!empty($info_zip['end_central_directory']['comment'])) {
    1.76 +                    $info_zip['comments']['comment'][] = $info_zip['end_central_directory']['comment'];
    1.77 +                }
    1.78 +
    1.79 +                if (isset($info_zip['central_directory'][0]['compression_method'])) {
    1.80 +                    $info_zip['compression_method'] = $info_zip['central_directory'][0]['compression_method'];
    1.81 +                }
    1.82 +                if (isset($info_zip['central_directory'][0]['flags']['compression_speed'])) {
    1.83 +                    $info_zip['compression_speed']  = $info_zip['central_directory'][0]['flags']['compression_speed'];
    1.84 +                }
    1.85 +                if (isset($info_zip['compression_method']) && ($info_zip['compression_method'] == 'store') && !isset($info_zip['compression_speed'])) {
    1.86 +                    $info_zip['compression_speed']  = 'store';
    1.87 +                }
    1.88 +
    1.89 +                return true;
    1.90 +            }
    1.91 +        }
    1.92 +
    1.93 +        if ($this->getZIPentriesFilepointer()) {
    1.94 +
    1.95 +            // central directory couldn't be found and/or parsed
    1.96 +            // scan through actual file data entries, recover as much as possible from probable trucated file
    1.97 +            if (@$info_zip['compressed_size'] > ($getid3->info['filesize'] - 46 - 22)) {
    1.98 +                throw new getid3_exception('Warning: Truncated file! - Total compressed file sizes ('.$info_zip['compressed_size'].' bytes) is greater than filesize minus Central Directory and End Of Central Directory structures ('.($getid3->info['filesize'] - 46 - 22).' bytes)');
    1.99 +            }
   1.100 +            throw new getid3_exception('Cannot find End Of Central Directory - returned list of files in [zip][entries] array may not be complete');
   1.101 +        }
   1.102 +        
   1.103 +        //throw new getid3_exception('Cannot find End Of Central Directory (truncated file?)');
   1.104 +    }
   1.105 +
   1.106 +
   1.107 +
   1.108 +    private function getZIPHeaderFilepointerTopDown() {
   1.109 +        
   1.110 +        // shortcut
   1.111 +        $getid3 = $this->getid3;
   1.112 +        
   1.113 +        $getid3->info['fileformat'] = 'zip';
   1.114 +        
   1.115 +        $getid3->info['zip'] = array ();
   1.116 +        $info_zip['compressed_size'] = $info_zip['uncompressed_size'] = $info_zip['entries_count'] = 0;
   1.117 +        
   1.118 +        rewind($getid3->fp);
   1.119 +        while ($fileentry = $this->ZIPparseLocalFileHeader()) {
   1.120 +            $info_zip['entries'][] = $fileentry;
   1.121 +            $info_zip['entries_count']++;
   1.122 +        }
   1.123 +        if ($info_zip['entries_count'] == 0) {
   1.124 +            throw new getid3_exception('No Local File Header entries found');
   1.125 +        }
   1.126 +
   1.127 +        $info_zip['entries_count']  = 0;
   1.128 +        while ($central_directoryentry = $this->ZIPparseCentralDirectory($getid3->fp)) {
   1.129 +            $info_zip['central_directory'][] = $central_directoryentry;
   1.130 +            $info_zip['entries_count']++;
   1.131 +            $info_zip['compressed_size']   += $central_directoryentry['compressed_size'];
   1.132 +            $info_zip['uncompressed_size'] += $central_directoryentry['uncompressed_size'];
   1.133 +        }
   1.134 +        if ($info_zip['entries_count'] == 0) {
   1.135 +            throw new getid3_exception('No Central Directory entries found (truncated file?)');
   1.136 +        }
   1.137 +
   1.138 +        if ($eocd = $this->ZIPparseEndOfCentralDirectory()) {
   1.139 +            $info_zip['end_central_directory'] = $eocd;
   1.140 +        } else {
   1.141 +            throw new getid3_exception('No End Of Central Directory entry found (truncated file?)');
   1.142 +        }
   1.143 +
   1.144 +        if (!@$info_zip['end_central_directory']['comment']) {
   1.145 +            $info_zip['comments']['comment'][] = $info_zip['end_central_directory']['comment'];
   1.146 +        }
   1.147 +
   1.148 +        return true;
   1.149 +    }
   1.150 +
   1.151 +
   1.152 +
   1.153 +    private function getZIPentriesFilepointer() {
   1.154 +        
   1.155 +        // shortcut
   1.156 +        $getid3 = $this->getid3;
   1.157 +        
   1.158 +        $getid3->info['zip'] = array ();
   1.159 +        $info_zip['compressed_size'] = $info_zip['uncompressed_size'] = $info_zip['entries_count'] = 0;
   1.160 +
   1.161 +        rewind($getid3->fp);
   1.162 +        while ($fileentry = $this->ZIPparseLocalFileHeader($getid3->fp)) {
   1.163 +            $info_zip['entries'][] = $fileentry;
   1.164 +            $info_zip['entries_count']++;
   1.165 +            $info_zip['compressed_size']   += $fileentry['compressed_size'];
   1.166 +            $info_zip['uncompressed_size'] += $fileentry['uncompressed_size'];
   1.167 +        }
   1.168 +        if ($info_zip['entries_count'] == 0) {
   1.169 +            throw new getid3_exception('No Local File Header entries found');
   1.170 +        }
   1.171 +
   1.172 +        return true;
   1.173 +    }
   1.174 +
   1.175 +
   1.176 +
   1.177 +    private function ZIPparseLocalFileHeader() {
   1.178 +        
   1.179 +        // shortcut
   1.180 +        $getid3 = $this->getid3;
   1.181 +
   1.182 +        $local_file_header['offset'] = ftell($getid3->fp);
   1.183 +        
   1.184 +        $zip_local_file_header = fread($getid3->fp, 30);
   1.185 +
   1.186 +        $local_file_header['raw']['signature'] = getid3_lib::LittleEndian2Int(substr($zip_local_file_header,  0, 4));
   1.187 +        
   1.188 +        // Invalid Local File Header Signature
   1.189 +        if ($local_file_header['raw']['signature'] != 0x04034B50) {
   1.190 +            fseek($getid3->fp, $local_file_header['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
   1.191 +            return false;
   1.192 +        }
   1.193 +        
   1.194 +        getid3_lib::ReadSequence('LittleEndian2Int', $local_file_header['raw'], $zip_local_file_header,  4, 
   1.195 +            array (
   1.196 +                'extract_version'    => 2, 
   1.197 +                'general_flags'      => 2, 
   1.198 +                'compression_method' => 2, 
   1.199 +                'last_mod_file_time' => 2, 
   1.200 +                'last_mod_file_date' => 2, 
   1.201 +                'crc_32'             => 2, 
   1.202 +                'compressed_size'    => 2, 
   1.203 +                'uncompressed_size'  => 2, 
   1.204 +                'filename_length'    => 2, 
   1.205 +                'extra_field_length' => 2
   1.206 +            )
   1.207 +        );        
   1.208 +
   1.209 +        $local_file_header['extract_version']         = sprintf('%1.1f', $local_file_header['raw']['extract_version'] / 10);
   1.210 +        $local_file_header['host_os']                 = $this->ZIPversionOSLookup(($local_file_header['raw']['extract_version'] & 0xFF00) >> 8);
   1.211 +        $local_file_header['compression_method']      = $this->ZIPcompressionMethodLookup($local_file_header['raw']['compression_method']);
   1.212 +        $local_file_header['compressed_size']         = $local_file_header['raw']['compressed_size'];
   1.213 +        $local_file_header['uncompressed_size']       = $local_file_header['raw']['uncompressed_size'];
   1.214 +        $local_file_header['flags']                   = $this->ZIPparseGeneralPurposeFlags($local_file_header['raw']['general_flags'], $local_file_header['raw']['compression_method']);
   1.215 +        $local_file_header['last_modified_timestamp'] = $this->DOStime2UNIXtime($local_file_header['raw']['last_mod_file_date'], $local_file_header['raw']['last_mod_file_time']);
   1.216 +
   1.217 +        $filename_extra_field_length = $local_file_header['raw']['filename_length'] + $local_file_header['raw']['extra_field_length'];
   1.218 +        if ($filename_extra_field_length > 0) {
   1.219 +            $zip_local_file_header .= fread($getid3->fp, $filename_extra_field_length);
   1.220 +
   1.221 +            if ($local_file_header['raw']['filename_length'] > 0) {
   1.222 +                $local_file_header['filename'] = substr($zip_local_file_header, 30, $local_file_header['raw']['filename_length']);
   1.223 +            }
   1.224 +            if ($local_file_header['raw']['extra_field_length'] > 0) {
   1.225 +                $local_file_header['raw']['extra_field_data'] = substr($zip_local_file_header, 30 + $local_file_header['raw']['filename_length'], $local_file_header['raw']['extra_field_length']);
   1.226 +            }
   1.227 +        }
   1.228 +
   1.229 +        $local_file_header['data_offset'] = ftell($getid3->fp);
   1.230 +        fseek($getid3->fp, $local_file_header['raw']['compressed_size'], SEEK_CUR);
   1.231 +
   1.232 +        if ($local_file_header['flags']['data_descriptor_used']) {
   1.233 +            $data_descriptor = fread($getid3->fp, 12);
   1.234 +            
   1.235 +            getid3_lib::ReadSequence('LittleEndian2Int', $local_file_header['data_descriptor'], $data_descriptor, 0, 
   1.236 +                array (
   1.237 +                'crc_32'            => 4,
   1.238 +                'compressed_size'   => 4,
   1.239 +                'uncompressed_size' => 4 
   1.240 +                )
   1.241 +            );
   1.242 +        }
   1.243 +
   1.244 +        return $local_file_header;
   1.245 +    }
   1.246 +
   1.247 +
   1.248 +
   1.249 +    private function ZIPparseCentralDirectory() {
   1.250 +        
   1.251 +        // shortcut
   1.252 +        $getid3 = $this->getid3;
   1.253 +
   1.254 +        $central_directory['offset'] = ftell($getid3->fp);
   1.255 +
   1.256 +        $zip_central_directory = fread($getid3->fp, 46);
   1.257 +
   1.258 +        $central_directory['raw']['signature']  = getid3_lib::LittleEndian2Int(substr($zip_central_directory,  0, 4));
   1.259 +        
   1.260 +        // invalid Central Directory Signature
   1.261 +        if ($central_directory['raw']['signature'] != 0x02014B50) {
   1.262 +            fseek($getid3->fp, $central_directory['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
   1.263 +            return false;
   1.264 +        }
   1.265 +        
   1.266 +        getid3_lib::ReadSequence('LittleEndian2Int', $central_directory['raw'], $zip_central_directory,  4, 
   1.267 +            array (
   1.268 +                'create_version'       => 2,
   1.269 +                'extract_version'      => 2,
   1.270 +                'general_flags'        => 2,
   1.271 +                'compression_method'   => 2,
   1.272 +                'last_mod_file_time'   => 2,
   1.273 +                'last_mod_file_date'   => 2,
   1.274 +                'crc_32'               => 4,
   1.275 +                'compressed_size'      => 4,
   1.276 +                'uncompressed_size'    => 4,
   1.277 +                'filename_length'      => 2,
   1.278 +                'extra_field_length'   => 2,
   1.279 +                'file_comment_length'  => 2,
   1.280 +                'disk_number_start'    => 2,
   1.281 +                'internal_file_attrib' => 2,
   1.282 +                'external_file_attrib' => 4,
   1.283 +                'local_header_offset'  => 4
   1.284 +            )
   1.285 +        );
   1.286 +        
   1.287 +        $central_directory['entry_offset']            = $central_directory['raw']['local_header_offset'];
   1.288 +        $central_directory['create_version']          = sprintf('%1.1f', $central_directory['raw']['create_version'] / 10);
   1.289 +        $central_directory['extract_version']         = sprintf('%1.1f', $central_directory['raw']['extract_version'] / 10);
   1.290 +        $central_directory['host_os']                 = $this->ZIPversionOSLookup(($central_directory['raw']['extract_version'] & 0xFF00) >> 8);
   1.291 +        $central_directory['compression_method']      = $this->ZIPcompressionMethodLookup($central_directory['raw']['compression_method']);
   1.292 +        $central_directory['compressed_size']         = $central_directory['raw']['compressed_size'];
   1.293 +        $central_directory['uncompressed_size']       = $central_directory['raw']['uncompressed_size'];
   1.294 +        $central_directory['flags']                   = $this->ZIPparseGeneralPurposeFlags($central_directory['raw']['general_flags'], $central_directory['raw']['compression_method']);
   1.295 +        $central_directory['last_modified_timestamp'] = $this->DOStime2UNIXtime($central_directory['raw']['last_mod_file_date'], $central_directory['raw']['last_mod_file_time']);
   1.296 +
   1.297 +        $filename_extra_field_comment_length = $central_directory['raw']['filename_length'] + $central_directory['raw']['extra_field_length'] + $central_directory['raw']['file_comment_length'];
   1.298 +        if ($filename_extra_field_comment_length > 0) {
   1.299 +            $filename_extra_field_comment = fread($getid3->fp, $filename_extra_field_comment_length);
   1.300 +
   1.301 +            if ($central_directory['raw']['filename_length'] > 0) {
   1.302 +                $central_directory['filename']= substr($filename_extra_field_comment, 0, $central_directory['raw']['filename_length']);
   1.303 +            }
   1.304 +            if ($central_directory['raw']['extra_field_length'] > 0) {
   1.305 +                $central_directory['raw']['extra_field_data'] = substr($filename_extra_field_comment, $central_directory['raw']['filename_length'], $central_directory['raw']['extra_field_length']);
   1.306 +            }
   1.307 +            if ($central_directory['raw']['file_comment_length'] > 0) {
   1.308 +                $central_directory['file_comment'] = substr($filename_extra_field_comment, $central_directory['raw']['filename_length'] + $central_directory['raw']['extra_field_length'], $central_directory['raw']['file_comment_length']);
   1.309 +            }
   1.310 +        }
   1.311 +
   1.312 +        return $central_directory;
   1.313 +    }
   1.314 +
   1.315 +    
   1.316 +    
   1.317 +    private function ZIPparseEndOfCentralDirectory() {
   1.318 +        
   1.319 +        // shortcut             
   1.320 +        $getid3 = $this->getid3;
   1.321 +    
   1.322 +        $end_of_central_directory['offset'] = ftell($getid3->fp);
   1.323 +
   1.324 +        $zip_end_of_central_directory = fread($getid3->fp, 22);
   1.325 +
   1.326 +        $end_of_central_directory['signature'] = getid3_lib::LittleEndian2Int(substr($zip_end_of_central_directory,  0, 4));
   1.327 +        
   1.328 +        // invalid End Of Central Directory Signature
   1.329 +        if ($end_of_central_directory['signature'] != 0x06054B50) {
   1.330 +            fseek($getid3->fp, $end_of_central_directory['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
   1.331 +            return false;
   1.332 +        }
   1.333 +        
   1.334 +        getid3_lib::ReadSequence('LittleEndian2Int', $end_of_central_directory, $zip_end_of_central_directory,  4, 
   1.335 +            array (
   1.336 +                'disk_number_current'         => 2,
   1.337 +                'disk_number_start_directory' => 2,
   1.338 +                'directory_entries_this_disk' => 2,
   1.339 +                'directory_entries_total'     => 2,
   1.340 +                'directory_size'              => 4,
   1.341 +                'directory_offset'            => 4,
   1.342 +                'comment_length'              => 2
   1.343 +            )
   1.344 +        );
   1.345 +        
   1.346 +        if ($end_of_central_directory['comment_length'] > 0) {
   1.347 +            $end_of_central_directory['comment'] = fread($getid3->fp, $end_of_central_directory['comment_length']);
   1.348 +        }
   1.349 +
   1.350 +        return $end_of_central_directory;
   1.351 +    }
   1.352 +    
   1.353 +
   1.354 +
   1.355 +    public static function ZIPparseGeneralPurposeFlags($flag_bytes, $compression_method) {
   1.356 +
   1.357 +        $parsed_flags['encrypted'] = (bool)($flag_bytes & 0x0001);
   1.358 +
   1.359 +        switch ($compression_method) {
   1.360 +            case 6:
   1.361 +                $parsed_flags['dictionary_size']    = (($flag_bytes & 0x0002) ? 8192 : 4096);
   1.362 +                $parsed_flags['shannon_fano_trees'] = (($flag_bytes & 0x0004) ? 3    : 2);
   1.363 +                break;
   1.364 +
   1.365 +            case 8:
   1.366 +            case 9:
   1.367 +                switch (($flag_bytes & 0x0006) >> 1) {
   1.368 +                    case 0:
   1.369 +                        $parsed_flags['compression_speed'] = 'normal';
   1.370 +                        break;
   1.371 +                    case 1:
   1.372 +                        $parsed_flags['compression_speed'] = 'maximum';
   1.373 +                        break;
   1.374 +                    case 2:
   1.375 +                        $parsed_flags['compression_speed'] = 'fast';
   1.376 +                        break;
   1.377 +                    case 3:
   1.378 +                        $parsed_flags['compression_speed'] = 'superfast';
   1.379 +                        break;
   1.380 +                }
   1.381 +                break;
   1.382 +        }
   1.383 +        $parsed_flags['data_descriptor_used'] = (bool)($flag_bytes & 0x0008);
   1.384 +
   1.385 +        return $parsed_flags;
   1.386 +    }
   1.387 +
   1.388 +
   1.389 +
   1.390 +    public static function ZIPversionOSLookup($index) {
   1.391 +        
   1.392 +        static $lookup = array (
   1.393 +            0  => 'MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems)',
   1.394 +            1  => 'Amiga',
   1.395 +            2  => 'OpenVMS',
   1.396 +            3  => 'Unix',
   1.397 +            4  => 'VM/CMS',
   1.398 +            5  => 'Atari ST',
   1.399 +            6  => 'OS/2 H.P.F.S.',
   1.400 +            7  => 'Macintosh',
   1.401 +            8  => 'Z-System',
   1.402 +            9  => 'CP/M',
   1.403 +            10 => 'Windows NTFS',
   1.404 +            11 => 'MVS',
   1.405 +            12 => 'VSE',
   1.406 +            13 => 'Acorn Risc',
   1.407 +            14 => 'VFAT',
   1.408 +            15 => 'Alternate MVS',
   1.409 +            16 => 'BeOS',
   1.410 +            17 => 'Tandem'
   1.411 +        );
   1.412 +        return (isset($lookup[$index]) ? $lookup[$index] : '[unknown]');
   1.413 +    }
   1.414 +
   1.415 +
   1.416 +
   1.417 +    public static function ZIPcompressionMethodLookup($index) {
   1.418 +
   1.419 +        static $lookup = array (
   1.420 +            0  => 'store',
   1.421 +            1  => 'shrink',
   1.422 +            2  => 'reduce-1',
   1.423 +            3  => 'reduce-2',
   1.424 +            4  => 'reduce-3',
   1.425 +            5  => 'reduce-4',
   1.426 +            6  => 'implode',
   1.427 +            7  => 'tokenize',
   1.428 +            8  => 'deflate',
   1.429 +            9  => 'deflate64',
   1.430 +            10 => 'PKWARE Date Compression Library Imploding'
   1.431 +        );
   1.432 +        return (isset($lookup[$index]) ? $lookup[$index] : '[unknown]');
   1.433 +    }
   1.434 +
   1.435 +
   1.436 +
   1.437 +    public static function DOStime2UNIXtime($DOSdate, $DOStime) {
   1.438 +
   1.439 +        /*
   1.440 +        // wFatDate
   1.441 +        // Specifies the MS-DOS date. The date is a packed 16-bit value with the following format:
   1.442 +        // Bits      Contents
   1.443 +        // 0-4    Day of the month (1-31)
   1.444 +        // 5-8    Month (1 = January, 2 = February, and so on)
   1.445 +        // 9-15   Year offset from 1980 (add 1980 to get actual year)
   1.446 +
   1.447 +        $UNIXday    =  ($DOSdate & 0x001F);
   1.448 +        $UNIXmonth  = (($DOSdate & 0x01E0) >> 5);
   1.449 +        $UNIXyear   = (($DOSdate & 0xFE00) >> 9) + 1980;
   1.450 +
   1.451 +        // wFatTime
   1.452 +        // Specifies the MS-DOS time. The time is a packed 16-bit value with the following format:
   1.453 +        // Bits   Contents
   1.454 +        // 0-4    Second divided by 2
   1.455 +        // 5-10   Minute (0-59)
   1.456 +        // 11-15  Hour (0-23 on a 24-hour clock)
   1.457 +
   1.458 +        $UNIXsecond =  ($DOStime & 0x001F) * 2;
   1.459 +        $UNIXminute = (($DOStime & 0x07E0) >> 5);
   1.460 +        $UNIXhour   = (($DOStime & 0xF800) >> 11);
   1.461 +
   1.462 +        return gmmktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
   1.463 +        */
   1.464 +        return gmmktime(($DOStime & 0xF800) >> 11, ($DOStime & 0x07E0) >> 5, ($DOStime & 0x001F) * 2, ($DOSdate & 0x01E0) >> 5, $DOSdate & 0x001F, (($DOSdate & 0xFE00) >> 9) + 1980);
   1.465 +    }
   1.466 +    
   1.467 +    
   1.468 +    
   1.469 +    public static function array_merge_clobber($array1, $array2) {
   1.470 +
   1.471 +        // written by kcØhireability*com
   1.472 +        // taken from http://www.php.net/manual/en/function.array-merge-recursive.php
   1.473 +        
   1.474 +        if (!is_array($array1) || !is_array($array2)) {
   1.475 +            return false;
   1.476 +        }
   1.477 +        
   1.478 +        $newarray = $array1;
   1.479 +        foreach ($array2 as $key => $val) {
   1.480 +            if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
   1.481 +                $newarray[$key] = getid3_zip::array_merge_clobber($newarray[$key], $val);
   1.482 +            } else {
   1.483 +                $newarray[$key] = $val;
   1.484 +            }
   1.485 +        }
   1.486 +        return $newarray;
   1.487 +    }
   1.488 +    
   1.489 +    
   1.490 +    
   1.491 +    public static function CreateDeepArray($array_path, $separator, $value) {
   1.492 +
   1.493 +        // assigns $value to a nested array path:
   1.494 +        //   $foo = getid3_lib::CreateDeepArray('/path/to/my', '/', 'file.txt')
   1.495 +        // is the same as:
   1.496 +        //   $foo = array ('path'=>array('to'=>'array('my'=>array('file.txt'))));
   1.497 +        // or
   1.498 +        //   $foo['path']['to']['my'] = 'file.txt';
   1.499 +        
   1.500 +        while ($array_path{0} == $separator) {
   1.501 +            $array_path = substr($array_path, 1);
   1.502 +        }
   1.503 +        if (($pos = strpos($array_path, $separator)) !== false) {
   1.504 +            return array (substr($array_path, 0, $pos) => getid3_zip::CreateDeepArray(substr($array_path, $pos + 1), $separator, $value));
   1.505 +        }
   1.506 +        
   1.507 +        return array ($array_path => $value);
   1.508 +    }
   1.509 +
   1.510 +}
   1.511 +
   1.512 +
   1.513 +?>
   1.514 \ No newline at end of file