You are here

function PclZip::privWriteCentralFileHeader in Quiz 6.5

Same name and namespace in other branches
  1. 6.6 includes/moodle/lib/pclzip/pclzip.lib.php \PclZip::privWriteCentralFileHeader()
2 calls to PclZip::privWriteCentralFileHeader()
PclZip::privAdd in includes/moodle/lib/pclzip/pclzip.lib.php
PclZip::privAddList in includes/moodle/lib/pclzip/pclzip.lib.php

File

includes/moodle/lib/pclzip/pclzip.lib.php, line 2892

Class

PclZip

Code

function privWriteCentralFileHeader(&$p_header) {

  //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
  $v_result = 1;

  // TBC

  //for(reset($p_header); $key = key($p_header); next($p_header)) {

  //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);

  //}

  // ----- Transform UNIX mtime to DOS format mdate/mtime

  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
  $v_date = getdate($p_header['mtime']);
  $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2;
  $v_mdate = ($v_date['year'] - 1980 << 9) + ($v_date['mon'] << 5) + $v_date['mday'];

  // ----- Packed data
  $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x2014b50, $p_header['version'], $p_header['version_extracted'], $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], $p_header['compressed_size'], $p_header['size'], strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'], $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']);

  // ----- Write the 42 bytes of the header in the zip file
  fputs($this->zip_fd, $v_binary_data, 46);

  // ----- Write the variable fields
  if (strlen($p_header['stored_filename']) != 0) {
    fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
  }
  if ($p_header['extra_len'] != 0) {
    fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
  }
  if ($p_header['comment_len'] != 0) {
    fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
  }

  // ----- Return

  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  return $v_result;
}