patch from Peter Listiak to get last modified date and time of the compressed file
This commit is contained in:
@@ -16,6 +16,9 @@ $Source$
|
||||
* tbl_change.php3: fixed bug #535984 - JS Error in tbl_change.php3.
|
||||
* tbl_replace.php3: fixed bug #536707 - undefined variables.
|
||||
* lang/italian.inc.php3: updated thanks to Pietro Danesi.
|
||||
* libraries/zip.lib.php3: merged a patch from
|
||||
Peter Listiak <mlady@users.sourceforge.net> to get last modified date and
|
||||
time of the compressed file.
|
||||
|
||||
2002-03-28 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* sql.php3, bug #535648: bookmarks can't be saved on the second server.
|
||||
|
@@ -9,10 +9,13 @@
|
||||
* Based on :
|
||||
*
|
||||
* http://www.zend.com/codex.php3?id=535&single=1
|
||||
* By Eric Mueller (eric@themepark.com)
|
||||
* By Eric Mueller <eric@themepark.com>
|
||||
*
|
||||
* http://www.zend.com/codex.php3?id=470&single=1
|
||||
* by Denis125 (webmaster@atlant.ru)
|
||||
* by Denis125 <webmaster@atlant.ru>
|
||||
*
|
||||
* a patch from Peter Listiak <mlady@users.sourceforge.net> for last modified
|
||||
* date and time of the compressed file
|
||||
*
|
||||
* Official ZIP file format: http://www.pkware.com/appnote.txt
|
||||
*
|
||||
@@ -50,22 +53,74 @@ class zipfile
|
||||
|
||||
|
||||
/**
|
||||
* Adds "file" to archive
|
||||
* Converts the date y/n/d and time h:m:s to a four byte DOS date and time
|
||||
* format (date in high two bytes, time in low two bytes allowing magnitude
|
||||
* comparison).
|
||||
*
|
||||
* @param string file contents
|
||||
* @param string name of the file in the archive (may contains the path)
|
||||
* @param integer the current year
|
||||
* @param integer the current month
|
||||
* @param integer the current day
|
||||
* @param integer the current hour
|
||||
* @param integer the current minut
|
||||
* @param integer the current second
|
||||
*
|
||||
* @return integer the current date in a four byte DOS format
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function addFile($data, $name)
|
||||
function dosTime($year, $month, $day, $hour, $minute, $second) {
|
||||
return ($year < 1980)
|
||||
? dosTime(1980, 1, 1, 0, 0, 0)
|
||||
: (($year - 1980) << 25) | ($month << 21) | ($day << 16) |
|
||||
($hour << 11) | ($minute << 5) | ($second >> 1);
|
||||
} // end of the 'dosTime()' method
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Unix time $unixtime in DOS format, rounded up to the next
|
||||
* two second boundary.
|
||||
*
|
||||
* @param integer the current timestamp
|
||||
*
|
||||
* @return integer the current date in a four byte DOS format
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @see DOSTime()
|
||||
*/
|
||||
function unix2DosTime($unixtime = 0) {
|
||||
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
|
||||
|
||||
return $this->dosTime($timearray['year'], $timearray['mon'], $timearray['mday'],
|
||||
$timearray['hours'], $timearray['minutes'], $timearray['seconds']);
|
||||
} // end of the 'unix2DosTime()' method
|
||||
|
||||
|
||||
/**
|
||||
* Adds "file" to archive
|
||||
*
|
||||
* @param string file contents
|
||||
* @param string name of the file in the archive (may contains the path)
|
||||
* @param integer the current timestamp
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function addFile($data, $name, $time = 0)
|
||||
{
|
||||
$name = str_replace('\\', '/', $name);
|
||||
$name = str_replace('\\', '/', $name);
|
||||
|
||||
$dtime = dechex ($this->unix2DosTime($time));
|
||||
$hexdtime = '\x' . $dtime[6] . $dtime[7]
|
||||
. '\x' . $dtime[4] . $dtime[5]
|
||||
. '\x' . $dtime[2] . $dtime[3]
|
||||
. '\x' . $dtime[0] . $dtime[1];
|
||||
eval('$hexdtime = "' . $hexdtime . '";');
|
||||
|
||||
$fr = "\x50\x4b\x03\x04";
|
||||
$fr .= "\x14\x00"; // ver needed to extract
|
||||
$fr .= "\x00\x00"; // gen purpose bit flag
|
||||
$fr .= "\x08\x00"; // compression method
|
||||
$fr .= "\x00\x00\x00\x00"; // last mod time and date
|
||||
$fr .= $hexdtime; // last mod time and date
|
||||
|
||||
// "local file header" segment
|
||||
$unc_len = strlen($data);
|
||||
@@ -99,7 +154,7 @@ class zipfile
|
||||
$cdrec .= "\x14\x00"; // version needed to extract
|
||||
$cdrec .= "\x00\x00"; // gen purpose bit flag
|
||||
$cdrec .= "\x08\x00"; // compression method
|
||||
$cdrec .= "\x00\x00\x00\x00"; // last mod time & date
|
||||
$cdrec .= $hexdtime; // last mod time & date
|
||||
$cdrec .= pack('V', $crc); // crc32
|
||||
$cdrec .= pack('V', $c_len); // compressed filesize
|
||||
$cdrec .= pack('V', $unc_len); // uncompressed filesize
|
||||
|
Reference in New Issue
Block a user