wnload.php 文件部分, 根据自己的需要修改一下 //---------------------- 中间的部分即可
?php
class zipfile {
var $datasec = array ()
var $ctrl_dir = array ()
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"
var $old_offset = 0
function unix2_dostime($unixtime = 0){
$timearray = ($unixtime == 0) ? getdate () : getdate($unixtime)
if ($timearray ['year'] 1980){
$timearray ['year'] = 1980
$timearray ['mon'] = 1
$timearray ['mday'] = 1
$timearray ['hours'] = 0
$timearray ['minutes'] = 0
$timearray ['seconds'] = 0
}
return (($timearray ['year'] - 1980) 25) | ($timearray ['mon'] 21) | ($timearray ['mday'] 16) | ($timearray ['hours'] 11) | ($timearray ['minutes'] 5) | ($timearray ['seconds'] >>1)
}
function add_file($data, $name, $time = 0){
$name = str_replace('\\', '/', $name)
$dtime = dechex($this->unix2_dostime($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"
$fr .= "\x00\x00"
$fr .= "\x08\x00"
$fr .= $hexdtime
$unc_len = strlen($data)
$crc = crc32($data)
$zdata = gz......一帆风顺吉星到 万事如意福临门 财源广进
加一个zip模块进去使用方式如下:
<?php
$zip = new ZipArchive()
$filename = "./test112.zip"
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit("cannot open <$filename>")
}
$zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt. ")
$zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt. ")
$zip->addFile($thisdir . "/too.php","/testfromfile.php")
echo "numfiles: " . $zip->numFiles . " "
echo "status:" . $zip->status . " "
$zip->close()
?>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)