当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPZip::filelist方法代码示例

本文整理汇总了PHP中PHPZip::filelist方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPZip::filelist方法的具体用法?PHP PHPZip::filelist怎么用?PHP PHPZip::filelist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPZip的用法示例。


在下文中一共展示了PHPZip::filelist方法的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);
                 }
//.........这里部分代码省略.........
开发者ID:polarlight1989,项目名称:08cms,代码行数:101,代码来源:upload.cls.php


注:本文中的PHPZip::filelist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。