: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$reqs = explode('/', dirname($req));
$uri = join('/', array_slice($reqs, 0, count($reqs) - 1)) . substr($this->tmpLinkPath, strlen($cur));
$https = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off');
$this->tmpLinkUrl = ($https ? 'https://' : 'http://')
. $_SERVER['SERVER_NAME'] // host
. (((!$https && $_SERVER['SERVER_PORT'] == 80) || ($https && $_SERVER['SERVER_PORT'] == 443)) ? '' : (':' . $_SERVER['SERVER_PORT'])) // port
if (!elFinder::$tmpLinkUrl) {
elFinder::$tmpLinkUrl = $this->tmpLinkUrl;
if ($this->tmpLinkPath) {
$this->tmpLinkPath = rtrim($this->tmpLinkPath, '/');
$this->tmpLinkUrl = rtrim($this->tmpLinkUrl, '/');
// to update options cache
if (isset($this->sessionCache['rootstat'])) {
unset($this->sessionCache['rootstat'][$this->getRootstatCachekey()]);
$this->updateCache($this->root, $root);
return $this->mounted = true;
* Some "unmount" stuffs - may be required by virtual fs
* @author Dmitry (dio) Levashov
* Remove session cache of this volume
public function clearSessionCache()
$this->sessionCache = array();
* Return error message from last failed action
* @author Dmitry (dio) Levashov
* Return is uploadable that given file name
* @param string $name file name
* @param bool $allowUnknown
public function isUploadableByName($name, $allowUnknown = false)
$mimeByName = $this->mimetype($name, true);
return (($allowUnknown && $mimeByName === 'unknown') || $this->allowPutMime($mimeByName));
* Return Extention/MIME Table (elFinderVolumeDriver::$mimetypes)
public function getMimeTable()
if (!elFinderVolumeDriver::$mimetypesLoaded) {
elFinderVolumeDriver::loadMimeTypes();
return elFinderVolumeDriver::$mimetypes;
* Return file extention detected by MIME type
* @param string $mime MIME type
* @param string $suffix Additional suffix
public function getExtentionByMime($mime, $suffix = '')
if (is_null($extTable)) {
$extTable = array_flip(array_unique($this->getMimeTable()));
foreach ($this->options['mimeMap'] as $pair => $_mime) {
list($ext) = explode(':', $pair);
if ($ext !== '*' && !isset($extTable[$_mime])) {
$extTable[$_mime] = $ext;
if ($mime && isset($extTable[$mime])) {
return $suffix ? ($extTable[$mime] . $suffix) : $extTable[$mime];
* Set mimetypes allowed to display to client
* @author Dmitry (dio) Levashov
public function setMimesFilter($mimes)
$this->onlyMimes = $mimes;
* Return root folder hash
* @author Dmitry (dio) Levashov
return $this->encode($this->root);
public function getRootPath()
* Return target path hash
public function getHash($path, $name = '')
$path = $this->joinPathCE($path, $name);
return $this->encode($path);
* Return decoded path of target hash
* This method do not check the stat of target
* Use method `realpath()` to do check of the stat of target
public function getPath($hash)
return $this->decode($hash);
* Return root or startPath hash
* @author Dmitry (dio) Levashov
public function defaultPath()
return $this->encode($this->startPath ? $this->startPath : $this->root);
* Return volume options required by client:
* @author Dmitry (dio) Levashov
public function options($hash)
$create = $createext = array();
if (isset($this->archivers['create']) && is_array($this->archivers['create'])) {
foreach ($this->archivers['create'] as $m => $v) {
$createext[$m] = $v['ext'];
'path' => $hash ? $this->path($hash) : '',
'tmbUrl' => (!$this->imgLib && $this->options['tmbFbSelf']) ? 'self' : $this->tmbURL,
'disabled' => $this->disabled,
'separator' => $this->separator,
'copyOverwrite' => intval($this->options['copyOverwrite']),
'uploadOverwrite' => intval($this->options['uploadOverwrite']),
'uploadMaxSize' => intval($this->uploadMaxSize),
'uploadMaxConn' => intval($this->options['uploadMaxConn']),
'firstOrder' => isset($this->uploadOrder[0]) ? $this->uploadOrder[0] : 'deny',
'allow' => $this->uploadAllow,
'deny' => $this->uploadDeny
'dispInlineRegex' => $this->options['dispInlineRegex'],
'jpgQuality' => intval($this->options['jpgQuality']),
'extract' => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(),
'createext' => $createext
'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(),
'syncChkAsTs' => intval($this->options['syncChkAsTs']),
'syncMinMs' => intval($this->options['syncMinMs']),
'i18nFolderName' => intval($this->options['i18nFolderName']),
'tmbCrop' => intval($this->options['tmbCrop']),
'tmbReqCustomData' => (bool)$this->options['tmbReqCustomData'],
'substituteImg' => (bool)$this->options['substituteImg'],
'onetimeUrl' => (bool)$this->options['onetimeUrl'],
if (!empty($this->options['trashHash'])) {
$opts['trashHash'] = $this->options['trashHash'];
// call from getRootStatExtra()
if (!empty($this->options['icon'])) {
$opts['icon'] = $this->options['icon'];
if (!empty($this->options['rootCssClass'])) {
$opts['csscls'] = $this->options['rootCssClass'];
if (isset($this->options['netkey'])) {
$opts['netkey'] = $this->options['netkey'];
* Get option value of this volume
* @param string $name target option name
* @return NULL|mixed target option value
public function getOption($name)
return isset($this->options[$name]) ? $this->options[$name] : null;
* Get plugin values of this options
* @param string $name Plugin name
* @return NULL|array Plugin values
public function getOptionsPlugin($name = '')
return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array();
return $this->options['plugin'];
* Return true if command disabled in options
* @param string $cmd command name
* @author Dmitry (dio) Levashov
public function commandDisabled($cmd)
return in_array($cmd, $this->disabled);
* Return true if mime is required mimes list
* @param string $mime mime type to check
* @param array $mimes allowed mime types list or not set to use client mimes list
* @param bool|null $empty what to return on empty list
* @author Dmitry (dio) Levashov
public function mimeAccepted($mime, $mimes = null, $empty = true)
$mimes = is_array($mimes) ? $mimes : $this->onlyMimes;
return $mime == 'directory'
|| in_array('all', $mimes)
|| in_array('All', $mimes)
|| in_array($mime, $mimes)
|| in_array(substr($mime, 0, strpos($mime, '/')), $mimes);
* Return true if voume is readable.
* @author Dmitry (dio) Levashov
public function isReadable()
$stat = $this->stat($this->root);
* Return true if copy from this volume allowed
* @author Dmitry (dio) Levashov
public function copyFromAllowed()
return !!$this->options['copyFrom'];
* Return file path related to root with convert encoging
* @param string $hash file hash
* @author Dmitry (dio) Levashov
public function path($hash)
return $this->convEncOut($this->_path($this->convEncIn($this->decode($hash))));
* Return file real path if file exists
* @param string $hash file hash
* @author Dmitry (dio) Levashov
public function realpath($hash)
$path = $this->decode($hash);
return $this->stat($path) ? $path : false;
* Return list of moved/overwrited files
* @author Dmitry (dio) Levashov
public function removed()
$unsetSubdir = isset($this->sessionCache['subdirs']) ? true : false;
foreach ($this->removed as $item) {
if ($item['mime'] === 'directory') {
$path = $this->decode($item['hash']);
unset($this->sessionCache['subdirs'][$path]);
if ($item['phash'] !== '') {
$parent = $this->decode($item['phash']);
unset($this->cache[$parent]);
if ($this->root === $parent) {
$this->sessionCache['rootstat'] = array();
unset($this->sessionCache['subdirs'][$parent]);
$this->removed = array_values($this->removed);
* Return list of added files
* Clean removed files list
* @author Dmitry (dio) Levashov
public function resetRemoved()
$this->resetResultStat();
* Clean added/removed files list
public function resetResultStat()
$this->removed = array();
* Return file/dir hash or first founded child hash with required attr == $val
* @param string $hash file hash
* @param string $attr attribute name
* @param bool $val attribute value
* @author Dmitry (dio) Levashov
public function closest($hash, $attr, $val)
return ($path = $this->closestByAttr($this->decode($hash), $attr, $val)) ? $this->encode($path) : false;
* Return file info or false on error
* @param string $hash file hash
* @internal param bool $realpath add realpath field to file info
* @author Dmitry (dio) Levashov
public function file($hash)
$file = $this->stat($this->decode($hash));
return ($file) ? $file : $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
* @param string $hash folder hash
* @param bool $resolveLink
* @internal param bool $hidden return hidden file info
* @author Dmitry (dio) Levashov
public function dir($hash, $resolveLink = false)
if (($dir = $this->file($hash)) == false) {
return $this->setError(elFinder::ERROR_DIR_NOT_FOUND);
if ($resolveLink && !empty($dir['thash'])) {
$dir = $this->file($dir['thash']);
return $dir && $dir['mime'] == 'directory' && empty($dir['hidden'])