framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php
protected function extractTo($extractPath, $extractClientPath, $filePathInfo, $sFileName, $originalFileName)
  {
    $sfilePathInfo = pathinfo($extractPath.$sFileName);
    $extractClientPathDir = $filePathInfo['dirname'];
    if ( $filePathInfo['dirname'] == '.' ){
      $extractClientPathDir = '';
    }
    $folderPath = CKFinder_Connector_Utils_FileSystem::combinePaths($extractClientPath,$extractClientPathDir);

    $_aclConfig = $this->_config->getAccessControlConfig();
    $aclMask = $_aclConfig->getComputedMask($this->_currentFolder->getResourceTypeName(),$folderPath);
    $canCreateFolder = (($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) == CKFINDER_CONNECTOR_ACL_FOLDER_CREATE );
    // create sub-directory of zip archive
    if ( empty($sfilePathInfo['extension']) )
    {
      $fileStat = $this->zip->statName($originalFileName);
      $isDir = false;
      if ( $fileStat && empty($fileStat['size']) ){
        $isDir = true;
      }
      if( !empty($sfilePathInfo['dirname']) && !empty($sfilePathInfo['basename']) && !file_exists($sfilePathInfo['dirname'].'/'.$sfilePathInfo['basename']) )
      {
        if ( !$canCreateFolder ){
          return;
        }
        if ( $isDir ) {
          CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively( $sfilePathInfo['dirname'].'/'.$sfilePathInfo['basename'] );
          return;
        } else {
          CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively( $sfilePathInfo['dirname']);
        }
      } else {
        return;
      }
    }

    // extract file
    if ( !file_exists($sfilePathInfo['dirname']) ){
      if ( !$canCreateFolder ){
        $this->errorCode = CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED;
        $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName );
        return;
      }
      CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively($sfilePathInfo['dirname']);
    }
    $isAuthorized = (($aclMask & CKFINDER_CONNECTOR_ACL_FILE_UPLOAD ) == CKFINDER_CONNECTOR_ACL_FILE_UPLOAD );
    if ( !$isAuthorized ){
      $this->errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED;
      $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
      return;
    }
    if ( copy('zip://'.$this->filePath.'#'.$originalFileName, $extractPath.$sFileName) )
    {
      $this->appendUnzippedNode($this->unzippedNodes,$originalFileName);
      // chmod extracted file
      if ( is_file($extractPath.$sFileName) && ( $perms = $this->_config->getChmodFiles()) )
      {
        $oldumask = umask(0);
        chmod( $extractPath.$sFileName, $perms );
        umask( $oldumask );
      }
    }
    // file extraction failed, add to skipped
    else
    {
      $this->errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED;
      $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
    }
  }
protected function extractTo($extractPath, $extractClientPath, $filePathInfo, $sFileName, $originalFileName)
  {
    $sfilePathInfo = pathinfo($extractPath.$sFileName);
    $extractClientPathDir = $filePathInfo['dirname'];
    if ( $filePathInfo['dirname'] == '.' ){
      $extractClientPathDir = '';
    }
    $folderPath = CKFinder_Connector_Utils_FileSystem::combinePaths($extractClientPath,$extractClientPathDir);

    $_aclConfig = $this->_config->getAccessControlConfig();
    $aclMask = $_aclConfig->getComputedMask($this->_currentFolder->getResourceTypeName(),$folderPath);
    $canCreateFolder = (($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) == CKFINDER_CONNECTOR_ACL_FOLDER_CREATE );
    // create sub-directory of zip archive
    if ( empty($sfilePathInfo['extension']) )
    {
      $fileStat = $this->zip->statName($originalFileName);
      $isDir = false;
      if ( $fileStat && empty($fileStat['size']) ){
        $isDir = true;
      }
      if( !empty($sfilePathInfo['dirname']) && !empty($sfilePathInfo['basename']) && !file_exists($sfilePathInfo['dirname'].'/'.$sfilePathInfo['basename']) )
      {
        if ( !$canCreateFolder ){
          return;
        }
        if ( $isDir ) {
          CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively( $sfilePathInfo['dirname'].'/'.$sfilePathInfo['basename'] );
          return;
        } else {
          CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively( $sfilePathInfo['dirname']);
        }
      } else {
        return;
      }
    }

    // extract file
    if ( !file_exists($sfilePathInfo['dirname']) ){
      if ( !$canCreateFolder ){
        $this->errorCode = CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED;
        $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName );
        return;
      }
      CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively($sfilePathInfo['dirname']);
    }
    $isAuthorized = (($aclMask & CKFINDER_CONNECTOR_ACL_FILE_UPLOAD ) == CKFINDER_CONNECTOR_ACL_FILE_UPLOAD );
    if ( !$isAuthorized ){
      $this->errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED;
      $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
      return;
    }
    if ( copy('zip://'.$this->filePath.'#'.$originalFileName, $extractPath.$sFileName) )
    {
      $this->appendUnzippedNode($this->unzippedNodes,$originalFileName);
      // chmod extracted file
      if ( is_file($extractPath.$sFileName) && ( $perms = $this->_config->getChmodFiles()) )
      {
        $oldumask = umask(0);
        chmod( $extractPath.$sFileName, $perms );
        umask( $oldumask );
      }
    }
    // file extraction failed, add to skipped
    else
    {
      $this->errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED;
      $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
    }
  }
protected function extractTo ( $ extractPath , $ extractClientPath , $ filePathInfo , $ sFileName , $ originalFileName ) { $ sfilePathInfo = pathinfo ( $ extractPath . $ sFileName ) ; $ extractClientPathDir = $ filePathInfo [ 'dirname' ] ; if ( $ filePathInfo [ 'dirname' ] == '.' ) { $ extractClientPathDir = '' ; } $ folderPath = CKFinder_Connector_Utils_FileSystem :: combinePaths ( $ extractClientPath , $ extractClientPathDir ) ; $ _aclConfig = $ this -> _config -> getAccessControlConfig ( ) ; $ aclMask = $ _aclConfig -> getComputedMask ( $ this -> _currentFolder -> getResourceTypeName ( ) , $ folderPath ) ; $ canCreateFolder = ( ( $ aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) == CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) ; // create sub-directory of zip archive if ( empty ( $ sfilePathInfo [ 'extension' ] ) ) { $ fileStat = $ this -> zip -> statName ( $ originalFileName ) ; $ isDir = false ; if ( $ fileStat && empty ( $ fileStat [ 'size' ] ) ) { $ isDir = true ; } if ( ! empty ( $ sfilePathInfo [ 'dirname' ] ) && ! empty ( $ sfilePathInfo [ 'basename' ] ) && ! file_exists ( $ sfilePathInfo [ 'dirname' ] . '/' . $ sfilePathInfo [ 'basename' ] ) ) { if ( ! $ canCreateFolder ) { return ; } if ( $ isDir ) { CKFinder_Connector_Utils_FileSystem :: createDirectoryRecursively ( $ sfilePathInfo [ 'dirname' ] . '/' . $ sfilePathInfo [ 'basename' ] ) ; return ; } else { CKFinder_Connector_Utils_FileSystem :: createDirectoryRecursively ( $ sfilePathInfo [ 'dirname' ] ) ; } } else { return ; } } // extract file if ( ! file_exists ( $ sfilePathInfo [ 'dirname' ] ) ) { if ( ! $ canCreateFolder ) { $ this -> errorCode = CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED ; $ this -> appendErrorNode ( $ this -> skippedFilesNode , $ this -> errorCode , $ originalFileName ) ; return ; } CKFinder_Connector_Utils_FileSystem :: createDirectoryRecursively ( $ sfilePathInfo [ 'dirname' ] ) ; } $ isAuthorized = ( ( $ aclMask & CKFINDER_CONNECTOR_ACL_FILE_UPLOAD ) == CKFINDER_CONNECTOR_ACL_FILE_UPLOAD ) ; if ( ! $ isAuthorized ) { $ this -> errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED ; $ this -> appendErrorNode ( $ this -> skippedFilesNode , $ this -> errorCode , $ originalFileName ) ; return ; } if ( copy ( 'zip://' . $ this -> filePath . '#' . $ originalFileName , $ extractPath . $ sFileName ) ) { $ this -> appendUnzippedNode ( $ this -> unzippedNodes , $ originalFileName ) ; // chmod extracted file if ( is_file ( $ extractPath . $ sFileName ) && ( $ perms = $ this -> _config -> getChmodFiles ( ) ) ) { $ oldumask = umask ( 0 ) ; chmod ( $ extractPath . $ sFileName , $ perms ) ; umask ( $ oldumask ) ; } } // file extraction failed, add to skipped else { $ this -> errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED ; $ this -> appendErrorNode ( $ this -> skippedFilesNode , $ this -> errorCode , $ originalFileName ) ; } }
Extract one file from zip archive

@param string $extractPath
@param string $extractClientPath
@param array  $filePathInfo
@param string $sFileName
@param string $originalFileName
Extract one file from zip archive