public function archive($hashes, $mime)
{
if ($this->commandDisabled('archive')) {
return $this->setError(elFinder::ERROR_PERM_DENIED);
}
$archiver = isset($this->archivers['create'][$mime]) ? $this->archivers['create'][$mime] : false;
if (!$archiver) {
return $this->setError(elFinder::ERROR_ARCHIVE_TYPE);
}
$files = array();
foreach ($hashes as $hash) {
if (($file = $this->file($hash)) == false) {
return $this->error(elFinder::ERROR_FILE_NOT_FOUND, '#' + $hash);
}
if (!$file['read']) {
return $this->error(elFinder::ERROR_PERM_DENIED);
}
$path = $this->decode($hash);
if (!isset($dir)) {
$dir = $this->_dirname($path);
$stat = $this->stat($dir);
if (!$stat['write']) {
return $this->error(elFinder::ERROR_PERM_DENIED);
}
}
$files[] = $this->_basename($path);
}
$name = (count($files) == 1 ? $files[0] : 'Archive') . '.' . $archiver['ext'];
$name = $this->uniqueName($dir, $name, '');
$this->clearcache();
return ($path = $this->_archive($dir, $files, $name, $archiver)) ? $this->stat($path) : false;
}