/** * 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 != $compare) { return $mtime; } $inotifywait = defined('ELFINER_INOTIFYWAIT_PATH') ? ELFINER_INOTIFYWAIT_PATH : 'inotifywait'; $path = escapeshellarg($path); $standby = max(1, intval($standby)); $cmd = $inotifywait . ' ' . $path . ' -t ' . $standby . ' -e moved_to,moved_from,move,close_write,delete,delete_self'; $this->procExec($cmd, $o, $r); if ($r === 0) { // changed clearstatcache(); $mtime = @filemtime($path); // error on busy? return $mtime ? $mtime : time(); } else { if ($r === 2) { // not changed (timeout) return $compare; } } // error // cache to $_SESSION $sessionStart = $this->sessionRestart(); if ($sessionStart) { $this->sessionCache['localFileSystemInotify_disable'] = true; elFinder::sessionWrite(); } return false; }
/** * Clean cache * * @return void * @author Dmitry (dio) Levashov **/ protected function clearcache() { $this->cache = $this->dirsCache = array(); $this->sessionRestart(); unset($this->sessionCache['rootstat'][md5($this->root)]); elFinder::sessionWrite(); }
/** * Save network volumes config. * * @param array $volumes volumes config * @return void * @author Dmitry (dio) Levashov */ protected function saveNetVolumes($volumes) { // try session restart @session_start(); $_SESSION[$this->netVolumesSessionKey] = elFinder::sessionDataEncode($volumes); elFinder::sessionWrite(); }