本文整理汇总了PHP中PHPZip::Extract方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPZip::Extract方法的具体用法?PHP PHPZip::Extract怎么用?PHP PHPZip::Extract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPZip
的用法示例。
在下文中一共展示了PHPZip::Extract方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function zip_upload($localname, $type = 'image')
{
global $curuser, $memberid, $_FILES, $localfiles, $dir_userfile, $db, $tblprefix, $timestamp, $ftp_enabled;
include_once 'include/zip.cls.php';
$uploadfile = $result = array();
$file_saved = false;
$localfile = $localfiles[$type];
foreach ($localfile as $k => $v) {
if (empty($v['islocal'])) {
unset($localfile[$k]);
}
}
if (!$_FILES[$localname] || !mis_uploaded_file($_FILES[$localname]['tmp_name']) || !$_FILES[$localname]['tmp_name'] || !$_FILES[$localname]['name'] || $_FILES[$localname]['tmp_name'] == 'none') {
$result['error'] = 1;
//'不存在的上传文件!'
return $result;
}
$uploadfile = $_FILES[$localname];
$localfilename = addslashes($uploadfile['name']);
$uploadfile['mid'] = $curuser->info['mid'];
$uploadfile['mname'] = $curuser->info['mname'];
$uploadpath = $this->upload_path($type);
$fuploadpath = M_ROOT . $uploadpath;
if (empty($localfile)) {
//本地上传方案为空
@unlink($uploadfile['tmp_name']);
$result['error'] = 1;
return $result;
}
if ($this->capacity != -1 && $uploadfile['size'] > 1024 * $this->capacity) {
//超过空间
@unlink($uploadfile['tmp_name']);
$result['error'] = 1;
return $result;
}
$zip = new PHPZip($uploadfile['tmp_name']);
$lst = $zip->filelist();
$result['count'] = count($lst);
$ret = array();
$capacity = 1024 * $this->capacity;
$size = 0;
foreach ($lst as $z) {
if ($z['folder']) {
$result['count']--;
continue;
}
$extension = strtolower(mextension($z['name']));
if (!in_array($extension, array_keys($localfile))) {
//文件类型不在本地上传方案中
continue;
}
if (!empty($localfile[$extension]['minisize']) && $z['size'] < 1024 * $localfile[$extension]['minisize']) {
//'超出该文件类型大小限制!'
continue;
}
if (!empty($localfile[$extension]['maxsize']) && $z['size'] > 1024 * $localfile[$extension]['maxsize']) {
//'超出该文件类型大小限制!'
continue;
}
$size += $z['size'];
if ($this->capacity != -1 && $size > $capacity) {
break;
}
$ret[] = $z['index'];
}
if (empty($ret)) {
$result['error'] = -2;
return $result;
}
$tzip = "{$fuploadpath}{$memberid}_" . random(6) . '/';
$lst = $zip->Extract($tzip, $ret);
@unlink($uploadfile['tmp_name']);
$ret = array();
foreach ($lst as $k => $v) {
if (substr($k, -1) == '/') {
continue;
}
$uploadfile['filename'] = preg_replace("/(php|phtml|php3|php4|jsp|exe|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\\.|\$)/i", "_\\1\\2", date('dHis') . substr(md5($k . microtime()), 5, 10) . random(4, 1) . '.' . $extension);
$uploadfile['url'] = $uploadpath . $uploadfile['filename'];
$target = $fuploadpath . $uploadfile['filename'];
if (!rename($tzip . $k, $target)) {
continue;
}
$uploadfile['thumbed'] = 0;
if (in_array($extension, array('jpg', 'jpeg', 'gif', 'png', 'swf', 'bmp'))) {
if (!($infos = @getimagesize($target))) {
@unlink($target);
continue;
}
if (in_array($extension, array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) {
/* if(isset($infos[0]) && isset($infos[1])){
$result['width'] = $infos[0];
$result['height'] = $infos[1];
}*/
if ($this->image_thumb($target)) {
$uploadfile['thumbed'] = 1;
}
if ($this->image_watermark($target)) {
$uploadfile['size'] = filesize($target);
}
//.........这里部分代码省略.........