|
@@ -65,78 +65,6 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
/* INIT AND CONFIGURE */
|
|
/* INIT AND CONFIGURE */
|
|
|
/*********************************************************************/
|
|
/*********************************************************************/
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Long pooling sync checker
|
|
|
|
|
- * This function require server command `inotifywait`
|
|
|
|
|
- * If `inotifywait` need full path, Please add `define('ELFINER_INOTIFYWAIT_PATH', '/PATH_TO/inotifywait');` into connector.php
|
|
|
|
|
- *
|
|
|
|
|
- * @param string $path
|
|
|
|
|
- * @param int $standby
|
|
|
|
|
- * @param number $compare
|
|
|
|
|
- * @return number|bool
|
|
|
|
|
- */
|
|
|
|
|
- public function localFileSystemInotify($path, $standby, $compare) {
|
|
|
|
|
- if (isset($this->sessionCache['localFileSystemInotify_disable'])) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- $path = realpath($path);
|
|
|
|
|
- $mtime = filemtime($path);
|
|
|
|
|
- if (! $mtime) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- if ($mtime != $compare) {
|
|
|
|
|
- return $mtime;
|
|
|
|
|
- }
|
|
|
|
|
- $inotifywait = defined('ELFINER_INOTIFYWAIT_PATH')? ELFINER_INOTIFYWAIT_PATH : 'inotifywait';
|
|
|
|
|
- $standby = max(1, intval($standby));
|
|
|
|
|
- $cmd = $inotifywait.' '.escapeshellarg($path).' -t '.$standby.' -e moved_to,moved_from,move,close_write,delete,delete_self';
|
|
|
|
|
- $this->procExec($cmd , $o, $r);
|
|
|
|
|
- if ($r === 0) {
|
|
|
|
|
- // changed
|
|
|
|
|
- clearstatcache();
|
|
|
|
|
- if (file_exists($path)) {
|
|
|
|
|
- $mtime = filemtime($path); // error on busy?
|
|
|
|
|
- return $mtime? $mtime : time();
|
|
|
|
|
- } else {
|
|
|
|
|
- // target was removed
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
- } else if ($r === 2) {
|
|
|
|
|
- // not changed (timeout)
|
|
|
|
|
- return $compare;
|
|
|
|
|
- }
|
|
|
|
|
- // error
|
|
|
|
|
- // cache to $_SESSION
|
|
|
|
|
- $this->sessionCache['localFileSystemInotify_disable'] = true;
|
|
|
|
|
- $this->session->set($this->id, $this->sessionCache, true);
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /******************** Original local functions ************************
|
|
|
|
|
- * @param $file
|
|
|
|
|
- * @param $key
|
|
|
|
|
- * @param $iterator
|
|
|
|
|
- * @return bool
|
|
|
|
|
- */
|
|
|
|
|
-
|
|
|
|
|
- public function localFileSystemSearchIteratorFilter($file, $key, $iterator) {
|
|
|
|
|
- $name = $file->getFilename();
|
|
|
|
|
- if ($this->doSearchCurrentQuery['excludes']) {
|
|
|
|
|
- foreach($this->doSearchCurrentQuery['excludes'] as $exclude) {
|
|
|
|
|
- if ($this->stripos($name, $exclude) !== false) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if ($iterator->hasChildren()) {
|
|
|
|
|
- if ($this->options['searchExDirReg'] && preg_match($this->options['searchExDirReg'], $key)) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- return (bool)$this->attr($key, 'read', null, true);
|
|
|
|
|
- }
|
|
|
|
|
- return ($this->stripos($name, $this->doSearchCurrentQuery['q']) === false)? false : true;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Prepare driver before mount volume.
|
|
* Prepare driver before mount volume.
|
|
|
* Return true if volume is ready.
|
|
* Return true if volume is ready.
|
|
@@ -169,23 +97,17 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
if (!empty($this->options['startPath'])) {
|
|
if (!empty($this->options['startPath'])) {
|
|
|
$this->options['startPath'] = $this->getFullPath($this->options['startPath'], $this->root);
|
|
$this->options['startPath'] = $this->getFullPath($this->options['startPath'], $this->root);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (is_null($this->options['syncChkAsTs'])) {
|
|
if (is_null($this->options['syncChkAsTs'])) {
|
|
|
$this->options['syncChkAsTs'] = true;
|
|
$this->options['syncChkAsTs'] = true;
|
|
|
}
|
|
}
|
|
|
if (is_null($this->options['syncCheckFunc'])) {
|
|
if (is_null($this->options['syncCheckFunc'])) {
|
|
|
$this->options['syncCheckFunc'] = array($this, 'localFileSystemInotify');
|
|
$this->options['syncCheckFunc'] = array($this, 'localFileSystemInotify');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /*********************************************************************/
|
|
|
|
|
- /* FS API */
|
|
|
|
|
- /*********************************************************************/
|
|
|
|
|
-
|
|
|
|
|
- /*********************** paths/urls *************************/
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Configure after successfull mount.
|
|
* Configure after successfull mount.
|
|
|
*
|
|
*
|
|
@@ -194,7 +116,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
**/
|
|
**/
|
|
|
protected function configure() {
|
|
protected function configure() {
|
|
|
$root = $this->stat($this->root);
|
|
$root = $this->stat($this->root);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// chek thumbnails path
|
|
// chek thumbnails path
|
|
|
if ($this->options['tmbPath']) {
|
|
if ($this->options['tmbPath']) {
|
|
|
$this->options['tmbPath'] = strpos($this->options['tmbPath'], DIRECTORY_SEPARATOR) === false
|
|
$this->options['tmbPath'] = strpos($this->options['tmbPath'], DIRECTORY_SEPARATOR) === false
|
|
@@ -205,7 +127,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
parent::configure();
|
|
parent::configure();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// set $this->tmp by options['tmpPath']
|
|
// set $this->tmp by options['tmpPath']
|
|
|
$this->tmp = '';
|
|
$this->tmp = '';
|
|
|
if (!empty($this->options['tmpPath'])) {
|
|
if (!empty($this->options['tmpPath'])) {
|
|
@@ -216,7 +138,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
if (!$this->tmp && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
|
|
if (!$this->tmp && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
|
|
|
$this->tmp = $tmp;
|
|
$this->tmp = $tmp;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// if no thumbnails url - try detect it
|
|
// if no thumbnails url - try detect it
|
|
|
if ($root['read'] && !$this->tmbURL && $this->URL) {
|
|
if ($root['read'] && !$this->tmbURL && $this->URL) {
|
|
|
if (strpos($this->tmbPath, $this->root) === 0) {
|
|
if (strpos($this->tmbPath, $this->root) === 0) {
|
|
@@ -242,7 +164,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!$this->quarantine) {
|
|
if (!$this->quarantine) {
|
|
|
if (!$this->tmp) {
|
|
if (!$this->tmp) {
|
|
|
$this->archivers['extract'] = array();
|
|
$this->archivers['extract'] = array();
|
|
@@ -251,7 +173,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
$this->quarantine = $this->tmp;
|
|
$this->quarantine = $this->tmp;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($this->options['quarantine']) {
|
|
if ($this->options['quarantine']) {
|
|
|
$this->attributes[] = array(
|
|
$this->attributes[] = array(
|
|
|
'pattern' => '~^'.preg_quote(DIRECTORY_SEPARATOR.$this->options['quarantine']).'$~',
|
|
'pattern' => '~^'.preg_quote(DIRECTORY_SEPARATOR.$this->options['quarantine']).'$~',
|
|
@@ -261,30 +183,85 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
'hidden' => true
|
|
'hidden' => true
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (! empty($this->options['keepTimestamp'])) {
|
|
if (! empty($this->options['keepTimestamp'])) {
|
|
|
$this->options['keepTimestamp'] = array_flip($this->options['keepTimestamp']);
|
|
$this->options['keepTimestamp'] = array_flip($this->options['keepTimestamp']);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Long pooling sync checker
|
|
|
|
|
+ * This function require server command `inotifywait`
|
|
|
|
|
+ * If `inotifywait` need full path, Please add `define('ELFINER_INOTIFYWAIT_PATH', '/PATH_TO/inotifywait');` into connector.php
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $path
|
|
|
|
|
+ * @param int $standby
|
|
|
|
|
+ * @param number $compare
|
|
|
|
|
+ * @return number|bool
|
|
|
|
|
+ */
|
|
|
|
|
+ public function localFileSystemInotify($path, $standby, $compare) {
|
|
|
|
|
+ if (isset($this->sessionCache['localFileSystemInotify_disable'])) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ $path = realpath($path);
|
|
|
|
|
+ $mtime = filemtime($path);
|
|
|
|
|
+ if (! $mtime) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($mtime != $compare) {
|
|
|
|
|
+ return $mtime;
|
|
|
|
|
+ }
|
|
|
|
|
+ $inotifywait = defined('ELFINER_INOTIFYWAIT_PATH')? ELFINER_INOTIFYWAIT_PATH : 'inotifywait';
|
|
|
|
|
+ $standby = max(1, intval($standby));
|
|
|
|
|
+ $cmd = $inotifywait.' '.escapeshellarg($path).' -t '.$standby.' -e moved_to,moved_from,move,close_write,delete,delete_self';
|
|
|
|
|
+ $this->procExec($cmd , $o, $r);
|
|
|
|
|
+ if ($r === 0) {
|
|
|
|
|
+ // changed
|
|
|
|
|
+ clearstatcache();
|
|
|
|
|
+ if (file_exists($path)) {
|
|
|
|
|
+ $mtime = filemtime($path); // error on busy?
|
|
|
|
|
+ return $mtime? $mtime : time();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // target was removed
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if ($r === 2) {
|
|
|
|
|
+ // not changed (timeout)
|
|
|
|
|
+ return $compare;
|
|
|
|
|
+ }
|
|
|
|
|
+ // error
|
|
|
|
|
+ // cache to $_SESSION
|
|
|
|
|
+ $this->sessionCache['localFileSystemInotify_disable'] = true;
|
|
|
|
|
+ $this->session->set($this->id, $this->sessionCache, true);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*********************************************************************/
|
|
|
|
|
+ /* FS API */
|
|
|
|
|
+ /*********************************************************************/
|
|
|
|
|
|
|
|
|
|
+ /*********************** paths/urls *************************/
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
- * Convert path related to root dir into real path
|
|
|
|
|
|
|
+ * Return parent directory path
|
|
|
*
|
|
*
|
|
|
* @param string $path file path
|
|
* @param string $path file path
|
|
|
* @return string
|
|
* @return string
|
|
|
* @author Dmitry (dio) Levashov
|
|
* @author Dmitry (dio) Levashov
|
|
|
**/
|
|
**/
|
|
|
- protected function _abspath($path) {
|
|
|
|
|
- if ($path === DIRECTORY_SEPARATOR) {
|
|
|
|
|
- return $this->root;
|
|
|
|
|
- } else {
|
|
|
|
|
- if ($path[0] === DIRECTORY_SEPARATOR) {
|
|
|
|
|
- // for link
|
|
|
|
|
- return $path;
|
|
|
|
|
- } else {
|
|
|
|
|
- return $this->_joinPath($this->root, $path);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ protected function _dirname($path) {
|
|
|
|
|
+ return dirname($path);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Return file name
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $path file path
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ * @author Dmitry (dio) Levashov
|
|
|
|
|
+ **/
|
|
|
|
|
+ protected function _basename($path) {
|
|
|
|
|
+ return basename($path);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -364,27 +341,78 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Return parent directory path
|
|
|
|
|
|
|
+ * Return file path related to root dir
|
|
|
*
|
|
*
|
|
|
* @param string $path file path
|
|
* @param string $path file path
|
|
|
* @return string
|
|
* @return string
|
|
|
* @author Dmitry (dio) Levashov
|
|
* @author Dmitry (dio) Levashov
|
|
|
**/
|
|
**/
|
|
|
- protected function _dirname($path) {
|
|
|
|
|
- return dirname($path);
|
|
|
|
|
|
|
+ protected function _relpath($path) {
|
|
|
|
|
+ if ($path === $this->root) {
|
|
|
|
|
+ return '';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (strpos($path, $this->root) === 0) {
|
|
|
|
|
+ return ltrim(substr($path, strlen($this->root)), DIRECTORY_SEPARATOR);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // for link
|
|
|
|
|
+ return $path;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Return file name
|
|
|
|
|
|
|
+ * Convert path related to root dir into real path
|
|
|
*
|
|
*
|
|
|
* @param string $path file path
|
|
* @param string $path file path
|
|
|
* @return string
|
|
* @return string
|
|
|
* @author Dmitry (dio) Levashov
|
|
* @author Dmitry (dio) Levashov
|
|
|
**/
|
|
**/
|
|
|
- protected function _basename($path) {
|
|
|
|
|
- return basename($path);
|
|
|
|
|
|
|
+ protected function _abspath($path) {
|
|
|
|
|
+ if ($path === DIRECTORY_SEPARATOR) {
|
|
|
|
|
+ return $this->root;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if ($path[0] === DIRECTORY_SEPARATOR) {
|
|
|
|
|
+ // for link
|
|
|
|
|
+ return $path;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return $this->_joinPath($this->root, $path);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Return fake path started from root dir
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $path file path
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ * @author Dmitry (dio) Levashov
|
|
|
|
|
+ **/
|
|
|
|
|
+ protected function _path($path) {
|
|
|
|
|
+ return $this->rootName.($path == $this->root ? '' : $this->separator.$this->_relpath($path));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Return true if $path is children of $parent
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $path path to check
|
|
|
|
|
+ * @param string $parent parent path
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ * @author Dmitry (dio) Levashov
|
|
|
|
|
+ **/
|
|
|
|
|
+ protected function _inpath($path, $parent) {
|
|
|
|
|
+ $cwd = getcwd();
|
|
|
|
|
+ $real_path = $this->getFullPath($path, $cwd);
|
|
|
|
|
+ $real_parent = $this->getFullPath($parent, $cwd);
|
|
|
|
|
+ if ($real_path && $real_parent) {
|
|
|
|
|
+ return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /***************** file stat ********************/
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Return stat for given path.
|
|
* Return stat for given path.
|
|
|
* Stat contains following fields:
|
|
* Stat contains following fields:
|
|
@@ -400,17 +428,17 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
*
|
|
*
|
|
|
* If file does not exists - returns empty array or false.
|
|
* If file does not exists - returns empty array or false.
|
|
|
*
|
|
*
|
|
|
- * @param string $path file path
|
|
|
|
|
|
|
+ * @param string $path file path
|
|
|
* @return array|false
|
|
* @return array|false
|
|
|
* @author Dmitry (dio) Levashov
|
|
* @author Dmitry (dio) Levashov
|
|
|
**/
|
|
**/
|
|
|
protected function _stat($path) {
|
|
protected function _stat($path) {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
static $statOwner;
|
|
static $statOwner;
|
|
|
if (is_null($statOwner)) {
|
|
if (is_null($statOwner)) {
|
|
|
$statOwner = (!empty($this->options['statOwner']));
|
|
$statOwner = (!empty($this->options['statOwner']));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$stat = array();
|
|
$stat = array();
|
|
|
|
|
|
|
|
if (!file_exists($path) && !is_link($path)) {
|
|
if (!file_exists($path) && !is_link($path)) {
|
|
@@ -454,14 +482,14 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
$stat['perm'] = substr((string)decoct($fstat['mode']), -4);
|
|
$stat['perm'] = substr((string)decoct($fstat['mode']), -4);
|
|
|
$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
|
|
$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (($dir = is_dir($path)) && $this->options['detectDirIcon']) {
|
|
if (($dir = is_dir($path)) && $this->options['detectDirIcon']) {
|
|
|
$favicon = $path . DIRECTORY_SEPARATOR . $this->options['detectDirIcon'];
|
|
$favicon = $path . DIRECTORY_SEPARATOR . $this->options['detectDirIcon'];
|
|
|
if ($this->URL && file_exists($favicon)) {
|
|
if ($this->URL && file_exists($favicon)) {
|
|
|
$stat['icon'] = $this->URL . str_replace(DIRECTORY_SEPARATOR, '/', substr($favicon, strlen($this->root) + 1));
|
|
$stat['icon'] = $this->URL . str_replace(DIRECTORY_SEPARATOR, '/', substr($favicon, strlen($this->root) + 1));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!isset($stat['mime'])) {
|
|
if (!isset($stat['mime'])) {
|
|
|
$stat['mime'] = $dir ? 'directory' : $this->mimetype($path);
|
|
$stat['mime'] = $dir ? 'directory' : $this->mimetype($path);
|
|
|
}
|
|
}
|
|
@@ -472,55 +500,10 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
if (is_null($stat['read'])) {
|
|
if (is_null($stat['read'])) {
|
|
|
$stat['size'] = $dir ? 0 : $size;
|
|
$stat['size'] = $dir ? 0 : $size;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return $stat;
|
|
return $stat;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Return true if $path is children of $parent
|
|
|
|
|
- *
|
|
|
|
|
- * @param string $path path to check
|
|
|
|
|
- * @param string $parent parent path
|
|
|
|
|
- * @return bool
|
|
|
|
|
- * @author Dmitry (dio) Levashov
|
|
|
|
|
- **/
|
|
|
|
|
- protected function _inpath($path, $parent) {
|
|
|
|
|
- $cwd = getcwd();
|
|
|
|
|
- $real_path = $this->getFullPath($path, $cwd);
|
|
|
|
|
- $real_parent = $this->getFullPath($parent, $cwd);
|
|
|
|
|
- if ($real_path && $real_parent) {
|
|
|
|
|
- return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0;
|
|
|
|
|
- }
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- /***************** file stat ********************/
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Return symlink target file
|
|
|
|
|
- *
|
|
|
|
|
- * @param string $path link path
|
|
|
|
|
- * @return string
|
|
|
|
|
- * @author Dmitry (dio) Levashov
|
|
|
|
|
- **/
|
|
|
|
|
- protected function readlink($path) {
|
|
|
|
|
- if (!($target = readlink($path))) {
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (strpos($target, $this->systemRoot) !== 0) {
|
|
|
|
|
- $target = $this->_joinPath(dirname($path), $target);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!file_exists($target)) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return $target;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Get stat `owner`, `group` and `isowner` by `uid` and `gid`
|
|
* Get stat `owner`, `group` and `isowner` by `uid` and `gid`
|
|
|
* Sub-fuction of _stat() and _scandir()
|
|
* Sub-fuction of _stat() and _scandir()
|
|
@@ -571,38 +554,6 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
return $stat;
|
|
return $stat;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Return fake path started from root dir
|
|
|
|
|
- *
|
|
|
|
|
- * @param string $path file path
|
|
|
|
|
- * @return string
|
|
|
|
|
- * @author Dmitry (dio) Levashov
|
|
|
|
|
- **/
|
|
|
|
|
- protected function _path($path) {
|
|
|
|
|
- return $this->rootName.($path == $this->root ? '' : $this->separator.$this->_relpath($path));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Return file path related to root dir
|
|
|
|
|
- *
|
|
|
|
|
- * @param string $path file path
|
|
|
|
|
- * @return string
|
|
|
|
|
- * @author Dmitry (dio) Levashov
|
|
|
|
|
- **/
|
|
|
|
|
- protected function _relpath($path) {
|
|
|
|
|
- if ($path === $this->root) {
|
|
|
|
|
- return '';
|
|
|
|
|
- } else {
|
|
|
|
|
- if (strpos($path, $this->root) === 0) {
|
|
|
|
|
- return ltrim(substr($path, strlen($this->root)), DIRECTORY_SEPARATOR);
|
|
|
|
|
- } else {
|
|
|
|
|
- // for link
|
|
|
|
|
- return $path;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- /******************** file/dir content *********************/
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Return true if path is dir and has at least one childs directory
|
|
* Return true if path is dir and has at least one childs directory
|
|
|
*
|
|
*
|
|
@@ -644,7 +595,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
}
|
|
}
|
|
|
return $dirs;
|
|
return $dirs;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Return object width and height
|
|
* Return object width and height
|
|
|
* Usualy used for images, but can be realize for video etc...
|
|
* Usualy used for images, but can be realize for video etc...
|
|
@@ -656,11 +607,35 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
**/
|
|
**/
|
|
|
protected function _dimensions($path, $mime) {
|
|
protected function _dimensions($path, $mime) {
|
|
|
clearstatcache();
|
|
clearstatcache();
|
|
|
- return strpos($mime, 'image') === 0 && is_readable($path) && ($s = getimagesize($path)) !== false
|
|
|
|
|
- ? $s[0].'x'.$s[1]
|
|
|
|
|
|
|
+ return strpos($mime, 'image') === 0 && is_readable($path) && ($s = getimagesize($path)) !== false
|
|
|
|
|
+ ? $s[0].'x'.$s[1]
|
|
|
: false;
|
|
: false;
|
|
|
}
|
|
}
|
|
|
|
|
+ /******************** file/dir content *********************/
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Return symlink target file
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $path link path
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ * @author Dmitry (dio) Levashov
|
|
|
|
|
+ **/
|
|
|
|
|
+ protected function readlink($path) {
|
|
|
|
|
+ if (!($target = readlink($path))) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ if (strpos($target, $this->systemRoot) !== 0) {
|
|
|
|
|
+ $target = $this->_joinPath(dirname($path), $target);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!file_exists($target)) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $target;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Return files list in directory.
|
|
* Return files list in directory.
|
|
|
*
|
|
*
|
|
@@ -679,16 +654,16 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
try {
|
|
try {
|
|
|
$dirItr = new DirectoryIterator($path);
|
|
$dirItr = new DirectoryIterator($path);
|
|
|
} catch (UnexpectedValueException $e) {}
|
|
} catch (UnexpectedValueException $e) {}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
foreach ($dirItr as $file) {
|
|
foreach ($dirItr as $file) {
|
|
|
try {
|
|
try {
|
|
|
if ($file->isDot()) { continue; }
|
|
if ($file->isDot()) { continue; }
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$files[] = $fpath = $file->getPathname();
|
|
$files[] = $fpath = $file->getPathname();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$br = false;
|
|
$br = false;
|
|
|
$stat = array();
|
|
$stat = array();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$gid = $uid = 0;
|
|
$gid = $uid = 0;
|
|
|
$stat['isowner'] = false;
|
|
$stat['isowner'] = false;
|
|
|
$linkreadable = false;
|
|
$linkreadable = false;
|
|
@@ -735,31 +710,31 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
$stat['perm'] = substr((string)decoct($file->getPerms()), -4);
|
|
$stat['perm'] = substr((string)decoct($file->getPerms()), -4);
|
|
|
$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
|
|
$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
//logical rights first
|
|
//logical rights first
|
|
|
$stat['read'] = ($linkreadable || $file->isReadable())? null : false;
|
|
$stat['read'] = ($linkreadable || $file->isReadable())? null : false;
|
|
|
$stat['write'] = $file->isWritable()? null : false;
|
|
$stat['write'] = $file->isWritable()? null : false;
|
|
|
$stat['locked'] = $dirWritable? null : true;
|
|
$stat['locked'] = $dirWritable? null : true;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (is_null($stat['read'])) {
|
|
if (is_null($stat['read'])) {
|
|
|
$stat['size'] = $dir ? 0 : $size;
|
|
$stat['size'] = $dir ? 0 : $size;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$cache[] = array($fpath, $stat);
|
|
$cache[] = array($fpath, $stat);
|
|
|
} catch (RuntimeException $e) {
|
|
} catch (RuntimeException $e) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($cache) {
|
|
if ($cache) {
|
|
|
$cache = $this->convEncOut($cache, false);
|
|
$cache = $this->convEncOut($cache, false);
|
|
|
foreach($cache as $d) {
|
|
foreach($cache as $d) {
|
|
|
$this->updateCache($d[0], $d[1]);
|
|
$this->updateCache($d[0], $d[1]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return $files;
|
|
return $files;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -775,9 +750,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
protected function _fopen($path, $mode='rb') {
|
|
protected function _fopen($path, $mode='rb') {
|
|
|
return fopen($path, $mode);
|
|
return fopen($path, $mode);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /******************** file/dir manipulations *************************/
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Close opened file
|
|
* Close opened file
|
|
|
*
|
|
*
|
|
@@ -790,6 +763,8 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
return (is_resource($fp) && fclose($fp));
|
|
return (is_resource($fp) && fclose($fp));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /******************** file/dir manipulations *************************/
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Create dir and return created dir path or false on failed
|
|
* Create dir and return created dir path or false on failed
|
|
|
*
|
|
*
|
|
@@ -819,7 +794,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
**/
|
|
**/
|
|
|
protected function _mkfile($path, $name) {
|
|
protected function _mkfile($path, $name) {
|
|
|
$path = $this->_joinPath($path, $name);
|
|
$path = $this->_joinPath($path, $name);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (($fp = fopen($path, 'w'))) {
|
|
if (($fp = fopen($path, 'w'))) {
|
|
|
fclose($fp);
|
|
fclose($fp);
|
|
|
chmod($path, $this->options['fileMode']);
|
|
chmod($path, $this->options['fileMode']);
|
|
@@ -840,7 +815,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
protected function _symlink($source, $targetDir, $name) {
|
|
protected function _symlink($source, $targetDir, $name) {
|
|
|
return symlink($source, $this->_joinPath($targetDir, $name));
|
|
return symlink($source, $this->_joinPath($targetDir, $name));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Copy file into another file
|
|
* Copy file into another file
|
|
|
*
|
|
*
|
|
@@ -858,7 +833,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
}
|
|
}
|
|
|
return $ret;
|
|
return $ret;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Move file into another parent dir.
|
|
* Move file into another parent dir.
|
|
|
* Return new file path or false.
|
|
* Return new file path or false.
|
|
@@ -878,7 +853,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
}
|
|
}
|
|
|
return $ret;
|
|
return $ret;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Remove file
|
|
* Remove file
|
|
|
*
|
|
*
|
|
@@ -889,7 +864,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
protected function _unlink($path) {
|
|
protected function _unlink($path) {
|
|
|
return is_file($path) && unlink($path);
|
|
return is_file($path) && unlink($path);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Remove dir
|
|
* Remove dir
|
|
|
*
|
|
*
|
|
@@ -934,7 +909,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
chmod($path, $this->options['fileMode']);
|
|
chmod($path, $this->options['fileMode']);
|
|
|
return $path;
|
|
return $path;
|
|
|
}
|
|
}
|
|
@@ -949,7 +924,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
protected function _getContents($path) {
|
|
protected function _getContents($path) {
|
|
|
return file_get_contents($path);
|
|
return file_get_contents($path);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Write a string to a file
|
|
* Write a string to a file
|
|
|
*
|
|
*
|
|
@@ -994,50 +969,50 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
protected function _findSymlinks($path) {
|
|
protected function _findSymlinks($path) {
|
|
|
return self::localFindSymlinks($path);
|
|
return self::localFindSymlinks($path);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Extract files from archive
|
|
* Extract files from archive
|
|
|
*
|
|
*
|
|
|
* @param string $path archive path
|
|
* @param string $path archive path
|
|
|
* @param array $arc archiver command and arguments (same as in $this->archivers)
|
|
* @param array $arc archiver command and arguments (same as in $this->archivers)
|
|
|
* @return true
|
|
* @return true
|
|
|
- * @author Dmitry (dio) Levashov,
|
|
|
|
|
|
|
+ * @author Dmitry (dio) Levashov,
|
|
|
* @author Alexey Sukhotin
|
|
* @author Alexey Sukhotin
|
|
|
**/
|
|
**/
|
|
|
protected function _extract($path, $arc) {
|
|
protected function _extract($path, $arc) {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($this->quarantine) {
|
|
if ($this->quarantine) {
|
|
|
|
|
|
|
|
$dir = $this->quarantine.DIRECTORY_SEPARATOR.md5(basename($path).mt_rand());
|
|
$dir = $this->quarantine.DIRECTORY_SEPARATOR.md5(basename($path).mt_rand());
|
|
|
$archive = (isset($arc['toSpec']) || $arc['cmd'] === 'phpfunction')? '' : $dir.DIRECTORY_SEPARATOR.basename($path);
|
|
$archive = (isset($arc['toSpec']) || $arc['cmd'] === 'phpfunction')? '' : $dir.DIRECTORY_SEPARATOR.basename($path);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!mkdir($dir)) {
|
|
if (!mkdir($dir)) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// insurance unexpected shutdown
|
|
// insurance unexpected shutdown
|
|
|
register_shutdown_function(array($this, 'rmdirRecursive'), realpath($dir));
|
|
register_shutdown_function(array($this, 'rmdirRecursive'), realpath($dir));
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
chmod($dir, 0777);
|
|
chmod($dir, 0777);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// copy in quarantine
|
|
// copy in quarantine
|
|
|
if (!is_readable($path) || ($archive && !copy($path, $archive))) {
|
|
if (!is_readable($path) || ($archive && !copy($path, $archive))) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// extract in quarantine
|
|
// extract in quarantine
|
|
|
$this->unpackArchive($path, $arc, $archive? true : $dir);
|
|
$this->unpackArchive($path, $arc, $archive? true : $dir);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// get files list
|
|
// get files list
|
|
|
$ls = self::localScandir($dir);
|
|
$ls = self::localScandir($dir);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// no files - extract error ?
|
|
// no files - extract error ?
|
|
|
if (empty($ls)) {
|
|
if (empty($ls)) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$this->archiveSize = 0;
|
|
$this->archiveSize = 0;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// find symlinks and check extracted items
|
|
// find symlinks and check extracted items
|
|
|
$checkRes = $this->checkExtractItems($dir);
|
|
$checkRes = $this->checkExtractItems($dir);
|
|
|
if ($checkRes['symlinks']) {
|
|
if ($checkRes['symlinks']) {
|
|
@@ -1050,15 +1025,15 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
$this->addError(elFinder::ERROR_SAVE, $name);
|
|
$this->addError(elFinder::ERROR_SAVE, $name);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// check max files size
|
|
// check max files size
|
|
|
if ($this->options['maxArcFilesSize'] > 0 && $this->options['maxArcFilesSize'] < $this->archiveSize) {
|
|
if ($this->options['maxArcFilesSize'] > 0 && $this->options['maxArcFilesSize'] < $this->archiveSize) {
|
|
|
$this->delTree($dir);
|
|
$this->delTree($dir);
|
|
|
return $this->setError(elFinder::ERROR_ARC_MAXSIZE);
|
|
return $this->setError(elFinder::ERROR_ARC_MAXSIZE);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$extractTo = $this->extractToNewdir; // 'auto', ture or false
|
|
$extractTo = $this->extractToNewdir; // 'auto', ture or false
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// archive contains one item - extract in archive dir
|
|
// archive contains one item - extract in archive dir
|
|
|
$name = '';
|
|
$name = '';
|
|
|
$src = $dir.DIRECTORY_SEPARATOR.$ls[0];
|
|
$src = $dir.DIRECTORY_SEPARATOR.$ls[0];
|
|
@@ -1077,7 +1052,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
$name = $this->uniqueName(dirname($path), $name, '-', false);
|
|
$name = $this->uniqueName(dirname($path), $name, '-', false);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($name !== '') {
|
|
if ($name !== '') {
|
|
|
$result = dirname($path).DIRECTORY_SEPARATOR.$name;
|
|
$result = dirname($path).DIRECTORY_SEPARATOR.$name;
|
|
|
|
|
|
|
@@ -1099,27 +1074,14 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
is_dir($dir) && $this->delTree($dir);
|
|
is_dir($dir) && $this->delTree($dir);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return (is_array($result) || file_exists($result)) ? $result : false;
|
|
return (is_array($result) || file_exists($result)) ? $result : false;
|
|
|
}
|
|
}
|
|
|
//TODO: Add return statement here
|
|
//TODO: Add return statement here
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /******************** Over write functions *************************/
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Delete dirctory trees
|
|
|
|
|
- *
|
|
|
|
|
- * @param string $localpath path need convert encoding to server encoding
|
|
|
|
|
- * @return boolean
|
|
|
|
|
- * @author Naoki Sawada
|
|
|
|
|
- */
|
|
|
|
|
- protected function delTree($localpath) {
|
|
|
|
|
- return $this->rmdirRecursive($localpath);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Create archive and return its path
|
|
* Create archive and return its path
|
|
|
*
|
|
*
|
|
@@ -1128,15 +1090,15 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
* @param string $name archive name
|
|
* @param string $name archive name
|
|
|
* @param array $arc archiver options
|
|
* @param array $arc archiver options
|
|
|
* @return string|bool
|
|
* @return string|bool
|
|
|
- * @author Dmitry (dio) Levashov,
|
|
|
|
|
|
|
+ * @author Dmitry (dio) Levashov,
|
|
|
* @author Alexey Sukhotin
|
|
* @author Alexey Sukhotin
|
|
|
**/
|
|
**/
|
|
|
protected function _archive($dir, $files, $name, $arc) {
|
|
protected function _archive($dir, $files, $name, $arc) {
|
|
|
return $this->makeArchive($dir, $files, $name, $arc);
|
|
return $this->makeArchive($dir, $files, $name, $arc);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /******************** Over write (Optimized) functions *************************/
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /******************** Over write functions *************************/
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* File path of local server side work file path
|
|
* File path of local server side work file path
|
|
|
*
|
|
*
|
|
@@ -1148,6 +1110,19 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
return $path;
|
|
return $path;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Delete dirctory trees
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $localpath path need convert encoding to server encoding
|
|
|
|
|
+ * @return boolean
|
|
|
|
|
+ * @author Naoki Sawada
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function delTree($localpath) {
|
|
|
|
|
+ return $this->rmdirRecursive($localpath);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /******************** Over write (Optimized) functions *************************/
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Recursive files search
|
|
* Recursive files search
|
|
|
*
|
|
*
|
|
@@ -1163,16 +1138,16 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
// non UTF-8 use elFinderVolumeDriver::doSearch()
|
|
// non UTF-8 use elFinderVolumeDriver::doSearch()
|
|
|
return parent::doSearch($path, $q, $mimes);
|
|
return parent::doSearch($path, $q, $mimes);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$result = array();
|
|
$result = array();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$timeout = $this->options['searchTimeout']? $this->searchStart + $this->options['searchTimeout'] : 0;
|
|
$timeout = $this->options['searchTimeout']? $this->searchStart + $this->options['searchTimeout'] : 0;
|
|
|
if ($timeout && $timeout < time()) {
|
|
if ($timeout && $timeout < time()) {
|
|
|
$this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode($path)));
|
|
$this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode($path)));
|
|
|
return $result;
|
|
return $result;
|
|
|
}
|
|
}
|
|
|
elFinder::extendTimeLimit($this->options['searchTimeout'] + 30);
|
|
elFinder::extendTimeLimit($this->options['searchTimeout'] + 30);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$match = array();
|
|
$match = array();
|
|
|
try {
|
|
try {
|
|
|
$iterator = new RecursiveIteratorIterator(
|
|
$iterator = new RecursiveIteratorIterator(
|
|
@@ -1202,40 +1177,65 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} catch (Exception $e) {}
|
|
} catch (Exception $e) {}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($match) {
|
|
if ($match) {
|
|
|
foreach($match as $p) {
|
|
foreach($match as $p) {
|
|
|
if ($timeout && ($this->error || $timeout < time())) {
|
|
if ($timeout && ($this->error || $timeout < time())) {
|
|
|
!$this->error && $this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode(dirname($p))));
|
|
!$this->error && $this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode(dirname($p))));
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$stat = $this->stat($p);
|
|
$stat = $this->stat($p);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!$stat) { // invalid links
|
|
if (!$stat) { // invalid links
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!empty($stat['hidden']) || !$this->mimeAccepted($stat['mime'], $mimes)) {
|
|
if (!empty($stat['hidden']) || !$this->mimeAccepted($stat['mime'], $mimes)) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$name = $stat['name'];
|
|
$name = $stat['name'];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ((!$mimes || $stat['mime'] !== 'directory')) {
|
|
if ((!$mimes || $stat['mime'] !== 'directory')) {
|
|
|
$stat['path'] = $this->path($stat['hash']);
|
|
$stat['path'] = $this->path($stat['hash']);
|
|
|
if ($this->URL && !isset($stat['url'])) {
|
|
if ($this->URL && !isset($stat['url'])) {
|
|
|
$_path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1));
|
|
$_path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1));
|
|
|
$stat['url'] = $this->URL . str_replace('%2F', '/', rawurlencode($_path));
|
|
$stat['url'] = $this->URL . str_replace('%2F', '/', rawurlencode($_path));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$result[] = $stat;
|
|
$result[] = $stat;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return $result;
|
|
return $result;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /******************** Original local functions ************************
|
|
|
|
|
+ * @param $file
|
|
|
|
|
+ * @param $key
|
|
|
|
|
+ * @param $iterator
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ public function localFileSystemSearchIteratorFilter($file, $key, $iterator) {
|
|
|
|
|
+ $name = $file->getFilename();
|
|
|
|
|
+ if ($this->doSearchCurrentQuery['excludes']) {
|
|
|
|
|
+ foreach($this->doSearchCurrentQuery['excludes'] as $exclude) {
|
|
|
|
|
+ if ($this->stripos($name, $exclude) !== false) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($iterator->hasChildren()) {
|
|
|
|
|
+ if ($this->options['searchExDirReg'] && preg_match($this->options['searchExDirReg'], $key)) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return (bool)$this->attr($key, 'read', null, true);
|
|
|
|
|
+ }
|
|
|
|
|
+ return ($this->stripos($name, $this->doSearchCurrentQuery['q']) === false)? false : true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
} // END class
|
|
} // END class
|
|
|
|
|
|