alexlcdee %!s(int64=8) %!d(string=hai) anos
pai
achega
40621c1762

+ 153 - 0
src/assets/main.default.js

@@ -0,0 +1,153 @@
+"use strict";
+/**
+ * elFinder client options and main script for RequireJS
+ *
+ * Rename "main.default.js" to "main.js" and edit it if you need configure elFInder options or any things. And use that in elfinder.html.
+ * e.g. `<script data-main="./main.js" src="./require.js"></script>`
+ **/
+(function(){
+	var // jQuery and jQueryUI version
+		jqver = '3.2.1',
+		uiver = '1.12.1',
+		
+		// Detect language (optional)
+		lang = (function() {
+			var locq = window.location.search,
+				fullLang, locm, lang;
+			if (locq && (locm = locq.match(/lang=([a-zA-Z_-]+)/))) {
+				// detection by url query (?lang=xx)
+				fullLang = locm[1];
+			} else {
+				// detection by browser language
+				fullLang = (navigator.browserLanguage || navigator.language || navigator.userLanguage);
+			}
+			lang = fullLang.substr(0,2);
+			if (lang === 'ja') lang = 'jp';
+			else if (lang === 'pt') lang = 'pt_BR';
+			else if (lang === 'ug') lang = 'ug_CN';
+			else if (lang === 'zh') lang = (fullLang.substr(0,5).toLowerCase() === 'zh-tw')? 'zh_TW' : 'zh_CN';
+			return lang;
+		})(),
+		
+		// Start elFinder (REQUIRED)
+		start = function(elFinder, editors, config) {
+			// load jQueryUI CSS
+			elFinder.prototype.loadCss('//cdnjs.cloudflare.com/ajax/libs/jqueryui/'+uiver+'/themes/smoothness/jquery-ui.css');
+			
+			$(function() {
+				var optEditors = {
+						commandsOptions: {
+							edit: {
+								editors: Array.isArray(editors)? editors : []
+							}
+						}
+					},
+					opts = {};
+				
+				// Interpretation of "elFinderConfig"
+				if (config && config.managers) {
+					$.each(config.managers, function(id, mOpts) {
+						opts = Object.assign(opts, config.defaultOpts || {});
+						// editors marges to opts.commandOptions.edit
+						try {
+							mOpts.commandsOptions.edit.editors = mOpts.commandsOptions.edit.editors.concat(editors || []);
+						} catch(e) {
+							Object.assign(mOpts, optEditors);
+						}
+						// Make elFinder
+						$('#' + id).elfinder(
+							// 1st Arg - options
+							$.extend(true, { lang: lang }, opts, mOpts || {}),
+							// 2nd Arg - before boot up function
+							function(fm, extraObj) {
+								// `init` event callback function
+								fm.bind('init', function() {
+									// Optional for Japanese decoder "extras/encoding-japanese.min"
+									delete fm.options.rawStringDecoder;
+									if (fm.lang === 'jp') {
+										require(
+											[ 'extras/encoding-japanese.min' ],
+											function(Encoding) {
+												if (Encoding.convert) {
+													fm.options.rawStringDecoder = function(s) {
+														return Encoding.convert(s,{to:'UNICODE',type:'string'});
+													};
+												}
+											}
+										);
+									}
+								});
+							}
+						);
+					});
+				} else {
+					alert('"elFinderConfig" object is wrong.');
+				}
+			});
+		},
+		
+		// JavaScript loader (REQUIRED)
+		load = function() {
+			require(
+				[
+					'elfinder'
+					, 'extras/editors.default.min'               // load text, image editors
+					, 'elFinderConfig'
+				//	, 'extras/quicklook.googledocs.min'          // optional preview for GoogleApps contents on the GoogleDrive volume
+				],
+				start,
+				function(error) {
+					alert(error.message);
+				}
+			);
+		},
+		
+		// is IE8? for determine the jQuery version to use (optional)
+		ie8 = (typeof window.addEventListener === 'undefined' && typeof document.getElementsByClassName === 'undefined');
+
+	// config of RequireJS (REQUIRED)
+	require.config({
+		baseUrl : 'js',
+		paths : {
+			'jquery'   : '//cdnjs.cloudflare.com/ajax/libs/jquery/'+(ie8? '1.12.4' : jqver)+'/jquery.min',
+			'jquery-ui': '//cdnjs.cloudflare.com/ajax/libs/jqueryui/'+uiver+'/jquery-ui.min',
+			'elfinder' : 'elfinder.min'
+		},
+		waitSeconds : 10 // optional
+	});
+
+	// check elFinderConfig and fallback
+	if (! require.defined('elFinderConfig')) {
+		define('elFinderConfig', {
+			// elFinder options (REQUIRED)
+			// Documentation for client options:
+			// https://github.com/Studio-42/elFinder/wiki/Client-configuration-options
+			defaultOpts : {
+				url : 'php/connector.minimal.php' // connector URL (REQUIRED)
+				,commandsOptions : {
+					edit : {
+						extraOptions : {
+							// set API key to enable Creative Cloud image editor
+							// see https://console.adobe.io/
+							creativeCloudApiKey : '',
+							// browsing manager URL for CKEditor, TinyMCE
+							// uses self location with the empty value
+							managerUrl : ''
+						}
+					}
+					,quicklook : {
+						// to enable preview with Google Docs Viewer
+						googleDocsMimes : ['application/pdf', 'image/tiff', 'application/vnd.ms-office', 'application/msword', 'application/vnd.ms-word', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.presentationml.presentation']
+					}
+				}
+			},
+			managers : {
+				'elfinder': {},
+			}
+		});
+	}
+
+	// load JavaScripts (REQUIRED)
+	load();
+
+})();

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 319 - 875
src/php/elFinder.class.php


+ 41 - 37
src/php/elFinderConnector.class.php

@@ -6,24 +6,20 @@
  * @author Dmitry (dio) Levashov
  **/
 class elFinderConnector {
-	/**
-	 * Content type of output JSON
-	 *
-	 * @var string
-	 */
-	protected static $contentType = 'Content-Type: application/json';
 	/**
 	 * elFinder instance
 	 *
 	 * @var elFinder
 	 **/
 	protected $elFinder;
+	
 	/**
 	 * Options
 	 *
 	 * @var aray
 	 **/
 	protected $options = array();
+	
 	/**
 	 * Must be use output($data) $data['header']
 	 *
@@ -31,13 +27,21 @@ class elFinderConnector {
 	 * @deprecated
 	 **/
 	protected $header = '';
+
 	/**
 	 * HTTP request method
-	 *
+	 * 
 	 * @var string
 	 */
 	protected $reqMethod = '';
 	
+	/**
+	 * Content type of output JSON
+	 * 
+	 * @var string
+	 */
+	protected static $contentType = 'Content-Type: application/json';
+	
 	/**
 	 * Constructor
 	 *
@@ -156,27 +160,6 @@ class elFinderConnector {
 		}
 	}
 	
-	/**
-	 * Remove null & stripslashes applies on "magic_quotes_gpc"
-	 *
-	 * @param  mixed  $args
-	 * @return mixed
-	 * @author Naoki Sawada
-	 */
-	protected function input_filter($args) {
-		static $magic_quotes_gpc = NULL;
-
-		if ($magic_quotes_gpc === NULL)
-			$magic_quotes_gpc = (version_compare(PHP_VERSION, '5.4', '<') && get_magic_quotes_gpc());
-
-		if (is_array($args)) {
-			return array_map(array(& $this, 'input_filter'), $args);
-		}
-		$res = str_replace("\0", '', $args);
-		$magic_quotes_gpc && ($res = stripslashes($res));
-		return $res;
-	}
-	
 	/**
 	 * Output json
 	 *
@@ -189,23 +172,23 @@ class elFinderConnector {
 		$this->elFinder->getSession()->close();
 		// client disconnect should abort
 		ignore_user_abort(false);
-
+		
 		if ($this->header) {
 			self::sendHeader($this->header);
 		}
-
+		
 		if (isset($data['pointer'])) {
 			// set time limit to 0
 			elFinder::extendTimeLimit(0);
-
+			
 			// send optional header
 			if (!empty($data['header'])) {
 				self::sendHeader($data['header']);
 			}
-
+			
 			// clear output buffer
 			while(ob_get_level() && ob_end_clean()){}
-
+			
 			$toEnd = true;
 			$fp = $data['pointer'];
 			$sendData = !($this->reqMethod === 'HEAD' || !empty($data['info']['xsendfile']));
@@ -233,11 +216,11 @@ class elFinderConnector {
 								}
 							}
 							$psize = $end - $start + 1;
-
+							
 							header('HTTP/1.1 206 Partial Content');
 							header('Content-Length: ' . $psize);
 							header('Content-Range: bytes ' . $start . '-' . $end . '/' . $size);
-
+							
 							// Apache mod_xsendfile dose not support range request
 							if (isset($data['info']['xsendfile']) && strtolower($data['info']['xsendfile']) === 'x-sendfile') {
 								if (function_exists('header_remove')) {
@@ -250,7 +233,7 @@ class elFinderConnector {
 									$sendData = true;
 								}
 							}
-
+							
 							$sendData && fseek($fp, $start);
 						}
 					}
@@ -278,7 +261,7 @@ class elFinderConnector {
 					fclose($out);
 				}
 			}
-
+			
 			if (!empty($data['volume'])) {
 				$data['volume']->close($data['pointer'], $data['info']['hash']);
 			}
@@ -289,6 +272,27 @@ class elFinderConnector {
 		}
 	}
 	
+	/**
+	 * Remove null & stripslashes applies on "magic_quotes_gpc"
+	 * 
+	 * @param  mixed  $args
+	 * @return mixed
+	 * @author Naoki Sawada
+	 */
+	protected function input_filter($args) {
+		static $magic_quotes_gpc = NULL;
+		
+		if ($magic_quotes_gpc === NULL)
+			$magic_quotes_gpc = (version_compare(PHP_VERSION, '5.4', '<') && get_magic_quotes_gpc());
+		
+		if (is_array($args)) {
+			return array_map(array(& $this, 'input_filter'), $args);
+		}
+		$res = str_replace("\0", '', $args);
+		$magic_quotes_gpc && ($res = stripslashes($res));
+		return $res;
+	}
+	
 	/**
 	 * Send HTTP header
 	 * 

+ 29 - 29
src/php/elFinderFlysystemGoogleDriveNetmount.php

@@ -36,6 +36,25 @@ class elFinderVolumeFlysystemGoogleDriveNetmount extends \Hypweb\elFinderFlysyst
         $this->options = array_merge($this->options, $opts);
     }
 
+    /**
+     * Prepare driver before mount volume.
+     * Return true if volume is ready.
+     *
+     * @return bool
+     **/
+    protected function init()
+    {
+        if (empty($this->options['icon'])) {
+            $this->options['icon'] = true;
+        }
+        if ($res = parent::init()) {
+            if ($this->options['icon'] === true) {
+                unset($this->options['icon']);
+            }
+        }
+        return $res;
+    }
+
     /**
      * Prepare
      * Call from elFinder::netmout() before volume->mount()
@@ -52,11 +71,11 @@ class elFinderVolumeFlysystemGoogleDriveNetmount extends \Hypweb\elFinderFlysyst
         if (empty($options['client_secret']) && defined('ELFINDER_GOOGLEDRIVE_CLIENTSECRET')) {
             $options['client_secret'] = ELFINDER_GOOGLEDRIVE_CLIENTSECRET;
         }
-
+        
         if (! isset($options['pass'])) {
             $options['pass'] = '';
         }
-
+        
         try {
             $client = new \Google_Client();
             $client->setClientId($options['client_id']);
@@ -70,7 +89,7 @@ class elFinderVolumeFlysystemGoogleDriveNetmount extends \Hypweb\elFinderFlysyst
             }
 
             $options = array_merge($this->session->get('GoogleDriveAuthParams', []), $options);
-
+            
             if (! isset($options['access_token'])) {
                 $options['access_token'] = $this->session->get('GoogleDriveTokens', []);
                 $this->session->remove('GoogleDriveTokens');
@@ -106,7 +125,7 @@ class elFinderVolumeFlysystemGoogleDriveNetmount extends \Hypweb\elFinderFlysyst
                 if (empty($options['url'])) {
                     $options['url'] = elFinder::getConnectorUrl();
                 }
-
+                
                 $callback  = $options['url']
                            . '?cmd=netmount&protocol=googledrive&host=1';
                 $client->setRedirectUri($callback);
@@ -118,7 +137,7 @@ class elFinderVolumeFlysystemGoogleDriveNetmount extends \Hypweb\elFinderFlysyst
                         $client->setAccessType('offline');
                     }
                     $url = $client->createAuthUrl();
-
+                    
                     $html = '<input id="elf-volumedriver-googledrive-host-btn" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" value="{msg:btnApprove}" type="button" onclick="window.open(\''.$url.'\')">';
                     $html .= '<script>
                         $("#'.$options['id'].'").elfinder("instance").trigger("netmount", {protocol: "googledrive", mode: "makebtn"});
@@ -175,15 +194,15 @@ class elFinderVolumeFlysystemGoogleDriveNetmount extends \Hypweb\elFinderFlysyst
                 return array('exit' => true, 'error' => [elFinder::ERROR_ACCESS_DENIED, $e->getMessage()]);
             }
         }
-
+        
         if (! $aToken) {
             return array('exit' => true, 'error' => elFinder::ERROR_REAUTH_REQUIRE);
         }
-
+        
         if ($options['path'] === '/') {
             $options['path'] = 'root';
         }
-
+        
         try {
             $file = $service->files->get($options['path']);
             $options['alias'] = sprintf($this->options['gdAlias'], $file->getName());
@@ -266,7 +285,7 @@ class elFinderVolumeFlysystemGoogleDriveNetmount extends \Hypweb\elFinderFlysyst
         if (!isset($opts['path']) || $opts['path'] === '') {
             $opts['path'] = 'root';
         }
-
+        
         $googleDrive = new GoogleDriveAdapter($service, $opts['path'], [ 'useHasDir' => true ]);
 
         $opts['fscache'] = null;
@@ -288,7 +307,7 @@ class elFinderVolumeFlysystemGoogleDriveNetmount extends \Hypweb\elFinderFlysyst
         if (! isset($opts['alias'])) {
             $opts['alias'] = 'GoogleDrive';
         }
-
+        
         if ($res = parent::mount($opts)) {
             // update access_token of session data
             if ($creds) {
@@ -301,25 +320,6 @@ class elFinderVolumeFlysystemGoogleDriveNetmount extends \Hypweb\elFinderFlysyst
         return $res;
     }
 
-    /**
-     * Prepare driver before mount volume.
-     * Return true if volume is ready.
-     *
-     * @return bool
-     **/
-    protected function init()
-    {
-        if (empty($this->options['icon'])) {
-            $this->options['icon'] = true;
-        }
-        if ($res = parent::init()) {
-            if ($this->options['icon'] === true) {
-                unset($this->options['icon']);
-            }
-        }
-        return $res;
-    }
-
     /**
      * @inheritdoc
      */

+ 96 - 96
src/php/elFinderSession.php

@@ -33,6 +33,38 @@ class elFinderSession implements elFinderSessionInterface
 		return $this;
 	}
 	
+    /**
+     * {@inheritdoc}
+     */
+	public function start()
+	{
+		if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
+			if (session_status() !== PHP_SESSION_ACTIVE) {
+				session_start();
+			}
+		} else {
+			set_error_handler(array($this, 'session_start_error'),  E_NOTICE);
+			session_start();
+			restore_error_handler();
+		}
+		$this->started = session_id()? true : false;
+		
+		return $this;
+	}
+	
+    /**
+     * {@inheritdoc}
+     */
+	public function close()
+	{
+		if ($this->started) {
+			session_write_close();
+		}
+		$this->started = false;
+		
+		return $this;
+	}
+	
     /**
      * {@inheritdoc}
      */
@@ -43,9 +75,9 @@ class elFinderSession implements elFinderSessionInterface
 			$closed = true;
 			$this->start();
 		}
-
+		
 		$data = null;
-
+		
 		if ($this->started) {
 			$session =& $this->getSessionRef($key);
 			$data = $session;
@@ -53,7 +85,7 @@ class elFinderSession implements elFinderSessionInterface
 				$data = $this->decodeData($data);
 			}
 		}
-
+		
 		$checkFn = null;
 		if (! is_null($empty)) {
 			if (is_string($empty)) {
@@ -68,11 +100,11 @@ class elFinderSession implements elFinderSessionInterface
 				$checkFn = 'is_int';
 			}
 		}
-
+		
 		if (is_null($data) || ($checkFn && ! $checkFn($data))) {
 			$session = $data = $empty;
 		}
-
+		
 		if ($closed) {
 			$this->close();
 		}
@@ -83,19 +115,62 @@ class elFinderSession implements elFinderSessionInterface
     /**
      * {@inheritdoc}
      */
-	public function start()
+	public function set($key, $data)
 	{
-		if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
-			if (session_status() !== PHP_SESSION_ACTIVE) {
-				session_start();
+		$closed = false;
+		if (! $this->started) {
+			$closed = true;
+			$this->start();
+		}
+		$session =& $this->getSessionRef($key);
+		if ($this->base64encode) {
+			$data = $this->encodeData($data);
+		}
+		$session = $data;
+		
+		if ($closed) {
+			$this->close();
+		}
+		
+		return $this;
+	}
+	
+    /**
+     * {@inheritdoc}
+     */
+	public function remove($key)
+	{
+		$closed = false;
+		if (! $this->started) {
+			$closed = true;
+			$this->start();
+		}
+
+		list($cat, $name) = array_pad(explode('.', $key, 2), 2, null);
+		if (is_null($name)) {
+			if (! isset($this->keys[$cat])) {
+				$name = $cat;
+				$cat = 'default';
 			}
+		}
+		if (isset($this->keys[$cat])) {
+			$cat = $this->keys[$cat];
 		} else {
-			set_error_handler(array($this, 'session_start_error'),  E_NOTICE);
-			session_start();
-			restore_error_handler();
+			$name = $cat . '.' . $name;
+			$cat = $this->keys['default'];
+		}
+		if (is_null($name)) {
+			unset($_SESSION[$cat]);
+		} else {
+			if (isset($_SESSION[$cat]) && is_array($_SESSION[$cat])) {
+				unset($_SESSION[$cat][$name]);
+			}
 		}
-		$this->started = session_id()? true : false;
 
+		if ($closed) {
+			$this->close();
+		}
+		
 		return $this;
 	}
 	
@@ -134,6 +209,14 @@ class elFinderSession implements elFinderSessionInterface
 		return $session;
 	}
 	
+	protected function encodeData($data)
+	{
+		if ($this->base64encode) {
+			$data = base64_encode(serialize($data));
+		}
+		return $data;
+	}
+	
 	protected function decodeData($data)
 	{
 		if ($this->base64encode) {
@@ -149,89 +232,6 @@ class elFinderSession implements elFinderSessionInterface
 		}
 		return $data;
 	}
-	
-    /**
-     * {@inheritdoc}
-     */
-	public function close()
-	{
-		if ($this->started) {
-			session_write_close();
-		}
-		$this->started = false;
-
-		return $this;
-	}
-	
-    /**
-     * {@inheritdoc}
-     */
-	public function set($key, $data)
-	{
-		$closed = false;
-		if (! $this->started) {
-			$closed = true;
-			$this->start();
-		}
-		$session =& $this->getSessionRef($key);
-		if ($this->base64encode) {
-			$data = $this->encodeData($data);
-		}
-		$session = $data;
-
-		if ($closed) {
-			$this->close();
-		}
-
-		return $this;
-	}
-	
-	protected function encodeData($data)
-	{
-		if ($this->base64encode) {
-			$data = base64_encode(serialize($data));
-		}
-		return $data;
-	}
-	
-    /**
-     * {@inheritdoc}
-     */
-	public function remove($key)
-	{
-		$closed = false;
-		if (! $this->started) {
-			$closed = true;
-			$this->start();
-		}
-
-		list($cat, $name) = array_pad(explode('.', $key, 2), 2, null);
-		if (is_null($name)) {
-			if (! isset($this->keys[$cat])) {
-				$name = $cat;
-				$cat = 'default';
-			}
-		}
-		if (isset($this->keys[$cat])) {
-			$cat = $this->keys[$cat];
-		} else {
-			$name = $cat . '.' . $name;
-			$cat = $this->keys['default'];
-		}
-		if (is_null($name)) {
-			unset($_SESSION[$cat]);
-		} else {
-			if (isset($_SESSION[$cat]) && is_array($_SESSION[$cat])) {
-				unset($_SESSION[$cat][$name]);
-			}
-		}
-
-		if ($closed) {
-			$this->close();
-		}
-
-		return $this;
-	}
 
 	protected function session_start_error($errno , $errstr) {}
 }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 555 - 694
src/php/elFinderVolumeBox.class.php


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 909 - 975
src/php/elFinderVolumeDriver.class.php


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 320 - 370
src/php/elFinderVolumeDropbox.class.php


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 446 - 413
src/php/elFinderVolumeDropbox2.class.php


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 343 - 752
src/php/elFinderVolumeFTP.class.php


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 548 - 379
src/php/elFinderVolumeGoogleDrive.class.php


+ 256 - 256
src/php/elFinderVolumeLocalFileSystem.class.php

@@ -65,78 +65,6 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 	/*                        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.
 	 * Return true if volume is ready.
@@ -169,23 +97,17 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 		if (!empty($this->options['startPath'])) {
 			$this->options['startPath'] = $this->getFullPath($this->options['startPath'], $this->root);
 		}
-
+		
 		if (is_null($this->options['syncChkAsTs'])) {
 			$this->options['syncChkAsTs'] = true;
 		}
 		if (is_null($this->options['syncCheckFunc'])) {
 			$this->options['syncCheckFunc'] = array($this, 'localFileSystemInotify');
 		}
-
+		
 		return true;
 	}
 	
-	/*********************************************************************/
-	/*                               FS API                              */
-	/*********************************************************************/
-
-	/*********************** paths/urls *************************/
-	
 	/**
 	 * Configure after successfull mount.
 	 *
@@ -194,7 +116,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 	 **/
 	protected function configure() {
 		$root = $this->stat($this->root);
-
+		
 		// chek thumbnails path
 		if ($this->options['tmbPath']) {
 			$this->options['tmbPath'] = strpos($this->options['tmbPath'], DIRECTORY_SEPARATOR) === false
@@ -205,7 +127,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 		}
 
 		parent::configure();
-
+		
 		// set $this->tmp by options['tmpPath']
 		$this->tmp = '';
 		if (!empty($this->options['tmpPath'])) {
@@ -216,7 +138,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 		if (!$this->tmp && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
 			$this->tmp = $tmp;
 		}
-
+		
 		// if no thumbnails url - try detect it
 		if ($root['read'] && !$this->tmbURL && $this->URL) {
 			if (strpos($this->tmbPath, $this->root) === 0) {
@@ -242,7 +164,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 				}
 			}
 		}
-
+		
 		if (!$this->quarantine) {
 			if (!$this->tmp) {
 				$this->archivers['extract'] = array();
@@ -251,7 +173,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 				$this->quarantine = $this->tmp;
 			}
 		}
-
+		
 		if ($this->options['quarantine']) {
 			$this->attributes[] = array(
 					'pattern' => '~^'.preg_quote(DIRECTORY_SEPARATOR.$this->options['quarantine']).'$~',
@@ -261,30 +183,85 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 					'hidden'  => true
 			);
 		}
-
+		
 		if (! empty($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
 	 * @return string
 	 * @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
 	 * @return string
 	 * @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
 	 * @return string
 	 * @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.
 	 * Stat contains following fields:
@@ -400,17 +428,17 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 	 *
 	 * If file does not exists - returns empty array or false.
 	 *
-	 * @param  string  $path    file path
+	 * @param  string  $path    file path 
 	 * @return array|false
 	 * @author Dmitry (dio) Levashov
 	 **/
 	protected function _stat($path) {
-
+		
 		static $statOwner;
 		if (is_null($statOwner)) {
 			$statOwner = (!empty($this->options['statOwner']));
 		}
-
+		
 		$stat = array();
 
 		if (!file_exists($path) && !is_link($path)) {
@@ -454,14 +482,14 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 			$stat['perm'] = substr((string)decoct($fstat['mode']), -4);
 			$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
 		}
-
+		
 		if (($dir = is_dir($path)) && $this->options['detectDirIcon']) {
 			$favicon = $path . DIRECTORY_SEPARATOR . $this->options['detectDirIcon'];
 			if ($this->URL && file_exists($favicon)) {
 				$stat['icon'] = $this->URL . str_replace(DIRECTORY_SEPARATOR, '/', substr($favicon, strlen($this->root) + 1));
 			}
 		}
-
+		
 		if (!isset($stat['mime'])) {
 			$stat['mime'] = $dir ? 'directory' : $this->mimetype($path);
 		}
@@ -472,55 +500,10 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 		if (is_null($stat['read'])) {
 			$stat['size'] = $dir ? 0 : $size;
 		}
-
+		
 		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`
 	 * Sub-fuction of _stat() and _scandir()
@@ -571,38 +554,6 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 		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
 	 *
@@ -644,7 +595,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 		}
 		return $dirs;
 	}
-		
+	
 	/**
 	 * Return object width and height
 	 * Usualy used for images, but can be realize for video etc...
@@ -656,11 +607,35 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 	 **/
 	protected function _dimensions($path, $mime) {
 		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;
 	}
+	/******************** 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.
 	 *
@@ -679,16 +654,16 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 		try {
 			$dirItr = new DirectoryIterator($path);
 		} catch (UnexpectedValueException $e) {}
-
+		
 		foreach ($dirItr as $file) {
 			try {
 				if ($file->isDot()) { continue; }
-
+				
 				$files[] = $fpath = $file->getPathname();
-
+				
 				$br = false;
 				$stat = array();
-
+				
 				$gid = $uid = 0;
 				$stat['isowner'] = false;
 				$linkreadable = false;
@@ -735,31 +710,31 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 						$stat['perm'] = substr((string)decoct($file->getPerms()), -4);
 						$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
 					}
-
+					
 					//logical rights first
 					$stat['read'] = ($linkreadable || $file->isReadable())? null : false;
 					$stat['write'] = $file->isWritable()? null : false;
 					$stat['locked'] = $dirWritable? null : true;
-
+					
 					if (is_null($stat['read'])) {
 						$stat['size'] = $dir ? 0 : $size;
 					}
-
+					
 				}
-
+				
 				$cache[] = array($fpath, $stat);
 			} catch (RuntimeException $e) {
 				continue;
 			}
 		}
-
+		
 		if ($cache) {
 			$cache = $this->convEncOut($cache, false);
 			foreach($cache as $d) {
 				$this->updateCache($d[0], $d[1]);
 			}
 		}
-
+		
 		return $files;
 	}
 
@@ -775,9 +750,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 	protected function _fopen($path, $mode='rb') {
 		return fopen($path, $mode);
 	}
-	
-	/********************  file/dir manipulations *************************/
-	
+
 	/**
 	 * Close opened file
 	 *
@@ -790,6 +763,8 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 		return (is_resource($fp) && fclose($fp));
 	}
 	
+	/********************  file/dir manipulations *************************/
+	
 	/**
 	 * Create dir and return created dir path or false on failed
 	 *
@@ -819,7 +794,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 	 **/
 	protected function _mkfile($path, $name) {
 		$path = $this->_joinPath($path, $name);
-
+		
 		if (($fp = fopen($path, 'w'))) {
 			fclose($fp);
 			chmod($path, $this->options['fileMode']);
@@ -840,7 +815,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 	protected function _symlink($source, $targetDir, $name) {
 		return symlink($source, $this->_joinPath($targetDir, $name));
 	}
-
+	
 	/**
 	 * Copy file into another file
 	 *
@@ -858,7 +833,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 		}
 		return $ret;
 	}
-		
+
 	/**
 	 * Move file into another parent dir.
 	 * Return new file path or false.
@@ -878,7 +853,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 		}
 		return $ret;
 	}
-
+		
 	/**
 	 * Remove file
 	 *
@@ -889,7 +864,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 	protected function _unlink($path) {
 		return is_file($path) && unlink($path);
 	}
-	
+
 	/**
 	 * Remove dir
 	 *
@@ -934,7 +909,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 				return false;
 			}
 		}
-
+		
 		chmod($path, $this->options['fileMode']);
 		return $path;
 	}
@@ -949,7 +924,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 	protected function _getContents($path) {
 		return file_get_contents($path);
 	}
-
+	
 	/**
 	 * Write a string to a file
 	 *
@@ -994,50 +969,50 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 	protected function _findSymlinks($path) {
 		return self::localFindSymlinks($path);
 	}
-	
+
 	/**
 	 * Extract files from archive
 	 *
 	 * @param  string  $path  archive path
 	 * @param  array   $arc   archiver command and arguments (same as in $this->archivers)
 	 * @return true
-	 * @author Dmitry (dio) Levashov,
+	 * @author Dmitry (dio) Levashov, 
 	 * @author Alexey Sukhotin
 	 **/
 	protected function _extract($path, $arc) {
-
+		
 		if ($this->quarantine) {
 
 			$dir     = $this->quarantine.DIRECTORY_SEPARATOR.md5(basename($path).mt_rand());
 			$archive = (isset($arc['toSpec']) || $arc['cmd'] === 'phpfunction')? '' : $dir.DIRECTORY_SEPARATOR.basename($path);
-
+			
 			if (!mkdir($dir)) {
 				return false;
 			}
-
+			
 			// insurance unexpected shutdown
 			register_shutdown_function(array($this, 'rmdirRecursive'), realpath($dir));
-
+			
 			chmod($dir, 0777);
-
+			
 			// copy in quarantine
 			if (!is_readable($path) || ($archive && !copy($path, $archive))) {
 				return false;
 			}
-
+			
 			// extract in quarantine
 			$this->unpackArchive($path, $arc, $archive? true : $dir);
-
+			
 			// get files list
 			$ls = self::localScandir($dir);
-
+			
 			// no files - extract error ?
 			if (empty($ls)) {
 				return false;
 			}
-
+			
 			$this->archiveSize = 0;
-
+			
 			// find symlinks and check extracted items
 			$checkRes = $this->checkExtractItems($dir);
 			if ($checkRes['symlinks']) {
@@ -1050,15 +1025,15 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 					$this->addError(elFinder::ERROR_SAVE, $name);
 				}
 			}
-
+			
 			// check max files size
 			if ($this->options['maxArcFilesSize'] > 0 && $this->options['maxArcFilesSize'] < $this->archiveSize) {
 				$this->delTree($dir);
 				return $this->setError(elFinder::ERROR_ARC_MAXSIZE);
 			}
-
+			
 			$extractTo = $this->extractToNewdir; // 'auto', ture or false
-
+			
 			// archive contains one item - extract in archive dir
 			$name = '';
 			$src = $dir.DIRECTORY_SEPARATOR.$ls[0];
@@ -1077,7 +1052,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 					$name = $this->uniqueName(dirname($path), $name, '-', false);
 				}
 			}
-
+			
 			if ($name !== '') {
 				$result  = dirname($path).DIRECTORY_SEPARATOR.$name;
 
@@ -1099,27 +1074,14 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 					return false;
 				}
 			}
-
+			
 			is_dir($dir) && $this->delTree($dir);
-
+			
 			return (is_array($result) || file_exists($result)) ? $result : false;
 		}
 	    //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
 	 *
@@ -1128,15 +1090,15 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 	 * @param  string  $name   archive name
 	 * @param  array   $arc    archiver options
 	 * @return string|bool
-	 * @author Dmitry (dio) Levashov,
+	 * @author Dmitry (dio) Levashov, 
 	 * @author Alexey Sukhotin
 	 **/
 	protected function _archive($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
 	 *
@@ -1148,6 +1110,19 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 		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
 	 *
@@ -1163,16 +1138,16 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 			// non UTF-8 use elFinderVolumeDriver::doSearch()
 			return parent::doSearch($path, $q, $mimes);
 		}
-
+		
 		$result = array();
-
+		
 		$timeout = $this->options['searchTimeout']? $this->searchStart + $this->options['searchTimeout'] : 0;
 		if ($timeout && $timeout < time()) {
 			$this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode($path)));
 			return $result;
 		}
 		elFinder::extendTimeLimit($this->options['searchTimeout'] + 30);
-
+		
 		$match = array();
 		try {
 			$iterator = new RecursiveIteratorIterator(
@@ -1202,40 +1177,65 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
 				}
 			}
 		} catch (Exception $e) {}
-
+		
 		if ($match) {
 			foreach($match as $p) {
 				if ($timeout && ($this->error || $timeout < time())) {
 					!$this->error && $this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode(dirname($p))));
 					break;
 				}
-
+				
 				$stat = $this->stat($p);
-
+		
 				if (!$stat) { // invalid links
 					continue;
 				}
-
+		
 				if (!empty($stat['hidden']) || !$this->mimeAccepted($stat['mime'], $mimes)) {
 					continue;
 				}
-
+					
 				$name = $stat['name'];
-
+		
 				if ((!$mimes || $stat['mime'] !== 'directory')) {
 					$stat['path'] = $this->path($stat['hash']);
 					if ($this->URL && !isset($stat['url'])) {
 						$_path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1));
 						$stat['url'] = $this->URL . str_replace('%2F', '/', rawurlencode($_path));
 					}
-
+		
 					$result[] = $stat;
 				}
 			}
 		}
-
+		
 		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 
 

+ 277 - 276
src/php/elFinderVolumeMySQL.class.php

@@ -80,31 +80,6 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 	/*                        INIT AND CONFIGURE                         */
 	/*********************************************************************/
 	
-	/**
-	 * Close connection
-	 *
-	 * @return void
-	 * @author Dmitry (dio) Levashov
-	 **/
-	public function umount() {
-		$this->db->close();
-	}
-
-	/**
-	 * Return debug info for client
-	 *
-	 * @return array
-	 * @author Dmitry (dio) Levashov
-	 **/
-	public function debug() {
-		$debug = parent::debug();
-		$debug['sqlCount'] = $this->sqlCnt;
-		if ($this->dbError) {
-			$debug['dbError'] = $this->dbError;
-		}
-		return $debug;
-	}
-	
 	/**
 	 * Prepare driver before mount volume.
 	 * Connect to db, check required tables and fetch root path
@@ -113,22 +88,22 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 	 * @author Dmitry (dio) Levashov
 	 **/
 	protected function init() {
-
+		
 		if (!($this->options['host'] || $this->options['socket'])
-		||  !$this->options['user']
-		||  !$this->options['pass']
+		||  !$this->options['user'] 
+		||  !$this->options['pass'] 
 		||  !$this->options['db']
 		||  !$this->options['path']
 		||  !$this->options['files_table']) {
 			return false;
 		}
-
-
+		
+		
 		$this->db = new mysqli($this->options['host'], $this->options['user'], $this->options['pass'], $this->options['db'], $this->options['port'], $this->options['socket']);
 		if ($this->db->connect_error || mysqli_connect_error()) {
 			return false;
 		}
-
+		
 		$this->db->set_charset('utf8');
 
 		if ($res = $this->db->query('SHOW TABLES')) {
@@ -148,56 +123,62 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 
 		return true;
 	}
-	
+
+
+
 	/**
-	 * 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
-	 * - (bool)   read    read permissions. required
-	 * - (bool)   write   write permissions. required
-	 * - (bool)   locked  is object locked. optionally
-	 * - (bool)   hidden  is object hidden. optionally
-	 * - (string) alias   for symlinks - link target path relative to root path. optionally
-	 * - (string) target  for symlinks - link target path. optionally
-	 *
-	 * If file does not exists - returns empty array or false.
+	 * Set tmp path
 	 *
-	 * @param  string  $path    file path
-	 * @return array|false
+	 * @return void
 	 * @author Dmitry (dio) Levashov
 	 **/
-	protected function _stat($path) {
-		$sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, IF(ch.id, 1, 0) AS dirs
-				FROM '.$this->tbf.' AS f 
-				LEFT JOIN '.$this->tbf.' AS ch ON ch.parent_id=f.id AND ch.mime=\'directory\'
-				WHERE f.id=\''.$path.'\'
-				GROUP BY f.id, ch.id';
-
-		$res = $this->query($sql);
+	protected function configure() {
+		parent::configure();
 
-		if ($res) {
-			$stat = $res->fetch_assoc();
-			if ($stat['parent_id']) {
-				$stat['phash'] = $this->encode($stat['parent_id']);
-			}
-			if ($stat['mime'] == 'directory') {
-				unset($stat['width']);
-				unset($stat['height']);
-				$stat['size'] = 0;
-			} else {
-				if (!$stat['mime']) {
-					unset($stat['mime']);
+		if (($tmp = $this->options['tmpPath'])) {
+			if (!file_exists($tmp)) {
+				if (mkdir($tmp)) {
+					chmod($tmp, $this->options['tmbPathMode']);
 				}
-				unset($stat['dirs']);
 			}
-			unset($stat['id']);
-			unset($stat['parent_id']);
-			return $stat;
+			
+			$this->tmpPath = is_dir($tmp) && is_writable($tmp) ? $tmp : false;
+		}
+		if (!$this->tmpPath && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
+			$this->tmpPath = $tmp;
+		}
+		
+		// fallback of $this->tmp
+		if (!$this->tmpPath && $this->tmbPathWritable) {
+			$this->tmpPath = $this->tmbPath;
+		}
 
+		$this->mimeDetect = 'internal';
+	}
+	
+	/**
+	 * Close connection
+	 *
+	 * @return void
+	 * @author Dmitry (dio) Levashov
+	 **/
+	public function umount() {
+		$this->db->close();
+	}
+	
+	/**
+	 * Return debug info for client
+	 *
+	 * @return array
+	 * @author Dmitry (dio) Levashov
+	 **/
+	public function debug() {
+		$debug = parent::debug();
+		$debug['sqlCount'] = $this->sqlCnt;
+		if ($this->dbError) {
+			$debug['dbError'] = $this->dbError;
 		}
-		return array();
+		return $debug;
 	}
 
 	/**
@@ -218,39 +199,109 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 	}
 
 	/**
-	 * Set tmp path
+	 * Create empty object with required mimetype
 	 *
-	 * @return void
+	 * @param  string  $path  parent dir path
+	 * @param  string  $name  object name
+	 * @param  string  $mime  mime type
+	 * @return bool
 	 * @author Dmitry (dio) Levashov
 	 **/
-	protected function configure() {
-		parent::configure();
+	protected function make($path, $name, $mime) {
+		$sql = 'INSERT INTO %s (`parent_id`, `name`, `size`, `mtime`, `mime`, `content`, `read`, `write`, `locked`, `hidden`, `width`, `height`) VALUES (\'%s\', \'%s\', 0, %d, \'%s\', \'\', \'%d\', \'%d\', \'%d\', \'%d\', 0, 0)';
+		$sql = sprintf($sql, $this->tbf, $path, $this->db->real_escape_string($name), time(), $mime, $this->defaults['read'], $this->defaults['write'], $this->defaults['locked'], $this->defaults['hidden']);
+		// echo $sql;
+		return $this->query($sql) && $this->db->affected_rows > 0;
+	}
 
-		if (($tmp = $this->options['tmpPath'])) {
-			if (!file_exists($tmp)) {
-				if (mkdir($tmp)) {
-					chmod($tmp, $this->options['tmbPathMode']);
+	/*********************************************************************/
+	/*                               FS API                              */
+	/*********************************************************************/
+	
+	/**
+	 * Cache dir contents
+	 *
+	 * @param  string  $path  dir path
+	 * @return string
+	 * @author Dmitry Levashov
+	 **/
+	protected function cacheDir($path) {
+		$this->dirsCache[$path] = array();
+
+		$sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, IF(ch.id, 1, 0) AS dirs 
+				FROM '.$this->tbf.' AS f 
+				LEFT JOIN '.$this->tbf.' AS ch ON ch.parent_id=f.id AND ch.mime=\'directory\'
+				WHERE f.parent_id=\''.$path.'\'
+				GROUP BY f.id, ch.id';
+				
+		$res = $this->query($sql);
+		if ($res) {
+			while ($row = $res->fetch_assoc()) {
+				$id = $row['id'];
+				if ($row['parent_id']) {
+					$row['phash'] = $this->encode($row['parent_id']);
+				} 
+				
+				if ($row['mime'] == 'directory') {
+					unset($row['width']);
+					unset($row['height']);
+					$row['size'] = 0;
+				} else {
+					unset($row['dirs']);
+				}
+				
+				unset($row['id']);
+				unset($row['parent_id']);
+				
+				
+				
+				if (($stat = $this->updateCache($id, $row)) && empty($stat['hidden'])) {
+					$this->dirsCache[$path][] = $id;
 				}
 			}
+		}
+		
+		return $this->dirsCache[$path];
+	}
 
-			$this->tmpPath = is_dir($tmp) && is_writable($tmp) ? $tmp : false;
+	/**
+	 * Return array of parents paths (ids)
+	 *
+	 * @param  int   $path  file path (id)
+	 * @return array
+	 * @author Dmitry (dio) Levashov
+	 **/
+	protected function getParents($path) {
+		$parents = array();
+
+		while ($path) {
+			if ($file = $this->stat($path)) {
+				array_unshift($parents, $path);
+				$path = isset($file['phash']) ? $this->decode($file['phash']) : false;
+			}
 		}
-		if (!$this->tmpPath && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
-			$this->tmpPath = $tmp;
+		
+		if (count($parents)) {
+			array_pop($parents);
 		}
+		return $parents;
+	}
 
-		// fallback of $this->tmp
-		if (!$this->tmpPath && $this->tmbPathWritable) {
-			$this->tmpPath = $this->tmbPath;
+	/**
+	 * Return correct file path for LOAD_FILE method
+	 *
+	 * @param  string $path  file path (id)
+	 * @return string
+	 * @author Troex Nevelin
+	 **/
+	protected function loadFilePath($path) {
+		$realPath = realpath($path);
+		if (DIRECTORY_SEPARATOR == '\\') { // windows
+			$realPath = str_replace('\\', '\\\\', $realPath);
 		}
-
-		$this->mimeDetect = 'internal';
+		return $this->db->real_escape_string($realPath);
 	}
 
-	/*********************************************************************/
-	/*                               FS API                              */
-	/*********************************************************************/
-	
 	/**
 	 * Recursive files search
 	 *
@@ -263,7 +314,7 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 	protected function doSearch($path, $q, $mimes) {
 		$dirs = array();
 		$timeout = $this->options['searchTimeout']? $this->searchStart + $this->options['searchTimeout'] : 0;
-
+		
 		if ($path != $this->root) {
 			$dirs = $inpath = array(intval($path));
 			while($inpath) {
@@ -282,7 +333,7 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 		}
 
 		$result = array();
-
+		
 		if ($mimes) {
 			$whrs = array();
 			foreach($mimes as $mime) {
@@ -299,27 +350,27 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 		if ($dirs) {
 			$whr = '(' . $whr . ') AND (`parent_id` IN (' . join(',', $dirs) . '))';
 		}
-
+		
 		$sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, 0 AS dirs 
 				FROM %s AS f 
 				WHERE %s';
-
+		
 		$sql = sprintf($sql, $this->tbf, $whr);
-
+		
 		if (($res = $this->query($sql))) {
 			while ($row = $res->fetch_assoc()) {
 				if ($timeout && $timeout < time()) {
 					$this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode($path)));
 					break;
 				}
-
+				
 				if (!$this->mimeAccepted($row['mime'], $mimes)) {
 					continue;
 				}
 				$id = $row['id'];
 				if ($row['parent_id']) {
 					$row['phash'] = $this->encode($row['parent_id']);
-				}
+				} 
 				$row['path'] = $this->_path($id);
 
 				if ($row['mime'] == 'directory') {
@@ -337,52 +388,22 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 				}
 			}
 		}
-
+		
 		return $result;
 	}
 
-	/**
-	 * Return fake path started from root dir
-	 *
-	 * @param  string  $path  file path
-	 * @return string
-	 * @author Dmitry (dio) Levashov
-	 **/
-	protected function _path($path) {
-		if (($file = $this->stat($path)) == false) {
-			return '';
-		}
-
-		$parentsIds = $this->getParents($path);
-		$path = '';
-		foreach ($parentsIds as $id) {
-			$dir = $this->stat($id);
-			$path .= $dir['name'].$this->separator;
-		}
-		return $path.$file['name'];
-	}
-
-	/**
-	 * Return array of parents paths (ids)
-	 *
-	 * @param  int   $path  file path (id)
-	 * @return array
-	 * @author Dmitry (dio) Levashov
-	 **/
-	protected function getParents($path) {
-		$parents = array();
 
-		while ($path) {
-			if ($file = $this->stat($path)) {
-				array_unshift($parents, $path);
-				$path = isset($file['phash']) ? $this->decode($file['phash']) : false;
-			}
-		}
-
-		if (count($parents)) {
-			array_pop($parents);
-		}
-		return $parents;
+	/*********************** paths/urls *************************/
+	
+	/**
+	 * Return parent directory path
+	 *
+	 * @param  string  $path  file path
+	 * @return string
+	 * @author Dmitry (dio) Levashov
+	 **/
+	protected function _dirname($path) {
+		return ($stat = $this->stat($path)) ? (!empty($stat['phash']) ? $this->decode($stat['phash']) : $this->root) : false;
 	}
 
 	/**
@@ -396,8 +417,23 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 		return ($stat = $this->stat($path)) ? $stat['name'] : false;
 	}
 
+	/**
+	 * Join dir name and file name and return full path
+	 *
+	 * @param  string  $dir
+	 * @param  string  $name
+	 * @return string
+	 * @author Dmitry (dio) Levashov
+	 **/
+	protected function _joinPath($dir, $name) {
+		$sql = 'SELECT id FROM '.$this->tbf.' WHERE parent_id=\''.$dir.'\' AND name=\''.$this->db->real_escape_string($name).'\'';
 
-	/*********************** paths/urls *************************/
+		if (($res = $this->query($sql)) && ($r = $res->fetch_assoc())) {
+			$this->updateCache($r['id'], $this->_stat($r['id']));
+			return $r['id'];
+		}
+		return -1;
+	}
 	
 	/**
 	 * Return normalized path, this works the same as os.path.normpath() in Python
@@ -409,7 +445,7 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 	protected function _normpath($path) {
 		return $path;
 	}
-
+	
 	/**
 	 * Return file path related to root dir
 	 *
@@ -420,7 +456,7 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 	protected function _relpath($path) {
 		return $path;
 	}
-
+	
 	/**
 	 * Convert path related to root dir into real path
 	 *
@@ -432,6 +468,27 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 		return $path;
 	}
 	
+	/**
+	 * Return fake path started from root dir
+	 *
+	 * @param  string  $path  file path
+	 * @return string
+	 * @author Dmitry (dio) Levashov
+	 **/
+	protected function _path($path) {
+		if (($file = $this->stat($path)) == false) {
+			return '';
+		}
+		
+		$parentsIds = $this->getParents($path);
+		$path = '';
+		foreach ($parentsIds as $id) {
+			$dir = $this->stat($id);
+			$path .= $dir['name'].$this->separator;
+		}
+		return $path.$file['name'];
+	}
+	
 	/**
 	 * Return true if $path is children of $parent
 	 *
@@ -446,6 +503,58 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 			: in_array($parent, $this->getParents($path));
 	}
 	
+	/***************** 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
+	 * - (bool)   read    read permissions. required
+	 * - (bool)   write   write permissions. required
+	 * - (bool)   locked  is object locked. optionally
+	 * - (bool)   hidden  is object hidden. optionally
+	 * - (string) alias   for symlinks - link target path relative to root path. optionally
+	 * - (string) target  for symlinks - link target path. optionally
+	 *
+	 * If file does not exists - returns empty array or false.
+	 *
+	 * @param  string  $path    file path 
+	 * @return array|false
+	 * @author Dmitry (dio) Levashov
+	 **/
+	protected function _stat($path) {
+		$sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, IF(ch.id, 1, 0) AS dirs
+				FROM '.$this->tbf.' AS f 
+				LEFT JOIN '.$this->tbf.' AS ch ON ch.parent_id=f.id AND ch.mime=\'directory\'
+				WHERE f.id=\''.$path.'\'
+				GROUP BY f.id, ch.id';
+
+		$res = $this->query($sql);
+		
+		if ($res) {
+			$stat = $res->fetch_assoc();
+			if ($stat['parent_id']) {
+				$stat['phash'] = $this->encode($stat['parent_id']);
+			} 
+			if ($stat['mime'] == 'directory') {
+				unset($stat['width']);
+				unset($stat['height']);
+				$stat['size'] = 0;
+			} else {
+				if (!$stat['mime']) {
+					unset($stat['mime']);
+				}
+				unset($stat['dirs']);
+			}
+			unset($stat['id']);
+			unset($stat['parent_id']);
+			return $stat;
+			
+		}
+		return array();
+	}
+	
 	/**
 	 * Return true if path is dir and has at least one childs directory
 	 *
@@ -470,6 +579,8 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 		return ($stat = $this->stat($path)) && isset($stat['width']) && isset($stat['height']) ? $stat['width'].'x'.$stat['height'] : '';
 	}
 	
+	/******************** file/dir content *********************/
+		
 	/**
 	 * Return files list in directory.
 	 *
@@ -482,55 +593,7 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 			? $this->dirsCache[$path]
 			: $this->cacheDir($path);
 	}
-	
-	/**
-	 * Cache dir contents
-	 *
-	 * @param  string  $path  dir path
-	 * @return string
-	 * @author Dmitry Levashov
-	 **/
-	protected function cacheDir($path) {
-		$this->dirsCache[$path] = array();
-
-		$sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, IF(ch.id, 1, 0) AS dirs 
-				FROM '.$this->tbf.' AS f 
-				LEFT JOIN '.$this->tbf.' AS ch ON ch.parent_id=f.id AND ch.mime=\'directory\'
-				WHERE f.parent_id=\''.$path.'\'
-				GROUP BY f.id, ch.id';
-
-		$res = $this->query($sql);
-		if ($res) {
-			while ($row = $res->fetch_assoc()) {
-				$id = $row['id'];
-				if ($row['parent_id']) {
-					$row['phash'] = $this->encode($row['parent_id']);
-				}
-
-				if ($row['mime'] == 'directory') {
-					unset($row['width']);
-					unset($row['height']);
-					$row['size'] = 0;
-				} else {
-					unset($row['dirs']);
-				}
-
-				unset($row['id']);
-				unset($row['parent_id']);
-
-
-
-				if (($stat = $this->updateCache($id, $row)) && empty($stat['hidden'])) {
-					$this->dirsCache[$path][] = $id;
-				}
-			}
-		}
-
-		return $this->dirsCache[$path];
-	}
-	
-	/***************** file stat ********************/
-
+		
 	/**
 	 * Open file and return file pointer
 	 *
@@ -543,8 +606,8 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 		$fp = $this->tmbPath
 			? fopen($this->getTempFile($path), 'w+')
 			: $this->tmpfile();
-
-
+		
+		
 		if ($fp) {
 			if (($res = $this->query('SELECT content FROM '.$this->tbf.' WHERE id=\''.$path.'\''))
 			&& ($r = $res->fetch_assoc())) {
@@ -555,10 +618,10 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 				$this->_fclose($fp, $path);
 			}
 		}
-
+		
 		return false;
 	}
-	
+
 	/**
 	 * Close opened file
 	 *
@@ -574,6 +637,8 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 		}
 	}
 	
+	/********************  file/dir manipulations *************************/
+	
 	/**
 	 * Create dir and return created dir path or false on failed
 	 *
@@ -586,42 +651,6 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 		return $this->make($path, $name, 'directory') ? $this->_joinPath($path, $name) : false;
 	}
 	
-	/******************** file/dir content *********************/
-		
-	/**
-	 * Create empty object with required mimetype
-	 *
-	 * @param  string  $path  parent dir path
-	 * @param  string  $name  object name
-	 * @param  string  $mime  mime type
-	 * @return bool
-	 * @author Dmitry (dio) Levashov
-	 **/
-	protected function make($path, $name, $mime) {
-		$sql = 'INSERT INTO %s (`parent_id`, `name`, `size`, `mtime`, `mime`, `content`, `read`, `write`, `locked`, `hidden`, `width`, `height`) VALUES (\'%s\', \'%s\', 0, %d, \'%s\', \'\', \'%d\', \'%d\', \'%d\', \'%d\', 0, 0)';
-		$sql = sprintf($sql, $this->tbf, $path, $this->db->real_escape_string($name), time(), $mime, $this->defaults['read'], $this->defaults['write'], $this->defaults['locked'], $this->defaults['hidden']);
-		// echo $sql;
-		return $this->query($sql) && $this->db->affected_rows > 0;
-	}
-		
-	/**
-	 * Join dir name and file name and return full path
-	 *
-	 * @param  string  $dir
-	 * @param  string  $name
-	 * @return string
-	 * @author Dmitry (dio) Levashov
-	 **/
-	protected function _joinPath($dir, $name) {
-		$sql = 'SELECT id FROM '.$this->tbf.' WHERE parent_id=\''.$dir.'\' AND name=\''.$this->db->real_escape_string($name).'\'';
-
-		if (($res = $this->query($sql)) && ($r = $res->fetch_assoc())) {
-			$this->updateCache($r['id'], $this->_stat($r['id']));
-			return $r['id'];
-		}
-		return -1;
-	}
-
 	/**
 	 * Create file and return it's path or false on failed
 	 *
@@ -633,9 +662,7 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 	protected function _mkfile($path, $name) {
 		return $this->make($path, $name, '') ? $this->_joinPath($path, $name) : false;
 	}
-	
-	/********************  file/dir manipulations *************************/
-	
+
 	/**
 	 * Create symlink. FTP driver does not support symlinks.
 	 *
@@ -669,17 +696,6 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 		return $this->query($sql);
 	}
 
-	/**
-	 * Return parent directory path
-	 *
-	 * @param  string  $path  file path
-	 * @return string
-	 * @author Dmitry (dio) Levashov
-	 **/
-	protected function _dirname($path) {
-		return ($stat = $this->stat($path)) ? (!empty($stat['phash']) ? $this->decode($stat['phash']) : $this->root) : false;
-	}
-	
 	/**
 	 * Move file into another parent dir.
 	 * Return new file path or false.
@@ -696,7 +712,7 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 		$sql = sprintf($sql, $this->tbf, $targetDir, $this->db->real_escape_string($name), $source);
 		return $this->query($sql) && $this->db->affected_rows > 0 ? $source : false;
 	}
-
+		
 	/**
 	 * Remove file
 	 *
@@ -707,7 +723,7 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 	protected function _unlink($path) {
 		return $this->query(sprintf('DELETE FROM %s WHERE id=%d AND mime!=\'directory\' LIMIT 1', $this->tbf, $path)) && $this->db->affected_rows;
 	}
-		
+
 	/**
 	 * Remove dir
 	 *
@@ -730,10 +746,10 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 		elFinder::rewind($fp);
 		$fstat = fstat($fp);
 		$size = $fstat['size'];
-
-
+		
+		
 	}
-
+	
 	/**
 	 * Create new file and write into it from file pointer.
 	 * Return new file path or false on error.
@@ -747,16 +763,16 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 	 **/
 	protected function _save($fp, $dir, $name, $stat) {
 		$this->clearcache();
-
+		
 		$mime = $stat['mime'];
 		$w = !empty($stat['width'])  ? $stat['width']  : 0;
 		$h = !empty($stat['height']) ? $stat['height'] : 0;
-
+		
 		$id = $this->_joinPath($dir, $name);
 		elFinder::rewind($fp);
 		$stat = fstat($fp);
 		$size = $stat['size'];
-
+		
 		if (($tmpfile = tempnam($this->tmpPath, $this->id))) {
 			if (($trgfp = fopen($tmpfile, 'wb')) == false) {
 				unlink($tmpfile);
@@ -766,7 +782,7 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 				}
 				fclose($trgfp);
 				chmod($tmpfile, 0644);
-
+				
 				$sql = $id > 0
 					? 'REPLACE INTO %s (id, parent_id, name, content, size, mtime, mime, width, height) VALUES ('.$id.', %d, \'%s\', LOAD_FILE(\'%s\'), %d, %d, \'%s\', %d, %d)'
 					: 'INSERT INTO %s (parent_id, name, content, size, mtime, mime, width, height) VALUES (%d, \'%s\', LOAD_FILE(\'%s\'), %d, %d, \'%s\', %d, %d)';
@@ -774,49 +790,34 @@ class elFinderVolumeMySQL extends elFinderVolumeDriver {
 
 				$res = $this->query($sql);
 				unlink($tmpfile);
-
+				
 				if ($res) {
 					return $id > 0 ? $id : $this->db->insert_id;
 				}
 			}
 		}
 
-
+		
 		$content = '';
 		elFinder::rewind($fp);
 		while (!feof($fp)) {
 			$content .= fread($fp, 8192);
 		}
-
+		
 		$sql = $id > 0
 			? 'REPLACE INTO %s (id, parent_id, name, content, size, mtime, mime, width, height) VALUES ('.$id.', %d, \'%s\', \'%s\', %d, %d, \'%s\', %d, %d)'
 			: 'INSERT INTO %s (parent_id, name, content, size, mtime, mime, width, height) VALUES (%d, \'%s\', \'%s\', %d, %d, \'%s\', %d, %d)';
 		$sql = sprintf($sql, $this->tbf, $dir, $this->db->real_escape_string($name), $this->db->real_escape_string($content), $size, time(), $mime, $w, $h);
-
+		
 		unset($content);
 
 		if ($this->query($sql)) {
 			return $id > 0 ? $id : $this->db->insert_id;
 		}
-
+		
 		return false;
 	}
 	
-	/**
-	 * Return correct file path for LOAD_FILE method
-	 *
-	 * @param  string $path  file path (id)
-	 * @return string
-	 * @author Troex Nevelin
-	 **/
-	protected function loadFilePath($path) {
-		$realPath = realpath($path);
-		if (DIRECTORY_SEPARATOR == '\\') { // windows
-			$realPath = str_replace('\\', '\\\\', $realPath);
-		}
-		return $this->db->real_escape_string($realPath);
-	}
-	
 	/**
 	 * Get file contents
 	 *

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 472 - 566
src/php/elFinderVolumeOneDrive.class.php


+ 34 - 35
src/php/libs/GdBmp.php

@@ -83,6 +83,40 @@ class elFinderLibGdBmp{
 		}
 		return self::loadFromFile($filename_or_stream_or_binary);
 	}
+	public static function loadFromFile($filename){
+		$fp = fopen($filename, "rb");
+		if ($fp === false){
+			return false;
+		}
+
+		$bmp = self::loadFromStream($fp);
+
+		fclose($fp);
+		return $bmp;
+	}
+
+	public static function loadFromString($str){
+		//data scheme より古いバージョンから対応しているようなので php://memory を使う
+		$fp = fopen("php://memory", "r+b");
+		if ($fp === false){
+			return false;
+		}
+
+		if (fwrite($fp, $str) != strlen($str)){
+			fclose($fp);
+			return false;
+		}
+
+		if (fseek($fp, 0) === -1){
+			fclose($fp);
+			return false;
+		}
+
+		$bmp = self::loadFromStream($fp);
+
+		fclose($fp);
+		return $bmp;
+	}
 
 	public static function loadFromStream($stream){
 		$buf = fread($stream, 14); //2+4+2+2+4
@@ -410,39 +444,4 @@ class elFinderLibGdBmp{
 		}
 		return $img;
 	}
-
-	public static function loadFromString($str){
-		//data scheme より古いバージョンから対応しているようなので php://memory を使う
-		$fp = fopen("php://memory", "r+b");
-		if ($fp === false){
-			return false;
-		}
-
-		if (fwrite($fp, $str) != strlen($str)){
-			fclose($fp);
-			return false;
-		}
-
-		if (fseek($fp, 0) === -1){
-			fclose($fp);
-			return false;
-		}
-
-		$bmp = self::loadFromStream($fp);
-
-		fclose($fp);
-		return $bmp;
-	}
-
-	public static function loadFromFile($filename){
-		$fp = fopen($filename, "rb");
-		if ($fp === false){
-			return false;
-		}
-
-		$bmp = self::loadFromStream($fp);
-
-		fclose($fp);
-		return $bmp;
-	}
 }

+ 27 - 28
src/php/plugins/Normalizer/plugin.php

@@ -99,6 +99,33 @@ class elFinderPluginNormalizer extends elFinderPlugin
 		return true;
 	}
 	
+	public function cmdPostprocess($cmd, &$result, $args, $elfinder) {
+		if ($cmd === 'ls') {
+			if (! empty($result['list']) && ! empty($this->replaced['ls'])) {
+				foreach($result['list'] as $hash => $name) {
+					if ($keys = array_keys($this->replaced['ls'], $name)) {
+						if (count($keys) === 1) {
+							$result['list'][$hash] = $keys[0];
+						} else {
+							$result['list'][$hash] = $keys;
+						}
+					}
+				}
+			}
+		}
+	}
+	
+	// NOTE: $thash is directory hash so it unneed to process at here
+	public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume) {
+		$opts = $this->getCurrentOpts($volume);
+		if (! $opts['enable']) {
+			return false;
+		}
+		
+		$name = $this->normalize($name, $opts);
+		return true;
+	}
+	
 	private function normalize($str, $opts) {
 		if ($opts['nfc'] || $opts['nfkc']) {
 			if (class_exists('Normalizer', false)) {
@@ -136,32 +163,4 @@ class elFinderPluginNormalizer extends elFinderPlugin
 		}
 		return $str;
 	}
-	
-	// NOTE: $thash is directory hash so it unneed to process at here
-
-	public function cmdPostprocess($cmd, &$result, $args, $elfinder) {
-		if ($cmd === 'ls') {
-			if (! empty($result['list']) && ! empty($this->replaced['ls'])) {
-				foreach($result['list'] as $hash => $name) {
-					if ($keys = array_keys($this->replaced['ls'], $name)) {
-						if (count($keys) === 1) {
-							$result['list'][$hash] = $keys[0];
-						} else {
-							$result['list'][$hash] = $keys;
-						}
-					}
-				}
-			}
-		}
-	}
-	
-	public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume) {
-		$opts = $this->getCurrentOpts($volume);
-		if (! $opts['enable']) {
-			return false;
-		}
-
-		$name = $this->normalize($name, $opts);
-		return true;
-	}
 }

+ 7 - 8
src/php/plugins/Sanitizer/plugin.php

@@ -86,13 +86,6 @@ class elFinderPluginSanitizer extends elFinderPlugin
 		return true;
 	}
 	
-	private function sanitizeFileName($filename, $opts, $allows = array()) {
-		$targets = $allows? array_diff($opts['targets'], $allows) : $opts['targets'];
-		return str_replace($targets, $opts['replace'], $filename);
-  	}
-	
-	// NOTE: $thash is directory hash so it unneed to process at here
-
 	public function cmdPostprocess($cmd, &$result, $args, $elfinder) {
 		if ($cmd === 'ls') {
 			if (! empty($result['list']) && ! empty($this->replaced['ls'])) {
@@ -109,13 +102,19 @@ class elFinderPluginSanitizer extends elFinderPlugin
 		}
 	}
 	
+	// NOTE: $thash is directory hash so it unneed to process at here
 	public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume) {
 		$opts = $this->getCurrentOpts($volume);
 		if (! $opts['enable']) {
 			return false;
 		}
-
+	
 		$name = $this->sanitizeFileName($name, $opts);
 		return true;
 	}
+	
+	private function sanitizeFileName($filename, $opts, $allows = array()) {
+		$targets = $allows? array_diff($opts['targets'], $allows) : $opts['targets'];
+		return str_replace($targets, $opts['replace'], $filename);
+  	}
 }

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio