public function makeZip($src, $dest, $basedir) { @set_time_limit(0); require_once AJXP_BIN_FOLDER . "/pclzip.lib.php"; $filePaths = array(); foreach ($src as $item) { $realFile = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $this->urlBase . ($item[0] == "/" ? "" : "/") . AJXP_Utils::securePath($item)); $basedir = trim(dirname($realFile)) . "/"; $filePaths[] = array(PCLZIP_ATT_FILE_NAME => $realFile, PCLZIP_ATT_FILE_NEW_SHORT_NAME => basename($item)); } $this->logDebug("Pathes", $filePaths); $this->logDebug("Basedir", array($basedir)); self::$filteringDriverInstance = $this; $archive = new PclZip($dest); $vList = $archive->create($filePaths, PCLZIP_OPT_REMOVE_PATH, $basedir, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_ADD_TEMP_FILE_ON); if (!$vList) { throw new Exception("Zip creation error : ({$dest}) " . $archive->errorInfo(true)); } self::$filteringDriverInstance = null; return $vList; }
public function makeZip($src, $dest, $basedir) { @set_time_limit(0); require_once AJXP_BIN_FOLDER . "/pclzip.lib.php"; $zipEncoding = ConfService::getCoreConf("ZIP_ENCODING"); $filePaths = array(); foreach ($src as $item) { $url = $this->urlBase . ($item[0] == "/" ? "" : "/") . AJXP_Utils::securePath($item); $realFile = AJXP_MetaStreamWrapper::getRealFSReference($url); //$basedir = trim(dirname($realFile))."/"; if (basename($item) == "") { $filePaths[] = array(PCLZIP_ATT_FILE_NAME => $realFile); } else { $shortName = basename($item); if (!empty($zipEncoding)) { $test = iconv(SystemTextEncoding::getEncoding(), $zipEncoding, $shortName); if ($test !== false) { $shortName = $test; } } $filePaths[] = array(PCLZIP_ATT_FILE_NAME => $realFile, PCLZIP_ATT_FILE_NEW_SHORT_NAME => $shortName); } } self::$filteringDriverInstance = $this; $archive = new PclZip($dest); if ($basedir == "__AJXP_ZIP_FLAT__/") { $vList = $archive->create($filePaths, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_ADD_TEMP_FILE_ON, PCLZIP_CB_PRE_ADD, 'zipPreAddCallback'); } else { $basedir = AJXP_MetaStreamWrapper::getRealFSReference($this->urlBase) . trim($basedir); $this->logDebug("Basedir", array($basedir)); $vList = $archive->create($filePaths, PCLZIP_OPT_REMOVE_PATH, $basedir, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_ADD_TEMP_FILE_ON, PCLZIP_CB_PRE_ADD, 'zipPreAddCallback'); } if (!$vList) { throw new Exception("Zip creation error : ({$dest}) " . $archive->errorInfo(true)); } self::$filteringDriverInstance = null; return $vList; }