Completed
Push — 2.x ( e1ebe5...b73a75 )
by Naoki
07:32
created
php/elFinderVolumeDriver.class.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Base class for elFinder volume.
4
- * Provide 2 layers:
5
- *  1. Public API (commands)
6
- *  2. abstract fs API
7
- *
8
- * All abstract methods begin with "_"
9
- *
10
- * @author Dmitry (dio) Levashov
11
- * @author Troex Nevelin
12
- * @author Alexey Sukhotin
13
- **/
3
+	 * Base class for elFinder volume.
4
+	 * Provide 2 layers:
5
+	 *  1. Public API (commands)
6
+	 *  2. abstract fs API
7
+	 *
8
+	 * All abstract methods begin with "_"
9
+	 *
10
+	 * @author Dmitry (dio) Levashov
11
+	 * @author Troex Nevelin
12
+	 * @author Alexey Sukhotin
13
+	 **/
14 14
 abstract class elFinderVolumeDriver {
15 15
 	
16 16
 	/**
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 		'mimefile'        => '',
193 193
 		// mime type normalize map : Array '[ext]:[detected mime type]' => '[normalized mime]'
194 194
 		'mimeMap'         => array(
195
-		                     'md:application/x-genesis-rom' => 'text/x-markdown',
196
-		                     'md:text/plain'                => 'text/x-markdown',
197
-		                     'markdown:text/plain'          => 'text/x-markdown',
198
-		                     'css:text/x-asm'               => 'text/css'
199
-		                    ),
195
+							 'md:application/x-genesis-rom' => 'text/x-markdown',
196
+							 'md:text/plain'                => 'text/x-markdown',
197
+							 'markdown:text/plain'          => 'text/x-markdown',
198
+							 'css:text/x-asm'               => 'text/css'
199
+							),
200 200
 		// directory for thumbnails
201 201
 		'tmbPath'         => '.tmb',
202 202
 		// mode to create thumbnails dir
@@ -4043,14 +4043,14 @@  discard block
 block discarded – undo
4043 4043
 	// }
4044 4044
 
4045 4045
 	/**
4046
-	* Find position of first occurrence of string in a string with multibyte support
4047
-	*
4048
-	* @param  string  $haystack  The string being checked.
4049
-	* @param  string  $needle    The string to find in haystack.
4050
-	* @param  int     $offset    The search offset. If it is not specified, 0 is used.
4051
-	* @return int|bool
4052
-	* @author Alexey Sukhotin
4053
-	**/
4046
+	 * Find position of first occurrence of string in a string with multibyte support
4047
+	 *
4048
+	 * @param  string  $haystack  The string being checked.
4049
+	 * @param  string  $needle    The string to find in haystack.
4050
+	 * @param  int     $offset    The search offset. If it is not specified, 0 is used.
4051
+	 * @return int|bool
4052
+	 * @author Alexey Sukhotin
4053
+	 **/
4054 4054
 	protected function stripos($haystack , $needle , $offset = 0) {
4055 4055
 		if (function_exists('mb_stripos')) {
4056 4056
 			return mb_stripos($haystack , $needle , $offset);
Please login to merge, or discard this patch.
Spacing   +130 added lines, -131 removed lines patch added patch discarded remove patch
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		'utf8fix'      => false,
279 279
 		 //                           й                 ё              Й               Ё              Ø         Å
280 280
 		'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"),
281
-		'utf8replace'  => array("\u0439",        "\u0451",       "\u0419",       "\u0401",       "\u00d8", "\u00c5")
281
+		'utf8replace'  => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5")
282 282
 	);
283 283
 
284 284
 	/**
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	 **/
571 571
 	protected function configure() {
572 572
 		// set ARGS
573
-		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET;
573
+		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
574 574
 		// set thumbnails path
575 575
 		$path = $this->options['tmbPath'];
576 576
 		if ($path) {
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		
602 602
 		// check 'statOwner' for command `chmod`
603 603
 		if (empty($this->options['statOwner'])) {
604
-			$this->disabled[] ='chmod';
604
+			$this->disabled[] = 'chmod';
605 605
 		}
606 606
 		
607 607
 		// check 'mimeMap'
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 	 **/
707 707
 	public function mount(array $opts) {
708 708
 		if (!isset($opts['path']) || $opts['path'] === '') {
709
-			return $this->setError('Path undefined.');;
709
+			return $this->setError('Path undefined.'); ;
710 710
 		}
711 711
 		
712 712
 		$this->options = array_merge($this->options, $opts);
@@ -725,14 +725,14 @@  discard block
 block discarded – undo
725 725
 		$argInit = !empty($this->ARGS['init']);
726 726
 		
727 727
 		// session cache
728
-		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
728
+		if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
729 729
 			$_SESSION[elFinder::$sessionCacheKey][$this->id] = array();
730 730
 		}
731 731
 		$this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id];
732 732
 		
733 733
 		// default file attribute
734 734
 		$this->defaults = array(
735
-			'read'    => isset($this->options['defaults']['read'])  ? !!$this->options['defaults']['read']  : true,
735
+			'read'    => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true,
736 736
 			'write'   => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true,
737 737
 			'locked'  => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false,
738 738
 			'hidden'  => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false
@@ -759,8 +759,8 @@  discard block
 block discarded – undo
759 759
 			$this->access = $this->options['accessControl'];
760 760
 		}
761 761
 		
762
-		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y'));
763
-		$this->yesterday = $this->today-86400;
762
+		$this->today     = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
763
+		$this->yesterday = $this->today - 86400;
764 764
 		
765 765
 		// debug($this->attributes);
766 766
 		if (!$this->init()) {
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
 				foreach ($mimecf as $line_num => $line) {
860 860
 					if (!preg_match('/^\s*#/', $line)) {
861 861
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
862
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
862
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
863 863
 							if (!isset(self::$mimetypes[$mime[$i]])) {
864 864
 								self::$mimetypes[$mime[$i]] = $mime[0];
865 865
 							}
@@ -911,8 +911,8 @@  discard block
 block discarded – undo
911 911
 				'read'    => false
912 912
 			));
913 913
 		}
914
-		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1;
915
-		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48;
914
+		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1;
915
+		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48;
916 916
 		$this->URL      = $this->options['URL'];
917 917
 		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) {
918 918
 			$this->URL .= '/';
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 	public function options($hash) {
1054 1054
 		$create = $createext = array();
1055 1055
 		if (isset($this->archivers['create']) && is_array($this->archivers['create'])) {
1056
-			foreach($this->archivers['create'] as $m => $v) {
1056
+			foreach ($this->archivers['create'] as $m => $v) {
1057 1057
 				$create[] = $m;
1058 1058
 				$createext[$m] = $v['ext'];
1059 1059
 			}
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
 				'extract'   => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(),
1074 1074
 				'createext' => $createext
1075 1075
 			),
1076
-			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array()
1076
+			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array()
1077 1077
 		);
1078 1078
 	}
1079 1079
 	
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 	 * @author Naoki Sawada
1086 1086
 	 */
1087 1087
 	public function getOption($name) {
1088
-		return isset($this->options[$name])? $this->options[$name] : null;
1088
+		return isset($this->options[$name]) ? $this->options[$name] : null;
1089 1089
 	}
1090 1090
 	
1091 1091
 	/**
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 	 */
1098 1098
 	public function getOptionsPlugin($name = '') {
1099 1099
 		if ($name) {
1100
-			return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array();
1100
+			return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array();
1101 1101
 		} else {
1102 1102
 			return $this->options['plugin'];
1103 1103
 		}
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 		$file = $this->stat($path);
1228 1228
 		
1229 1229
 		if ($hash === $this->root()) {
1230
-			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array();
1230
+			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array();
1231 1231
 			$file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON
1232 1232
 		}
1233 1233
 		
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 	 * @return array|false
1243 1243
 	 * @author Dmitry (dio) Levashov
1244 1244
 	 **/
1245
-	public function dir($hash, $resolveLink=false) {
1245
+	public function dir($hash, $resolveLink = false) {
1246 1246
 		if (($dir = $this->file($hash)) == false) {
1247 1247
 			return $this->setError(elFinder::ERROR_DIR_NOT_FOUND);
1248 1248
 		}
@@ -1306,14 +1306,14 @@  discard block
 block discarded – undo
1306 1306
 	 * @return array|false
1307 1307
 	 * @author Dmitry (dio) Levashov
1308 1308
 	 **/
1309
-	public function tree($hash='', $deep=0, $exclude='') {
1309
+	public function tree($hash = '', $deep = 0, $exclude = '') {
1310 1310
 		$path = $hash ? $this->decode($hash) : $this->root;
1311 1311
 		
1312 1312
 		if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') {
1313 1313
 			return false;
1314 1314
 		}
1315 1315
 		
1316
-		$dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null);
1316
+		$dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null);
1317 1317
 		array_unshift($dirs, $dir);
1318 1318
 		return $dirs;
1319 1319
 	}
@@ -1543,7 +1543,7 @@  discard block
 block discarded – undo
1543 1543
 	 * @return array|false
1544 1544
 	 * @author Dmitry (dio) Levashov
1545 1545
 	 **/
1546
-	public function duplicate($hash, $suffix='copy') {
1546
+	public function duplicate($hash, $suffix = 'copy') {
1547 1547
 		if ($this->commandDisabled('duplicate')) {
1548 1548
 			return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED);
1549 1549
 		}
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
 		
1620 1620
 		if ($file) { // file exists
1621 1621
 			// check POST data `overwrite` for 3rd party uploader
1622
-			$overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite'];
1622
+			$overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite'];
1623 1623
 			if ($overwrite) {
1624 1624
 				if (!$file['write']) {
1625 1625
 					return $this->setError(elFinder::ERROR_PERM_DENIED);
@@ -1690,7 +1690,7 @@  discard block
 block discarded – undo
1690 1690
 		if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) {
1691 1691
 			return $rmSrc
1692 1692
 				? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test))
1693
-				: $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1693
+				: $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1694 1694
 		}
1695 1695
 
1696 1696
 		$test = $this->joinPathCE($destination, $name);
@@ -1853,7 +1853,7 @@  discard block
 block discarded – undo
1853 1853
 			return $this->setError(elFinder::ERROR_PERM_DENIED);
1854 1854
 		}
1855 1855
 		$this->clearcache();
1856
-		$this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir;
1856
+		$this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir;
1857 1857
 		
1858 1858
 		if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) {
1859 1859
 			if (is_array($path)) {
@@ -1911,9 +1911,9 @@  discard block
 block discarded – undo
1911 1911
 		if ($name === '') {
1912 1912
 			$name = count($files) == 1 ? $files[0] : 'Archive';
1913 1913
 		} else {
1914
-			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name));
1914
+			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name));
1915 1915
 		}
1916
-		$name .='.' . $archiver['ext'];
1916
+		$name .= '.'.$archiver['ext'];
1917 1917
 		$name = $this->uniqueName($dir, $name, '');
1918 1918
 		$this->clearcache();
1919 1919
 		return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false;
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
 		
1950 1950
 		$path = $this->decode($hash);
1951 1951
 		
1952
-		$work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path);
1952
+		$work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path);
1953 1953
 
1954 1954
 		if (!$work_path || !is_writable($work_path)) {
1955 1955
 			if ($work_path && $path !== $work_path && is_file($work_path)) {
@@ -1964,7 +1964,7 @@  discard block
 block discarded – undo
1964 1964
 			}
1965 1965
 		}
1966 1966
 
1967
-		switch($mode) {
1967
+		switch ($mode) {
1968 1968
 			
1969 1969
 			case 'propresize':
1970 1970
 				$result = $this->imgResize($work_path, $width, $height, true, true);
@@ -2060,7 +2060,7 @@  discard block
 block discarded – undo
2060 2060
 		}
2061 2061
 		return ($q === '' || $this->commandDisabled('search'))
2062 2062
 			? array()
2063
-			: $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes);
2063
+			: $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes);
2064 2064
 	}
2065 2065
 	
2066 2066
 	/**
@@ -2129,9 +2129,9 @@  discard block
 block discarded – undo
2129 2129
 		$path = ltrim($path, $this->separator);
2130 2130
 		$dirs = explode($this->separator, $path);
2131 2131
 		array_pop($dirs);
2132
-		foreach($dirs as $dir) {
2132
+		foreach ($dirs as $dir) {
2133 2133
 			$targetPath = $this->joinPathCE($base, $dir);
2134
-			if (! $_realpath = $this->realpath($this->encode($targetPath))) {
2134
+			if (!$_realpath = $this->realpath($this->encode($targetPath))) {
2135 2135
 				if ($stat = $this->mkdir($targetHash, $dir)) {
2136 2136
 					$result['added'][] = $stat;
2137 2137
 					$targetHash = $stat['hash'];
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
 	 * @author Naoki Sawada
2199 2199
 	 **/
2200 2200
 	protected function dirnameCE($path) {
2201
-		return (!$this->encoding)? $this->_dirname($path) :	$this->convEncOut($this->_dirname($this->convEncIn($path)));
2201
+		return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path)));
2202 2202
 	}
2203 2203
 	
2204 2204
 	/**
@@ -2209,7 +2209,7 @@  discard block
 block discarded – undo
2209 2209
 	 * @author Naoki Sawada
2210 2210
 	 **/
2211 2211
 	protected function basenameCE($path) {
2212
-		return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2212
+		return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2213 2213
 	}
2214 2214
 	
2215 2215
 	/**
@@ -2222,7 +2222,7 @@  discard block
 block discarded – undo
2222 2222
 	 * @author Naoki Sawada
2223 2223
 	 **/
2224 2224
 	protected function joinPathCE($dir, $name) {
2225
-		return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2225
+		return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2226 2226
 	}
2227 2227
 	
2228 2228
 	/**
@@ -2233,7 +2233,7 @@  discard block
 block discarded – undo
2233 2233
 	 * @author Naoki Sawada
2234 2234
 	 **/
2235 2235
 	protected function normpathCE($path) {
2236
-		return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2236
+		return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2237 2237
 	}
2238 2238
 	
2239 2239
 	/**
@@ -2244,7 +2244,7 @@  discard block
 block discarded – undo
2244 2244
 	 * @author Naoki Sawada
2245 2245
 	 **/
2246 2246
 	protected function relpathCE($path) {
2247
-		return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2247
+		return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2248 2248
 	}
2249 2249
 	
2250 2250
 	/**
@@ -2255,7 +2255,7 @@  discard block
 block discarded – undo
2255 2255
 	 * @author Naoki Sawada
2256 2256
 	 **/
2257 2257
 	protected function abspathCE($path) {
2258
-		return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path)));
2258
+		return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path)));
2259 2259
 	}
2260 2260
 	
2261 2261
 	/**
@@ -2267,7 +2267,7 @@  discard block
 block discarded – undo
2267 2267
 	 * @author Naoki Sawada
2268 2268
 	 **/
2269 2269
 	protected function inpathCE($path, $parent) {
2270
-		return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2270
+		return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2271 2271
 	}
2272 2272
 	
2273 2273
 	/**
@@ -2278,8 +2278,8 @@  discard block
 block discarded – undo
2278 2278
 	 * @return resource|false
2279 2279
 	 * @author Naoki Sawada
2280 2280
 	 **/
2281
-	protected function fopenCE($path, $mode='rb') {
2282
-		return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2281
+	protected function fopenCE($path, $mode = 'rb') {
2282
+		return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2283 2283
 	}
2284 2284
 	
2285 2285
 	/**
@@ -2290,8 +2290,8 @@  discard block
 block discarded – undo
2290 2290
 	 * @return bool
2291 2291
 	 * @author Naoki Sawada
2292 2292
 	 **/
2293
-	protected function fcloseCE($fp, $path='') {
2294
-		return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2293
+	protected function fcloseCE($fp, $path = '') {
2294
+		return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2295 2295
 	}
2296 2296
 	
2297 2297
 	/**
@@ -2306,7 +2306,7 @@  discard block
 block discarded – undo
2306 2306
 	 * @author Naoki Sawada
2307 2307
 	 **/
2308 2308
 	protected function saveCE($fp, $dir, $name, $stat) {
2309
-		return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2309
+		return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2310 2310
 	}
2311 2311
 	
2312 2312
 	/**
@@ -2318,7 +2318,7 @@  discard block
 block discarded – undo
2318 2318
 	 **/
2319 2319
 	protected function subdirsCE($path) {
2320 2320
 		if (!isset($this->subdirsCache[$path])) {
2321
-			$this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2321
+			$this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2322 2322
 		}
2323 2323
 		return $this->subdirsCache[$path];
2324 2324
 	}
@@ -2331,7 +2331,7 @@  discard block
 block discarded – undo
2331 2331
 	 * @author Naoki Sawada
2332 2332
 	 **/
2333 2333
 	protected function scandirCE($path) {
2334
-		return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2334
+		return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2335 2335
 	}
2336 2336
 	
2337 2337
 	/**
@@ -2344,7 +2344,7 @@  discard block
 block discarded – undo
2344 2344
 	 * @author Naoki Sawada
2345 2345
 	 **/
2346 2346
 	protected function symlinkCE($source, $targetDir, $name) {
2347
-		return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2347
+		return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2348 2348
 	}
2349 2349
 	
2350 2350
 	/***************** paths *******************/
@@ -2363,7 +2363,7 @@  discard block
 block discarded – undo
2363 2363
 			// cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root
2364 2364
 			$p = $this->relpathCE($path);
2365 2365
 			// if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt
2366
-			if ($p === '')	{
2366
+			if ($p === '') {
2367 2367
 				$p = DIRECTORY_SEPARATOR;
2368 2368
 			}
2369 2369
 
@@ -2396,7 +2396,7 @@  discard block
 block discarded – undo
2396 2396
 			// TODO uncrypt hash and return path
2397 2397
 			$path = $this->uncrypt($h); 
2398 2398
 			// append ROOT to path after it was cut in encode
2399
-			return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2399
+			return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2400 2400
 		}
2401 2401
 	}
2402 2402
 	
@@ -2453,21 +2453,21 @@  discard block
 block discarded – undo
2453 2453
 	 * @author Dmitry (dio) Levashov
2454 2454
 	 **/
2455 2455
 	public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) {
2456
-		$ext  = '';
2456
+		$ext = '';
2457 2457
 
2458 2458
 		if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
2459 2459
 			$ext  = '.'.$m[1];
2460
-			$name = substr($name, 0,  strlen($name)-strlen($m[0]));
2460
+			$name = substr($name, 0, strlen($name) - strlen($m[0]));
2461 2461
 		} 
2462 2462
 		
2463 2463
 		if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) {
2464
-			$i    = (int)$m[2];
2465
-			$name = substr($name, 0, strlen($name)-strlen($m[2]));
2464
+			$i    = (int) $m[2];
2465
+			$name = substr($name, 0, strlen($name) - strlen($m[2]));
2466 2466
 		} else {
2467 2467
 			$i     = $start;
2468 2468
 			$name .= $suffix;
2469 2469
 		}
2470
-		$max = $i+100000;
2470
+		$max = $i + 100000;
2471 2471
 
2472 2472
 		while ($i <= $max) {
2473 2473
 			$n = $name.($i > 0 ? $i : '').$ext;
@@ -2491,7 +2491,7 @@  discard block
 block discarded – undo
2491 2491
 	 * @author Naoki Sawada
2492 2492
 	 */
2493 2493
 	public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') {
2494
-		return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2494
+		return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2495 2495
 	}
2496 2496
 	
2497 2497
 	/**
@@ -2504,7 +2504,7 @@  discard block
 block discarded – undo
2504 2504
 	 * @author Naoki Sawada
2505 2505
 	 */
2506 2506
 	public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') {
2507
-		return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2507
+		return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2508 2508
 	}
2509 2509
 	
2510 2510
 	/**
@@ -2524,7 +2524,7 @@  discard block
 block discarded – undo
2524 2524
 			}
2525 2525
 			if (is_array($var)) {
2526 2526
 				$_ret = array();
2527
-				foreach($var as $_k => $_v) {
2527
+				foreach ($var as $_k => $_v) {
2528 2528
 					$_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_');
2529 2529
 				}
2530 2530
 				$var = $_ret;
@@ -2536,7 +2536,7 @@  discard block
 block discarded – undo
2536 2536
 						$_var = str_replace('?', $unknown, $_var);
2537 2537
 					}
2538 2538
 				}
2539
-				if  ($_var !== false) {
2539
+				if ($_var !== false) {
2540 2540
 					$var = $_var;
2541 2541
 				}
2542 2542
 			}
@@ -2563,7 +2563,7 @@  discard block
 block discarded – undo
2563 2563
 		
2564 2564
 		$key = '';
2565 2565
 		if ($path !== '') {
2566
-			$key = $this->id . '#' . $path;
2566
+			$key = $this->id.'#'.$path;
2567 2567
 			if (isset($cache[$key])) {
2568 2568
 				return $cache[$key];
2569 2569
 			}
@@ -2595,7 +2595,7 @@  discard block
 block discarded – undo
2595 2595
 		if ($work = $this->getTempFile()) {
2596 2596
 			if ($wfp = fopen($work, 'wb')) {
2597 2597
 				if ($fp = $this->_fopen($path)) {
2598
-					while(!feof($fp)) {
2598
+					while (!feof($fp)) {
2599 2599
 						fwrite($wfp, fread($fp, 8192));
2600 2600
 					}
2601 2601
 					$this->_fclose($fp, $path);
@@ -2639,7 +2639,7 @@  discard block
 block discarded – undo
2639 2639
 			@set_time_limit(30);
2640 2640
 			$stat = $this->stat($this->convEncOut($p));
2641 2641
 			$this->convEncIn();
2642
-			($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p);
2642
+			($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p);
2643 2643
 		}
2644 2644
 		return $this->_rmdir($localpath);
2645 2645
 	}
@@ -2656,7 +2656,7 @@  discard block
 block discarded – undo
2656 2656
 	 * @return bool
2657 2657
 	 * @author Dmitry (dio) Levashov
2658 2658
 	 **/
2659
-	protected function attr($path, $name, $val=null, $isDir=null) {
2659
+	protected function attr($path, $name, $val = null, $isDir = null) {
2660 2660
 		if (!isset($this->defaults[$name])) {
2661 2661
 			return false;
2662 2662
 		}
@@ -2688,7 +2688,7 @@  discard block
 block discarded – undo
2688 2688
 			} 
2689 2689
 		}
2690 2690
 		
2691
-		return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm;
2691
+		return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm;
2692 2692
 	}
2693 2693
 	
2694 2694
 	/**
@@ -2732,7 +2732,7 @@  discard block
 block discarded – undo
2732 2732
 	protected function allowPutMime($mime) {
2733 2733
 		// logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order
2734 2734
 		$allow  = $this->mimeAccepted($mime, $this->uploadAllow, null);
2735
-		$deny   = $this->mimeAccepted($mime, $this->uploadDeny,  null);
2735
+		$deny   = $this->mimeAccepted($mime, $this->uploadDeny, null);
2736 2736
 		$res = true; // default to allow
2737 2737
 		if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny'
2738 2738
 			$res = false; // default is deny
@@ -2803,10 +2803,10 @@  discard block
 block discarded – undo
2803 2803
 			if ($this->rootName) {
2804 2804
 				$stat['name'] = $this->rootName;
2805 2805
 			}
2806
-			if (! empty($this->options['icon'])) {
2806
+			if (!empty($this->options['icon'])) {
2807 2807
 				$stat['icon'] = $this->options['icon'];
2808 2808
 			}
2809
-			if (! empty($this->options['rootCssClass'])) {
2809
+			if (!empty($this->options['rootCssClass'])) {
2810 2810
 				$stat['csscls'] = $this->options['rootCssClass'];
2811 2811
 			}
2812 2812
 		} else {
@@ -2850,7 +2850,7 @@  discard block
 block discarded – undo
2850 2850
 			// lock when parent directory is not writable
2851 2851
 			if (!isset($stat['locked'])) {
2852 2852
 				$parent = $this->dirnameCE($path);
2853
-				$pstat = isset($this->cache[$parent])? $this->cache[$parent] : array();
2853
+				$pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array();
2854 2854
 				if (isset($pstat['write']) && !$pstat['write']) {
2855 2855
 					$stat['locked'] = true;
2856 2856
 				}
@@ -2908,7 +2908,7 @@  discard block
 block discarded – undo
2908 2908
 			}
2909 2909
 			if (!isset($stat['url']) && $this->URL && $this->encoding) {
2910 2910
 				$_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1));
2911
-				$stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN')? $_path : $this->convEncIn($_path, true)));
2911
+				$stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN') ? $_path : $this->convEncIn($_path, true)));
2912 2912
 			}
2913 2913
 		} else {
2914 2914
 			if ($isDir) {
@@ -3151,7 +3151,7 @@  discard block
 block discarded – undo
3151 3151
 	 * @return array
3152 3152
 	 * @author Dmitry (dio) Levashov
3153 3153
 	 **/
3154
-	protected function gettree($path, $deep, $exclude='') {
3154
+	protected function gettree($path, $deep, $exclude = '') {
3155 3155
 		$dirs = array();
3156 3156
 		
3157 3157
 		!isset($this->dirsCache[$path]) && $this->cacheDir($path);
@@ -3162,7 +3162,7 @@  discard block
 block discarded – undo
3162 3162
 			if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') {
3163 3163
 				$dirs[] = $stat;
3164 3164
 				if ($deep > 0 && !empty($stat['dirs'])) {
3165
-					$dirs = array_merge($dirs, $this->gettree($p, $deep-1));
3165
+					$dirs = array_merge($dirs, $this->gettree($p, $deep - 1));
3166 3166
 				}
3167 3167
 			}
3168 3168
 		}
@@ -3182,7 +3182,7 @@  discard block
 block discarded – undo
3182 3182
 	protected function doSearch($path, $q, $mimes) {
3183 3183
 		$result = array();
3184 3184
 
3185
-		foreach($this->scandirCE($path) as $p) {
3185
+		foreach ($this->scandirCE($path) as $p) {
3186 3186
 			@set_time_limit(30);
3187 3187
 			$stat = $this->stat($p);
3188 3188
 
@@ -3203,7 +3203,7 @@  discard block
 block discarded – undo
3203 3203
 					if ($this->encoding) {
3204 3204
 						$path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true)));
3205 3205
 					}
3206
-					$stat['url'] = $this->URL . $path;
3206
+					$stat['url'] = $this->URL.$path;
3207 3207
 				}
3208 3208
 				
3209 3209
 				$result[] = $stat;
@@ -3237,7 +3237,7 @@  discard block
 block discarded – undo
3237 3237
 			if (!$this->inpathCE($target, $this->root)) {
3238 3238
 				return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK);
3239 3239
 			}
3240
-			$stat   = $this->stat($target);
3240
+			$stat = $this->stat($target);
3241 3241
 			$this->clearcache();
3242 3242
 			return $stat && $this->symlinkCE($target, $dst, $name)
3243 3243
 				? $this->joinPathCE($dst, $name)
@@ -3518,15 +3518,15 @@  discard block
 block discarded – undo
3518 3518
 		}
3519 3519
 
3520 3520
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
3521
-		if ($s[0] <= $tmbSize && $s[1]	<= $tmbSize) {
3522
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3521
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
3522
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3523 3523
 		} else {
3524 3524
 		
3525 3525
 			if ($this->options['tmbCrop']) {
3526 3526
 		
3527 3527
 				$result = $tmb;
3528 3528
 				/* Resize and crop if image bigger than thumbnail */
3529
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3529
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3530 3530
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
3531 3531
 				}
3532 3532
 		
@@ -3543,7 +3543,7 @@  discard block
 block discarded – undo
3543 3543
 			}
3544 3544
 		
3545 3545
 			if ($result) {
3546
-				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3546
+				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3547 3547
 			}
3548 3548
 		}
3549 3549
 		
@@ -3584,18 +3584,18 @@  discard block
 block discarded – undo
3584 3584
 			/* Resizing by biggest side */
3585 3585
 			if ($resizeByBiggerSide) {
3586 3586
 				if ($orig_w > $orig_h) {
3587
-					$size_h = round($orig_h * $width / $orig_w);
3587
+					$size_h = round($orig_h*$width/$orig_w);
3588 3588
 					$size_w = $width;
3589 3589
 				} else {
3590
-					$size_w = round($orig_w * $height / $orig_h);
3590
+					$size_w = round($orig_w*$height/$orig_h);
3591 3591
 					$size_h = $height;
3592 3592
 				}
3593 3593
 			} else {
3594 3594
 				if ($orig_w > $orig_h) {
3595
-					$size_w = round($orig_w * $height / $orig_h);
3595
+					$size_w = round($orig_w*$height/$orig_h);
3596 3596
 					$size_h = $height;
3597 3597
 				} else {
3598
-					$size_h = round($orig_h * $width / $orig_w);
3598
+					$size_h = round($orig_h*$width/$orig_w);
3599 3599
 					$size_w = $width;
3600 3600
 				}
3601 3601
 			}
@@ -3613,7 +3613,7 @@  discard block
 block discarded – undo
3613 3613
 				// Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb
3614 3614
 				// resize bench: http://app-mgng.rhcloud.com/9
3615 3615
 				// resize sample: http://www.dylanbeattie.net/magick/filters/result.html
3616
-				$filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3616
+				$filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3617 3617
 				
3618 3618
 				$ani = ($img->getNumberImages() > 1);
3619 3619
 				if ($ani && is_null($destformat)) {
@@ -3638,11 +3638,11 @@  discard block
 block discarded – undo
3638 3638
 				break;
3639 3639
 
3640 3640
 			case 'gd':
3641
-				$img = self::gdImageCreate($path,$s['mime']);
3641
+				$img = self::gdImageCreate($path, $s['mime']);
3642 3642
 
3643
-				if ($img &&  false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3643
+				if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3644 3644
 				
3645
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3645
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3646 3646
 					
3647 3647
 					if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) {
3648 3648
 						return false;
@@ -3718,11 +3718,11 @@  discard block
 block discarded – undo
3718 3718
 				break;
3719 3719
 
3720 3720
 			case 'gd':
3721
-				$img = self::gdImageCreate($path,$s['mime']);
3721
+				$img = self::gdImageCreate($path, $s['mime']);
3722 3722
 
3723
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3723
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3724 3724
 					
3725
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3725
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3726 3726
 
3727 3727
 					$size_w = $width;
3728 3728
 					$size_h = $height;
@@ -3772,8 +3772,8 @@  discard block
 block discarded – undo
3772 3772
 		$result = false;
3773 3773
 
3774 3774
 		/* Coordinates for image over square aligning */
3775
-		$y = ceil(abs($height - $s[1]) / 2); 
3776
-		$x = ceil(abs($width - $s[0]) / 2);
3775
+		$y = ceil(abs($height - $s[1])/2); 
3776
+		$x = ceil(abs($width - $s[0])/2);
3777 3777
 
3778 3778
 		switch ($this->imgLib) {
3779 3779
 			case 'imagick':
@@ -3793,7 +3793,7 @@  discard block
 block discarded – undo
3793 3793
 						$gif->newImage($width, $height, new ImagickPixel($bgcolor));
3794 3794
 						$gif->setImageColorspace($img->getImageColorspace());
3795 3795
 						$gif->setImageFormat('gif');
3796
-						$gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3796
+						$gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3797 3797
 						$gif->setImageDelay($img->getImageDelay());
3798 3798
 						$gif->setImageIterations($img->getImageIterations());
3799 3799
 						$img1->addImage($gif);
@@ -3809,7 +3809,7 @@  discard block
 block discarded – undo
3809 3809
 					$img1->newImage($width, $height, new ImagickPixel($bgcolor));
3810 3810
 					$img1->setImageColorspace($img->getImageColorspace());
3811 3811
 					$img1->setImageFormat($destformat != null ? $destformat : $img->getFormat());
3812
-					$img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3812
+					$img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3813 3813
 					$result = $img1->writeImage($path);
3814 3814
 				}
3815 3815
 				
@@ -3820,11 +3820,11 @@  discard block
 block discarded – undo
3820 3820
 				break;
3821 3821
 
3822 3822
 			case 'gd':
3823
-				$img = self::gdImageCreate($path,$s['mime']);
3823
+				$img = self::gdImageCreate($path, $s['mime']);
3824 3824
 
3825
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3825
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3826 3826
 
3827
-					self::gdImageBackground($tmp,$bgcolor);
3827
+					self::gdImageBackground($tmp, $bgcolor);
3828 3828
 
3829 3829
 					if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) {
3830 3830
 						return false;
@@ -3855,15 +3855,15 @@  discard block
 block discarded – undo
3855 3855
 	 * @author Troex Nevelin
3856 3856
 	 **/
3857 3857
 	protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null) {
3858
-		if (($s = @getimagesize($path)) == false || $degree % 360 === 0) {
3858
+		if (($s = @getimagesize($path)) == false || $degree%360 === 0) {
3859 3859
 			return false;
3860 3860
 		}
3861 3861
 
3862 3862
 		$result = false;
3863 3863
 
3864 3864
 		// try lossless rotate
3865
-		if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3866
-			$count = ($degree / 90) % 4;
3865
+		if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3866
+			$count = ($degree/90)%4;
3867 3867
 			$exiftran = array(
3868 3868
 				1 => '-9',
3869 3869
 				2 => '-1',
@@ -3879,7 +3879,7 @@  discard block
 block discarded – undo
3879 3879
 				'exiftran -i '.$exiftran[$count].' '.$path,
3880 3880
 				'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath
3881 3881
 			);
3882
-			foreach($cmds as $cmd) {
3882
+			foreach ($cmds as $cmd) {
3883 3883
 				if ($this->procExec($cmd) === 0) {
3884 3884
 					$result = true;
3885 3885
 					break;
@@ -3915,12 +3915,12 @@  discard block
 block discarded – undo
3915 3915
 				break;
3916 3916
 
3917 3917
 			case 'gd':
3918
-				$img = self::gdImageCreate($path,$s['mime']);
3918
+				$img = self::gdImageCreate($path, $s['mime']);
3919 3919
 
3920 3920
 				$degree = 360 - $degree;
3921 3921
 				list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
3922 3922
 				$bgcolor = imagecolorallocate($img, $r, $g, $b);
3923
-				$tmp = imageRotate($img, $degree, (int)$bgcolor);
3923
+				$tmp = imageRotate($img, $degree, (int) $bgcolor);
3924 3924
 
3925 3925
 				$result = self::gdImage($tmp, $path, $destformat, $s['mime']);
3926 3926
 
@@ -3945,11 +3945,11 @@  discard block
 block discarded – undo
3945 3945
 	 * @return int     exit code
3946 3946
 	 * @author Alexey Sukhotin
3947 3947
 	 **/
3948
-	protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) {
3948
+	protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) {
3949 3949
 
3950 3950
 		$descriptorspec = array(
3951
-			0 => array("pipe", "r"),  // stdin
3952
-			1 => array("pipe", "w"),  // stdout
3951
+			0 => array("pipe", "r"), // stdin
3952
+			1 => array("pipe", "w"), // stdout
3953 3953
 			2 => array("pipe", "w")   // stderr
3954 3954
 		);
3955 3955
 
@@ -4006,8 +4006,8 @@  discard block
 block discarded – undo
4006 4006
 	 * @param string $mime
4007 4007
 	 * @return gd image resource identifier
4008 4008
 	 */
4009
-	protected function gdImageCreate($path,$mime){
4010
-		switch($mime){
4009
+	protected function gdImageCreate($path, $mime) {
4010
+		switch ($mime) {
4011 4011
 			case 'image/jpeg':
4012 4012
 			return imagecreatefromjpeg($path);
4013 4013
 
@@ -4031,7 +4031,7 @@  discard block
 block discarded – undo
4031 4031
 	 * @param string $destformat The Image type to use for $filename
4032 4032
 	 * @param string $mime The original image mime type
4033 4033
 	 */
4034
-	protected function gdImage($image, $filename, $destformat, $mime ){
4034
+	protected function gdImage($image, $filename, $destformat, $mime) {
4035 4035
 
4036 4036
 		if ($destformat == 'jpg' || ($destformat == null && $mime == 'image/jpeg')) {
4037 4037
 			return imagejpeg($image, $filename, 100);
@@ -4050,13 +4050,13 @@  discard block
 block discarded – undo
4050 4050
 	 * @param resource $image gd image resource
4051 4051
 	 * @param string $bgcolor background color in #rrggbb format
4052 4052
 	 */
4053
-	protected function gdImageBackground($image, $bgcolor){
4053
+	protected function gdImageBackground($image, $bgcolor) {
4054 4054
 
4055
-		if( $bgcolor == 'transparent' ){
4056
-			imagesavealpha($image,true);
4055
+		if ($bgcolor == 'transparent') {
4056
+			imagesavealpha($image, true);
4057 4057
 			$bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127);
4058 4058
 
4059
-		}else{
4059
+		} else {
4060 4060
 			list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4061 4061
 			$bgcolor1 = imagecolorallocate($image, $r, $g, $b);
4062 4062
 		}
@@ -4094,13 +4094,13 @@  discard block
 block discarded – undo
4094 4094
 	* @return int|bool
4095 4095
 	* @author Alexey Sukhotin
4096 4096
 	**/
4097
-	protected function stripos($haystack , $needle , $offset = 0) {
4097
+	protected function stripos($haystack, $needle, $offset = 0) {
4098 4098
 		if (function_exists('mb_stripos')) {
4099
-			return mb_stripos($haystack , $needle , $offset);
4099
+			return mb_stripos($haystack, $needle, $offset);
4100 4100
 		} else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) {
4101 4101
 			return mb_strpos(mb_strtolower($haystack), mb_strtolower($needle), $offset);
4102 4102
 		} 
4103
-		return stripos($haystack , $needle , $offset);
4103
+		return stripos($haystack, $needle, $offset);
4104 4104
 	}
4105 4105
 
4106 4106
 	/**
@@ -4150,22 +4150,22 @@  discard block
 block discarded – undo
4150 4150
 			unset($o);
4151 4151
 			$this->procExec('zip -v', $o, $c);
4152 4152
 			if ($c == 0) {
4153
-				$arcs['create']['application/zip']  = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4153
+				$arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4154 4154
 			}
4155 4155
 			unset($o);
4156 4156
 			$this->procExec('unzip --help', $o, $c);
4157 4157
 			if ($c == 0) {
4158
-				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '',  'ext' => 'zip');
4158
+				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip');
4159 4159
 			}
4160 4160
 			unset($o);
4161 4161
 			$this->procExec('rar --version', $o, $c);
4162 4162
 			if ($c == 0 || $c == 7) {
4163 4163
 				$arcs['create']['application/x-rar']  = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar');
4164
-				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y',    'ext' => 'rar');
4164
+				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar');
4165 4165
 			} else {
4166 4166
 				unset($o);
4167 4167
 				$test = $this->procExec('unrar', $o, $c);
4168
-				if ($c==0 || $c == 7) {
4168
+				if ($c == 0 || $c == 7) {
4169 4169
 					$arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar');
4170 4170
 				}
4171 4171
 			}
@@ -4187,7 +4187,7 @@  discard block
 block discarded – undo
4187 4187
 				if (empty($arcs['extract']['application/x-tar'])) {
4188 4188
 					$arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar');
4189 4189
 				}
4190
-			} else if (substr(PHP_OS,0,3) === 'WIN') {
4190
+			} else if (substr(PHP_OS, 0, 3) === 'WIN') {
4191 4191
 				// check `7z` for Windows server.
4192 4192
 				unset($o);
4193 4193
 				$this->procExec('7z', $o, $c);
@@ -4241,22 +4241,22 @@  discard block
 block discarded – undo
4241 4241
 
4242 4242
 		// normalize `/../`
4243 4243
 		$normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#';
4244
-		while(preg_match($normreg, $path)) {
4244
+		while (preg_match($normreg, $path)) {
4245 4245
 			$path = preg_replace($normreg, '$1', $path);
4246 4246
 		}
4247 4247
 		
4248 4248
 		// 'Here'
4249
-		if ($path === '' || $path === '.' . $separator) return $base;
4249
+		if ($path === '' || $path === '.'.$separator) return $base;
4250 4250
 		
4251 4251
 		// Absolute path
4252 4252
 		if ($path[0] === $separator || strpos($path, $systemroot) === 0) {
4253 4253
 			return $path;
4254 4254
 		}
4255 4255
 		
4256
-		$preg_separator = '#' . $sepquoted . '#';
4256
+		$preg_separator = '#'.$sepquoted.'#';
4257 4257
 		
4258 4258
 		// Relative path from 'Here'
4259
-		if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) {
4259
+		if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) {
4260 4260
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4261 4261
 			if ($arrn[0] !== '.') {
4262 4262
 				array_unshift($arrn, '.');
@@ -4270,12 +4270,11 @@  discard block
 block discarded – undo
4270 4270
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4271 4271
 			$arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY);
4272 4272
 		
4273
-			while (! empty($arrn) && $arrn[0] === '..') {
4273
+			while (!empty($arrn) && $arrn[0] === '..') {
4274 4274
 				array_shift($arrn);
4275 4275
 				array_pop($arrp);
4276 4276
 			}
4277
-			$path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) :
4278
-				(! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot);
4277
+			$path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot);
4279 4278
 		}
4280 4279
 		
4281 4280
 		return $path;
@@ -4293,7 +4292,7 @@  discard block
 block discarded – undo
4293 4292
 			@chmod($dir, 0777);
4294 4293
 			foreach (array_diff(scandir($dir), array('.', '..')) as $file) {
4295 4294
 				@set_time_limit(30);
4296
-				$path = $dir . DIRECTORY_SEPARATOR . $file;
4295
+				$path = $dir.DIRECTORY_SEPARATOR.$file;
4297 4296
 				if (!is_link($dir) && is_dir($path)) {
4298 4297
 					$this->rmdirRecursive($path);
4299 4298
 				} else {
@@ -4380,22 +4379,22 @@  discard block
 block discarded – undo
4380 4379
 		try {
4381 4380
 			if ($start = is_string($zipPath)) {
4382 4381
 				$zip = new ZipArchive();
4383
-				if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) {
4382
+				if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) {
4384 4383
 					$zip = false;
4385 4384
 				}
4386 4385
 			} else {
4387 4386
 				$zip = $zipPath;
4388 4387
 			}
4389 4388
 			if ($zip) {
4390
-				foreach($files as $file) {
4391
-					$path = $dir . DIRECTORY_SEPARATOR . $file;
4389
+				foreach ($files as $file) {
4390
+					$path = $dir.DIRECTORY_SEPARATOR.$file;
4392 4391
 					if (is_dir($path)) {
4393 4392
 						$zip->addEmptyDir($file);
4394 4393
 						$_files = array();
4395 4394
 						if ($handle = opendir($path)) {
4396 4395
 							while (false !== ($entry = readdir($handle))) {
4397 4396
 								if ($entry !== "." && $entry !== "..") {
4398
-									$_files[] = $file . DIRECTORY_SEPARATOR . $entry;
4397
+									$_files[] = $file.DIRECTORY_SEPARATOR.$entry;
4399 4398
 								}
4400 4399
 							}
4401 4400
 							closedir($handle);
@@ -4580,7 +4579,7 @@  discard block
 block discarded – undo
4580 4579
 	 * @return resource|false
4581 4580
 	 * @author Dmitry (dio) Levashov
4582 4581
 	 **/
4583
-	abstract protected function _fopen($path, $mode="rb");
4582
+	abstract protected function _fopen($path, $mode = "rb");
4584 4583
 	
4585 4584
 	/**
4586 4585
 	 * Close opened file
@@ -4590,7 +4589,7 @@  discard block
 block discarded – undo
4590 4589
 	 * @return bool
4591 4590
 	 * @author Dmitry (dio) Levashov
4592 4591
 	 **/
4593
-	abstract protected function _fclose($fp, $path='');
4592
+	abstract protected function _fclose($fp, $path = '');
4594 4593
 	
4595 4594
 	/********************  file/dir manipulations *************************/
4596 4595
 	
Please login to merge, or discard this patch.
php/elFinderVolumeLocalFileSystem.class.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 	 * @author Dmitry (dio) Levashov
33 33
 	 **/
34 34
 	public function __construct() {
35
-		$this->options['alias']    = '';              // alias to replace root dir name
36
-		$this->options['dirMode']  = 0755;            // new dirs mode
37
-		$this->options['fileMode'] = 0644;            // new files mode
38
-		$this->options['quarantine'] = '.quarantine';  // quarantine folder name - required to check archive (must be hidden)
39
-		$this->options['maxArcFilesSize'] = 0;        // max allowed archive files size (0 - no limit)
35
+		$this->options['alias']    = ''; // alias to replace root dir name
36
+		$this->options['dirMode']  = 0755; // new dirs mode
37
+		$this->options['fileMode'] = 0644; // new files mode
38
+		$this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden)
39
+		$this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit)
40 40
 		$this->options['rootCssClass'] = 'elfinder-navbar-root-local';
41 41
 	}
42 42
 	
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	protected function init() {
54 54
 		// Normalize directory separator for windows
55 55
 		if (DIRECTORY_SEPARATOR !== '/') {
56
-			foreach(array('path', 'tmpPath', 'quarantine') as $key) {
56
+			foreach (array('path', 'tmpPath', 'quarantine') as $key) {
57 57
 				if ($this->options[$key]) {
58 58
 					$this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]);
59 59
 				}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		// if no thumbnails url - try detect it
100 100
 		if ($root['read'] && !$this->tmbURL && $this->URL) {
101 101
 			if (strpos($this->tmbPath, $this->root) === 0) {
102
-				$this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1));
102
+				$this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1));
103 103
 				if (preg_match("|[^/?&=]$|", $this->tmbURL)) {
104 104
 					$this->tmbURL .= '/';
105 105
 				}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 * @author Dmitry (dio) Levashov
176 176
 	 **/
177 177
 	protected function _joinPath($dir, $name) {
178
-		return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name;
178
+		return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name;
179 179
 	}
180 180
 	
181 181
 	/**
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		$comps = $new_comps;
228 228
 		$path = implode('/', $comps);
229 229
 		if ($initial_slashes) {
230
-			$path = str_repeat('/', $initial_slashes) . $path;
230
+			$path = str_repeat('/', $initial_slashes).$path;
231 231
 		}
232 232
 		
233 233
 		if ($changeSep) {
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 **/
299 299
 	protected function _inpath($path, $parent) {
300 300
 		$cwd = getcwd();
301
-		$real_path   = $this->getFullPath($path,   $cwd);
301
+		$real_path   = $this->getFullPath($path, $cwd);
302 302
 		$real_parent = $this->getFullPath($parent, $cwd);
303 303
 		if ($real_path && $real_parent) {
304 304
 			return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0;
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 					$stat = array();
358 358
 					return $stat;
359 359
 				} else {
360
-					$stat['mime']  = 'symlink-broken';
360
+					$stat['mime'] = 'symlink-broken';
361 361
 					$target = readlink($path);
362 362
 					$lstat = lstat($path);
363 363
 					$ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']);
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 			$fstat = stat($path);
374 374
 			$uid = $fstat['uid'];
375 375
 			$gid = $fstat['gid'];
376
-			$stat['perm'] = substr((string)decoct($fstat['mode']), -4);
376
+			$stat['perm'] = substr((string) decoct($fstat['mode']), -4);
377 377
 			$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
378 378
 		}
379 379
 		
@@ -383,8 +383,8 @@  discard block
 block discarded – undo
383 383
 			$stat['mime'] = $dir ? 'directory' : $this->mimetype($path);
384 384
 		}
385 385
 		//logical rights first
386
-		$stat['read'] = ($linkreadable || is_readable($path))? null : false;
387
-		$stat['write'] = is_writable($path)? null : false;
386
+		$stat['read'] = ($linkreadable || is_readable($path)) ? null : false;
387
+		$stat['write'] = is_writable($path) ? null : false;
388 388
 
389 389
 		if (is_null($stat['read'])) {
390 390
 			$stat['size'] = $dir ? 0 : $size;
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 
455 455
 		if (is_dir($path)) {
456 456
 			$path = strtr($path, array('['  => '\\[', ']'  => '\\]', '*'  => '\\*', '?'  => '\\?'));
457
-			return (bool)glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR);
457
+			return (bool) glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR);
458 458
 		}
459 459
 		return false;
460 460
 	}
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 							$br = true;
536 536
 						} else {
537 537
 							$_path = $fpath;
538
-							$stat['mime']  = 'symlink-broken';
538
+							$stat['mime'] = 'symlink-broken';
539 539
 							$target = readlink($_path);
540 540
 							$lstat = lstat($_path);
541 541
 							$ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']);
@@ -560,13 +560,13 @@  discard block
 block discarded – undo
560 560
 					if ($statOwner && !$linkreadable) {
561 561
 						$uid = $file->getOwner();
562 562
 						$gid = $file->getGroup();
563
-						$stat['perm'] = substr((string)decoct($file->getPerms()), -4);
563
+						$stat['perm'] = substr((string) decoct($file->getPerms()), -4);
564 564
 						$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
565 565
 					}
566 566
 					
567 567
 					//logical rights first
568
-					$stat['read'] = ($linkreadable || $file->isReadable())? null : false;
569
-					$stat['write'] = $file->isWritable()? null : false;
568
+					$stat['read'] = ($linkreadable || $file->isReadable()) ? null : false;
569
+					$stat['write'] = $file->isWritable() ? null : false;
570 570
 					
571 571
 					if (is_null($stat['read'])) {
572 572
 						$stat['size'] = $dir ? 0 : $size;
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 		
583 583
 		if ($cache) {
584 584
 			$cache = $this->convEncOut($cache, false);
585
-			foreach($cache as $d) {
585
+			foreach ($cache as $d) {
586 586
 				$this->updateCache($d[0], $d[1]);
587 587
 			}
588 588
 		}
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 	 * @return resource|false
599 599
 	 * @author Dmitry (dio) Levashov
600 600
 	 **/
601
-	protected function _fopen($path, $mode='rb') {
601
+	protected function _fopen($path, $mode = 'rb') {
602 602
 		return @fopen($path, $mode);
603 603
 	}
604 604
 	
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 	 * @return bool
610 610
 	 * @author Dmitry (dio) Levashov
611 611
 	 **/
612
-	protected function _fclose($fp, $path='') {
612
+	protected function _fclose($fp, $path = '') {
613 613
 		return @fclose($fp);
614 614
 	}
615 615
 	
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 		$path = $this->_joinPath($dir, $name);
742 742
 
743 743
 		$meta = stream_get_meta_data($fp);
744
-		$uri = isset($meta['uri'])? $meta['uri'] : '';
744
+		$uri = isset($meta['uri']) ? $meta['uri'] : '';
745 745
 		if ($uri && @is_file($uri)) {
746 746
 			fclose($fp);
747 747
 			$isCmdPaste = ($this->ARGS['cmd'] === 'paste');
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 	 * @return bool
806 806
 	 **/
807 807
 	protected function _chmod($path, $mode) {
808
-		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode));
808
+		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode));
809 809
 		$ret = @chmod($path, $modeOct);
810 810
 		$ret && clearstatcache();
811 811
 		return  $ret;
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
 				$src = $dir;
924 924
 				$name = basename($path);
925 925
 				if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
926
-					$name = substr($name, 0,  strlen($name)-strlen($m[0]));
926
+					$name = substr($name, 0, strlen($name) - strlen($m[0]));
927 927
 				}
928 928
 				$test = dirname($path).DIRECTORY_SEPARATOR.$name;
929 929
 				if (file_exists($test) || is_link($test)) {
@@ -932,9 +932,9 @@  discard block
 block discarded – undo
932 932
 			}
933 933
 			
934 934
 			if ($name !== '') {
935
-				$result  = dirname($path).DIRECTORY_SEPARATOR.$name;
935
+				$result = dirname($path).DIRECTORY_SEPARATOR.$name;
936 936
 
937
-				if (! @rename($src, $result)) {
937
+				if (!@rename($src, $result)) {
938 938
 					$this->delTree($dir);
939 939
 					return false;
940 940
 				}
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 				$dstDir = dirname($path);
943 943
 				$res = false;
944 944
 				$result = array();
945
-				foreach($ls as $name) {
945
+				foreach ($ls as $name) {
946 946
 					$target = $dstDir.DIRECTORY_SEPARATOR.$name;
947 947
 					if (is_dir($target)) {
948 948
 						$this->delTree($target);
@@ -1034,10 +1034,10 @@  discard block
 block discarded – undo
1034 1034
 		
1035 1035
 		$path = strtr($path, $escaper);
1036 1036
 		$_q = strtr($q, $escaper);
1037
-		$dirs = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR);
1038
-		$match = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'.$_q.'*', GLOB_NOSORT);
1037
+		$dirs = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR);
1038
+		$match = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'.$_q.'*', GLOB_NOSORT);
1039 1039
 		if ($match) {
1040
-			foreach($match as $p) {
1040
+			foreach ($match as $p) {
1041 1041
 				$stat = $this->stat($p);
1042 1042
 		
1043 1043
 				if (!$stat) { // invalid links
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
 					$stat['path'] = $this->path($stat['hash']);
1055 1055
 					if ($this->URL && !isset($stat['url'])) {
1056 1056
 						$path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1));
1057
-						$stat['url'] = $this->URL . $path;
1057
+						$stat['url'] = $this->URL.$path;
1058 1058
 					}
1059 1059
 		
1060 1060
 					$result[] = $stat;
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
 			}
1063 1063
 		}
1064 1064
 		if ($dirs) {
1065
-			foreach($dirs as $dir) {
1065
+			foreach ($dirs as $dir) {
1066 1066
 				$stat = $this->stat($dir);
1067 1067
 				if ($stat['read'] && !isset($stat['alias'])) {
1068 1068
 					@set_time_limit(30);
Please login to merge, or discard this patch.