: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$this->setError($e->getMessage());
if ($this->netMountKey) {
$this->tmbPrefix = 'onedrive' . base_convert($this->netMountKey, 16, 32);
if (empty($this->options['netkey']) && $this->tmbPrefix) {
$this->netunmount(null, null);
if ($this->options['path'] == 'root') {
$this->options['path'] = '/';
$this->root = $this->options['path'] = $this->_normpath($this->options['path']);
$this->options['root'] = ($this->options['root'] == '')? 'OneDrive.com' : $this->options['root'];
if (empty($this->options['alias'])) {
$this->options['alias'] = ($this->options['path'] === '/') ? $this->options['root'] :
$this->_od_query(basename($this->options['path']), $fetch_self = true)->name . '@OneDrive';
if (!empty($this->options['netkey'])) {
elFinder::$instance->updateNetVolumeOption($this->options['netkey'], 'alias', $this->options['alias']);
$this->options['alias'] = $this->options['root'];
$this->rootName = $this->options['alias'];
// This driver dose not support `syncChkAsTs`
$this->options['syncChkAsTs'] = false;
// 'lsPlSleep' minmum 10 sec
$this->options['lsPlSleep'] = max(10, $this->options['lsPlSleep']);
$this->queryOptions = array(
'select' => 'id,name,lastModifiedDateTime,file,folder,size,image',
if ($this->options['useApiThumbnail']) {
$this->options['tmbURL'] = 'https://';
$this->options['tmbPath'] = '';
$this->queryOptions['query']['expand'] = 'thumbnails(select=small)';
// enable command archive
$this->options['useRemoteArchive'] = true;
* Configure after successfull mount.
* @author Dmitry (dio) Levashov
protected function configure()
// fallback of $this->tmp
if (!$this->tmp && $this->tmbPathWritable) {
$this->tmp = $this->tmbPath;
/*********************************************************************/
/*********************************************************************/
* Close opened connection.
* @author Dmitry (dio) Levashov
protected function isNameExists($path)
list($pid, $name) = $this->_od_splitPath($path);
$raw = $this->_od_query($pid . '/children/' . rawurlencode($name), true);
return $raw ? $this->_od_parseRaw($raw) : false;
* @param string $path dir path
* @throws elFinderAbortException
* @author Dmitry Levashov
protected function cacheDir($path)
$this->dirsCache[$path] = array();
list(, $itemId) = $this->_od_splitPath($path);
$res = $this->_od_query($itemId, false, false, $this->queryOptions);
if ($stat = $this->_od_parseRaw($raw)) {
$itemPath = $this->_joinPath($path, $raw->id);
$stat = $this->updateCache($itemPath, $stat);
if (empty($stat['hidden'])) {
if (!$hasDir && $stat['mime'] === 'directory') {
$this->dirsCache[$path][] = $itemPath;
if (isset($this->sessionCache['subdirs'])) {
$this->sessionCache['subdirs'][$path] = $hasDir;
return $this->dirsCache[$path];
* Copy file/recursive copy dir only in current volume.
* Return new file path or false.
* @param string $src source path
* @param string $dst destination dir path
* @param string $name new file name (optionaly)
* @throws elFinderAbortException
* @author Dmitry (dio) Levashov
protected function copy($src, $dst, $name)
if ($this->options['copyJoin']) {
$test = $this->joinPathCE($dst, $name);
if ($testStat = $this->isNameExists($test)) {
if ($path = $this->_copy($src, $dst, $name)) {
$this->added[] = $this->stat($path);
$this->setError(elFinder::ERROR_COPY, $this->_path($src));
* Remove file/ recursive remove dir.
* @param string $path file path
* @param bool $force try to remove even if file locked
* @throws elFinderAbortException
* @author Dmitry (dio) Levashov
protected function remove($path, $force = false)
$stat = $this->stat($path);
$stat['realpath'] = $path;
return $this->setError(elFinder::ERROR_RM, $this->_path($path), elFinder::ERROR_FILE_NOT_FOUND);
if (!$force && !empty($stat['locked'])) {
return $this->setError(elFinder::ERROR_LOCKED, $this->_path($path));
if ($stat['mime'] == 'directory') {
if (!$this->_rmdir($path)) {
return $this->setError(elFinder::ERROR_RM, $this->_path($path));
if (!$this->_unlink($path)) {
return $this->setError(elFinder::ERROR_RM, $this->_path($path));
$this->removed[] = $stat;
* Create thumnbnail and return it's URL on success.
* @param string $path file path
* @throws ImagickException
* @throws elFinderAbortException
* @author Dmitry (dio) Levashov
protected function createTmb($path, $stat)
if ($this->options['useApiThumbnail']) {
if (func_num_args() > 2) {
list(, , $count) = func_get_args();
if (isset($stat['tmb']) && $stat['tmb'] != '1') {
elFinder::extendTimeLimit();
$stat = $this->stat($path);
return $this->createTmb($path, $stat, ++$count);
if (!$stat || !$this->canCreateTmb($path, $stat)) {
$name = $this->tmbname($stat);
$tmb = $this->tmbPath . DIRECTORY_SEPARATOR . $name;
// copy image into tmbPath so some drivers does not store files on local fs
if (!$data = $this->_od_getThumbnail($path)) {
if (!file_put_contents($tmb, $data)) {
$tmbSize = $this->tmbSize;
if (($s = getimagesize($tmb)) == false) {
/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
if ($this->options['tmbCrop']) {
/* Resize and crop if image bigger than thumbnail */
if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
if (($s = getimagesize($tmb)) != false) {
$x = $s[0] > $tmbSize ? intval(($s[0] - $tmbSize) / 2) : 0;
$y = $s[1] > $tmbSize ? intval(($s[1] - $tmbSize) / 2) : 0;
$result = $this->imgCrop($tmb, $tmbSize, $tmbSize, $x, $y, 'png');
$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png');
$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
* Return thumbnail file name for required file.
* @param array $stat file stat
* @author Dmitry (dio) Levashov
protected function tmbname($stat)
return $this->tmbPrefix . $stat['rev'] . $stat['ts'] . '.png';
* @param string $hash file hash
* @param array $options options
public function getContentUrl($hash, $options = array())
if (!empty($options['onetime']) && $this->options['onetimeUrl']) {
return parent::getContentUrl($hash, $options);
if (!empty($options['temporary'])) {
// try make temporary file
$url = parent::getContentUrl($hash, $options);
if (($file = $this->file($hash)) == false || !$file['url'] || $file['url'] == 1) {
$path = $this->decode($hash);
list(, $itemId) = $this->_od_splitPath($path);
$url = self::API_URL . $itemId . '/createLink';
$curl = $this->_od_prepareCurl($url);
curl_setopt_array($curl, array(
CURLOPT_POSTFIELDS => json_encode($data),
$result = elFinder::curlExec($curl);
$result = json_decode($result);
if (isset($result->link)) {
// list(, $res) = explode('?', $result->link->webUrl);
// $res = 'https://onedrive.live.com/download.aspx?' . $res;
$res = $result->link->webUrl;
/*********************** paths/urls *************************/
* Return parent directory path.
* @param string $path file path
* @author Dmitry (dio) Levashov
protected function _dirname($path)
list(, , $dirname) = $this->_od_splitPath($path);
* @param string $path file path
* @author Dmitry (dio) Levashov
protected function _basename($path)
list(, $basename) = $this->_od_splitPath($path);
* Join dir name and file name and retur full path.
* @author Dmitry (dio) Levashov
protected function _joinPath($dir, $name)
return $this->_normpath($dir . '/' . $name);
* Return normalized path, this works the same as os.path.normpath() in Python.
* @param string $path path
protected function _normpath($path)
if (DIRECTORY_SEPARATOR !== '/') {
$path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
$path = '/' . ltrim($path, '/');
* Return file path related to root dir.
* @param string $path file path
* @author Dmitry (dio) Levashov
protected function _relpath($path)
* Convert path related to root dir into real path.
* @param string $path file path
* @author Dmitry (dio) Levashov
protected function _abspath($path)
* Return fake path started from root dir.
* @param string $path file path
* @author Dmitry (dio) Levashov
protected function _path($path)
return $this->rootName . $this->_normpath(substr($path, strlen($this->root)));
* Return true if $path is children of $parent.
* @param string $path path to check
* @param string $parent parent path
* @author Dmitry (dio) Levashov
protected function _inpath($path, $parent)
return $path == $parent || strpos($path, $parent . '/') === 0;
/***************** file stat ********************/
* Return stat for given path.
* Stat contains following fields:
* - (int) size file size in b. required
* - (int) ts file modification time in unix time. required
* - (string) mime mimetype. required for folders, others - optionally