Пример #1
0
function ___ziplist()
{
    $zip = trim(func_get_arg(0));
    if (!is_readable('pclzip.php') || !___getmime($zip, 'zip')) {
        return false;
    }
    require 'pclzip.php';
    $pclzip = new pclzip($zip);
    if (!($getlist = $pclzip->listContent())) {
        return false;
    }
    if (!is_array($getlist) || count($getlist) < 1) {
        return false;
    }
    return $getlist;
}
Пример #2
0
 /**
  * Extract template package.
  * 
  * @param  string    $package 
  * @access public
  * @return void
  */
 public function extractPackage($package)
 {
     $packageFile = $this->app->getDataRoot() . "template/{$package}.zip";
     $this->app->loadClass('pclzip', true);
     $zip = new pclzip($packageFile);
     $files = $zip->listContent();
     $tempPath = $this->app->getDataRoot() . 'template/' . $package . DS;
     if (is_dir($tempPath)) {
         $fileClass = $this->app->loadClass('zfile');
         $fileClass->removeDir($tempPath);
     }
     $return = new stdclass();
     $removePath = $files[0]['filename'];
     if ($zip->extract(PCLZIP_OPT_PATH, $tempPath, PCLZIP_OPT_REMOVE_PATH, $removePath) == 0) {
         $return->result = 'fail';
         $return->error = $zip->errorInfo(true);
     }
     return true;
 }
Пример #3
0
 /**
  * Extract zip.
  * 
  * @param  string    $zipFile 
  * @access public
  * @return string
  */
 public function extractZip($zipFile)
 {
     $classFile = $this->app->loadClass('zfile');
     $parentPath = $this->app->getCacheRoot() . 'uploadimages/';
     if (!is_dir($parentPath)) {
         mkdir($parentPath, 0777, true);
     }
     $filePath = $parentPath . str_replace('.zip', '', basename($zipFile)) . '/';
     if (is_dir($filePath)) {
         $classFile->removeDir($filePath);
     }
     mkdir($filePath);
     $this->app->loadClass('pclzip', true);
     $zip = new pclzip($zipFile);
     $files = $zip->listContent();
     foreach ($files as $i => $uploadFile) {
         $extension = strtolower(substr(strrchr($uploadFile['filename'], '.'), 1));
         if (empty($extension) or !in_array($extension, $this->config->file->imageExtensions)) {
             return false;
         }
     }
     $extractedFiles = array();
     foreach ($files as $i => $uploadFile) {
         $fileName = mb_convert_encoding($uploadFile['filename'], 'UTF-8', 'gb2312');
         $file = array();
         $file['extension'] = $this->getExtension($fileName);
         $file['pathname'] = $this->setPathName($i, $file['extension']);
         $file['title'] = str_replace(".{$file['extension']}", '', $fileName);
         $file['size'] = $uploadFile['size'];
         $fileName = basename($file['pathname']);
         $file['realpath'] = $filePath . $fileName;
         $list = $zip->extract(PCLZIP_OPT_BY_NAME, $uploadFile['filename'], PCLZIP_OPT_EXTRACT_AS_STRING);
         if ($list) {
             file_put_contents($file['realpath'], $list[0]['content']);
             $extractedFiles[$fileName] = $file;
         }
     }
     return $extractedFiles;
 }
Пример #4
0
 /**
  * Extract an extension.
  * 
  * @param  string    $extension 
  * @access public
  * @return object
  */
 public function extractPackage($extension)
 {
     $return = new stdclass();
     $return->result = 'ok';
     $return->error = '';
     /* try remove pre extracted files. */
     $extensionPath = "ext/{$extension}";
     if (is_dir($extensionPath)) {
         $this->classFile->removeDir($extensionPath);
     }
     /* Extract files. */
     $packageFile = $this->getPackageFile($extension);
     $this->app->loadClass('pclzip', true);
     $zip = new pclzip($packageFile);
     $files = $zip->listContent();
     $removePath = $files[0]['filename'];
     if ($zip->extract(PCLZIP_OPT_PATH, $extensionPath, PCLZIP_OPT_REMOVE_PATH, $removePath) == 0) {
         $return->result = 'fail';
         $return->error = $zip->errorInfo(true);
     }
     return $return;
 }
Пример #5
0
 /**
  * Extract zip.
  * 
  * @param  string    $zipFile 
  * @access public
  * @return string
  */
 public function extractZip($zipFile)
 {
     $classFile = $this->app->loadClass('zfile');
     $parentPath = $this->app->getCacheRoot() . 'uploadimages/';
     if (!is_dir($parentPath)) {
         mkdir($parentPath, 0777, true);
     }
     $filePath = $parentPath . str_replace('.zip', '', basename($zipFile)) . '/';
     if (is_dir($filePath)) {
         $classFile->removeDir($filePath);
     }
     $this->app->loadClass('pclzip', true);
     $zip = new pclzip($zipFile);
     $files = $zip->listContent();
     if ($zip->extract(PCLZIP_OPT_PATH, $filePath) == 0) {
         return false;
     }
     return $filePath;
 }
Пример #6
0
 /**
  * Extract zip.
  * 
  * @param  string    $zipFile 
  * @access public
  * @return string
  */
 public function extractZip($zipFile)
 {
     $classFile = $this->app->loadClass('zfile');
     $parentPath = $this->app->getCacheRoot() . 'uploadimages/';
     if (!is_dir($parentPath)) {
         mkdir($parentPath, 0777, true);
     }
     $filePath = $parentPath . str_replace('.zip', '', basename($zipFile)) . '/';
     if (is_dir($filePath)) {
         $classFile->removeDir($filePath);
     }
     $this->app->loadClass('pclzip', true);
     $zip = new pclzip($zipFile);
     $files = $zip->listContent();
     foreach ($files as $uploadFile) {
         $extension = strtolower(substr(strrchr($uploadFile['filename'], '.'), 1));
         if (empty($extension) or !in_array($extension, $this->config->file->imageExtensions)) {
             return false;
         }
     }
     if ($zip->extract(PCLZIP_OPT_PATH, $filePath) == 0) {
         return false;
     }
     return $filePath;
 }