src/Zip.php
protected function makeCentralFileRecord($offset, $ts, $crc, $len, $clen, $name, $comp = null)
    {
        if(is_null($comp)) $comp = $len != $clen;
        $comp = $comp ? 8 : 0;
        $dtime = dechex($this->makeDosTime($ts));

        list($name, $extra) = $this->encodeFilename($name);

        $header = "\x50\x4b\x01\x02"; // central file header signature
        $header .= pack('v', 14); // version made by - VFAT
        $header .= pack('v', 20); // version needed to extract - 2.0
        $header .= pack('v', 0); // general purpose flag - no flags set
        $header .= pack('v', $comp); // compression method - deflate|none
        $header .= pack(
            'H*',
            $dtime[6] . $dtime[7] .
            $dtime[4] . $dtime[5] .
            $dtime[2] . $dtime[3] .
            $dtime[0] . $dtime[1]
        ); //  last mod file time and date
        $header .= pack('V', $crc); // crc-32
        $header .= pack('V', $clen); // compressed size
        $header .= pack('V', $len); // uncompressed size
        $header .= pack('v', strlen($name)); // file name length
        $header .= pack('v', strlen($extra)); // extra field length
        $header .= pack('v', 0); // file comment length
        $header .= pack('v', 0); // disk number start
        $header .= pack('v', 0); // internal file attributes
        $header .= pack('V', 0); // external file attributes  @todo was 0x32!?
        $header .= pack('V', $offset); // relative offset of local header
        $header .= $name; // file name
        $header .= $extra; // extra (utf-8 filename)

        return $header;
    }
protected function makeCentralFileRecord($offset, $ts, $crc, $len, $clen, $name, $comp = null)
    {
        if(is_null($comp)) $comp = $len != $clen;
        $comp = $comp ? 8 : 0;
        $dtime = dechex($this->makeDosTime($ts));

        list($name, $extra) = $this->encodeFilename($name);

        $header = "\x50\x4b\x01\x02"; // central file header signature
        $header .= pack('v', 14); // version made by - VFAT
        $header .= pack('v', 20); // version needed to extract - 2.0
        $header .= pack('v', 0); // general purpose flag - no flags set
        $header .= pack('v', $comp); // compression method - deflate|none
        $header .= pack(
            'H*',
            $dtime[6] . $dtime[7] .
            $dtime[4] . $dtime[5] .
            $dtime[2] . $dtime[3] .
            $dtime[0] . $dtime[1]
        ); //  last mod file time and date
        $header .= pack('V', $crc); // crc-32
        $header .= pack('V', $clen); // compressed size
        $header .= pack('V', $len); // uncompressed size
        $header .= pack('v', strlen($name)); // file name length
        $header .= pack('v', strlen($extra)); // extra field length
        $header .= pack('v', 0); // file comment length
        $header .= pack('v', 0); // disk number start
        $header .= pack('v', 0); // internal file attributes
        $header .= pack('V', 0); // external file attributes  @todo was 0x32!?
        $header .= pack('V', $offset); // relative offset of local header
        $header .= $name; // file name
        $header .= $extra; // extra (utf-8 filename)

        return $header;
    }
protected function makeCentralFileRecord ( $ offset , $ ts , $ crc , $ len , $ clen , $ name , $ comp = null ) { if ( is_null ( $ comp ) ) $ comp = $ len != $ clen ; $ comp = $ comp ? 8 : 0 ; $ dtime = dechex ( $ this -> makeDosTime ( $ ts ) ) ; list ( $ name , $ extra ) = $ this -> encodeFilename ( $ name ) ; $ header = "\x50\x4b\x01\x02" ; // central file header signature $ header .= pack ( 'v' , 14 ) ; // version made by - VFAT $ header .= pack ( 'v' , 20 ) ; // version needed to extract - 2.0 $ header .= pack ( 'v' , 0 ) ; // general purpose flag - no flags set $ header .= pack ( 'v' , $ comp ) ; // compression method - deflate|none $ header .= pack ( 'H*' , $ dtime [ 6 ] . $ dtime [ 7 ] . $ dtime [ 4 ] . $ dtime [ 5 ] . $ dtime [ 2 ] . $ dtime [ 3 ] . $ dtime [ 0 ] . $ dtime [ 1 ] ) ; //  last mod file time and date $ header .= pack ( 'V' , $ crc ) ; // crc-32 $ header .= pack ( 'V' , $ clen ) ; // compressed size $ header .= pack ( 'V' , $ len ) ; // uncompressed size $ header .= pack ( 'v' , strlen ( $ name ) ) ; // file name length $ header .= pack ( 'v' , strlen ( $ extra ) ) ; // extra field length $ header .= pack ( 'v' , 0 ) ; // file comment length $ header .= pack ( 'v' , 0 ) ; // disk number start $ header .= pack ( 'v' , 0 ) ; // internal file attributes $ header .= pack ( 'V' , 0 ) ; // external file attributes  @todo was 0x32!? $ header .= pack ( 'V' , $ offset ) ; // relative offset of local header $ header .= $ name ; // file name $ header .= $ extra ; // extra (utf-8 filename) return $ header ; }
Returns a local file header for the given data

@param int $offset location of the local header
@param int $ts unix timestamp
@param int $crc CRC32 checksum of the uncompressed data
@param int $len length of the uncompressed data
@param int $clen length of the compressed data
@param string $name file name
@param boolean|null $comp if compression is used, if null it's determined from $len != $clen
@return string
Returns a local file header for the given data