Completed
Push — 2.x ( 36805a...aa838c )
by Naoki
07:59
created
php/elFinderVolumeDriver.class.php 1 patch
Spacing   +129 added lines, -130 removed lines patch added patch discarded remove patch
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 		'utf8fix'      => false,
275 275
 		 //                           й                 ё              Й               Ё              Ø         Å
276 276
 		'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"),
277
-		'utf8replace'  => array("\u0439",        "\u0451",       "\u0419",       "\u0401",       "\u00d8", "\u00c5")
277
+		'utf8replace'  => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5")
278 278
 	);
279 279
 
280 280
 	/**
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 **/
567 567
 	protected function configure() {
568 568
 		// set ARGS
569
-		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET;
569
+		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
570 570
 		// set thumbnails path
571 571
 		$path = $this->options['tmbPath'];
572 572
 		if ($path) {
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 		
598 598
 		// check 'statOwner' for command `chmod`
599 599
 		if (empty($this->options['statOwner'])) {
600
-			$this->disabled[] ='chmod';
600
+			$this->disabled[] = 'chmod';
601 601
 		}
602 602
 		
603 603
 		// check 'mimeMap'
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	 **/
703 703
 	public function mount(array $opts) {
704 704
 		if (!isset($opts['path']) || $opts['path'] === '') {
705
-			return $this->setError('Path undefined.');;
705
+			return $this->setError('Path undefined.'); ;
706 706
 		}
707 707
 		
708 708
 		$this->options = array_merge($this->options, $opts);
@@ -721,14 +721,14 @@  discard block
 block discarded – undo
721 721
 		$argInit = !empty($this->ARGS['init']);
722 722
 		
723 723
 		// session cache
724
-		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
724
+		if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
725 725
 			$_SESSION[elFinder::$sessionCacheKey][$this->id] = array();
726 726
 		}
727 727
 		$this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id];
728 728
 		
729 729
 		// default file attribute
730 730
 		$this->defaults = array(
731
-			'read'    => isset($this->options['defaults']['read'])  ? !!$this->options['defaults']['read']  : true,
731
+			'read'    => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true,
732 732
 			'write'   => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true,
733 733
 			'locked'  => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false,
734 734
 			'hidden'  => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false
@@ -755,8 +755,8 @@  discard block
 block discarded – undo
755 755
 			$this->access = $this->options['accessControl'];
756 756
 		}
757 757
 		
758
-		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y'));
759
-		$this->yesterday = $this->today-86400;
758
+		$this->today     = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
759
+		$this->yesterday = $this->today - 86400;
760 760
 		
761 761
 		// debug($this->attributes);
762 762
 		if (!$this->init()) {
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 				foreach ($mimecf as $line_num => $line) {
856 856
 					if (!preg_match('/^\s*#/', $line)) {
857 857
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
858
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
858
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
859 859
 							if (!isset(self::$mimetypes[$mime[$i]])) {
860 860
 								self::$mimetypes[$mime[$i]] = $mime[0];
861 861
 							}
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
 				'read'    => false
908 908
 			));
909 909
 		}
910
-		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1;
911
-		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48;
910
+		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1;
911
+		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48;
912 912
 		$this->URL      = $this->options['URL'];
913 913
 		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) {
914 914
 			$this->URL .= '/';
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 	public function options($hash) {
1050 1050
 		$create = $createext = array();
1051 1051
 		if (isset($this->archivers['create']) && is_array($this->archivers['create'])) {
1052
-			foreach($this->archivers['create'] as $m => $v) {
1052
+			foreach ($this->archivers['create'] as $m => $v) {
1053 1053
 				$create[] = $m;
1054 1054
 				$createext[$m] = $v['ext'];
1055 1055
 			}
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 				'extract'   => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(),
1069 1069
 				'createext' => $createext
1070 1070
 			),
1071
-			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array()
1071
+			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array()
1072 1072
 		);
1073 1073
 	}
1074 1074
 	
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
 	 */
1082 1082
 	public function getOptionsPlugin($name = '') {
1083 1083
 		if ($name) {
1084
-			return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array();
1084
+			return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array();
1085 1085
 		} else {
1086 1086
 			return $this->options['plugin'];
1087 1087
 		}
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 		$file = $this->stat($path);
1212 1212
 		
1213 1213
 		if ($hash === $this->root()) {
1214
-			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array();
1214
+			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array();
1215 1215
 			$file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON
1216 1216
 		}
1217 1217
 		
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
 	 * @return array|false
1227 1227
 	 * @author Dmitry (dio) Levashov
1228 1228
 	 **/
1229
-	public function dir($hash, $resolveLink=false) {
1229
+	public function dir($hash, $resolveLink = false) {
1230 1230
 		if (($dir = $this->file($hash)) == false) {
1231 1231
 			return $this->setError(elFinder::ERROR_DIR_NOT_FOUND);
1232 1232
 		}
@@ -1290,14 +1290,14 @@  discard block
 block discarded – undo
1290 1290
 	 * @return array|false
1291 1291
 	 * @author Dmitry (dio) Levashov
1292 1292
 	 **/
1293
-	public function tree($hash='', $deep=0, $exclude='') {
1293
+	public function tree($hash = '', $deep = 0, $exclude = '') {
1294 1294
 		$path = $hash ? $this->decode($hash) : $this->root;
1295 1295
 		
1296 1296
 		if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') {
1297 1297
 			return false;
1298 1298
 		}
1299 1299
 		
1300
-		$dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null);
1300
+		$dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null);
1301 1301
 		array_unshift($dirs, $dir);
1302 1302
 		return $dirs;
1303 1303
 	}
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
 	 * @return array|false
1528 1528
 	 * @author Dmitry (dio) Levashov
1529 1529
 	 **/
1530
-	public function duplicate($hash, $suffix='copy') {
1530
+	public function duplicate($hash, $suffix = 'copy') {
1531 1531
 		if ($this->commandDisabled('duplicate')) {
1532 1532
 			return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED);
1533 1533
 		}
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
 		
1604 1604
 		if ($file) { // file exists
1605 1605
 			// check POST data `overwrite` for 3rd party uploader
1606
-			$overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite'];
1606
+			$overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite'];
1607 1607
 			if ($overwrite) {
1608 1608
 				if (!$file['write']) {
1609 1609
 					return $this->setError(elFinder::ERROR_PERM_DENIED);
@@ -1674,7 +1674,7 @@  discard block
 block discarded – undo
1674 1674
 		if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) {
1675 1675
 			return $rmSrc
1676 1676
 				? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test))
1677
-				: $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1677
+				: $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1678 1678
 		}
1679 1679
 
1680 1680
 		$test = $this->joinPathCE($destination, $name);
@@ -1837,7 +1837,7 @@  discard block
 block discarded – undo
1837 1837
 			return $this->setError(elFinder::ERROR_PERM_DENIED);
1838 1838
 		}
1839 1839
 		$this->clearcache();
1840
-		$this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir;
1840
+		$this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir;
1841 1841
 		
1842 1842
 		if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) {
1843 1843
 			if (is_array($path)) {
@@ -1895,9 +1895,9 @@  discard block
 block discarded – undo
1895 1895
 		if ($name === '') {
1896 1896
 			$name = count($files) == 1 ? $files[0] : 'Archive';
1897 1897
 		} else {
1898
-			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name));
1898
+			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name));
1899 1899
 		}
1900
-		$name .='.' . $archiver['ext'];
1900
+		$name .= '.'.$archiver['ext'];
1901 1901
 		$name = $this->uniqueName($dir, $name, '');
1902 1902
 		$this->clearcache();
1903 1903
 		return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false;
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
 		
1934 1934
 		$path = $this->decode($hash);
1935 1935
 		
1936
-		$work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path);
1936
+		$work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path);
1937 1937
 
1938 1938
 		if (!$work_path || !is_writable($work_path)) {
1939 1939
 			if ($work_path && $path !== $work_path && is_file($work_path)) {
@@ -1948,7 +1948,7 @@  discard block
 block discarded – undo
1948 1948
 			}
1949 1949
 		}
1950 1950
 
1951
-		switch($mode) {
1951
+		switch ($mode) {
1952 1952
 			
1953 1953
 			case 'propresize':
1954 1954
 				$result = $this->imgResize($work_path, $width, $height, true, true);
@@ -2044,7 +2044,7 @@  discard block
 block discarded – undo
2044 2044
 		}
2045 2045
 		return ($q === '' || $this->commandDisabled('search'))
2046 2046
 			? array()
2047
-			: $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes);
2047
+			: $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes);
2048 2048
 	}
2049 2049
 	
2050 2050
 	/**
@@ -2113,9 +2113,9 @@  discard block
 block discarded – undo
2113 2113
 		$path = ltrim($path, $this->separator);
2114 2114
 		$dirs = explode($this->separator, $path);
2115 2115
 		array_pop($dirs);
2116
-		foreach($dirs as $dir) {
2116
+		foreach ($dirs as $dir) {
2117 2117
 			$targetPath = $this->joinPathCE($base, $dir);
2118
-			if (! $_realpath = $this->realpath($this->encode($targetPath))) {
2118
+			if (!$_realpath = $this->realpath($this->encode($targetPath))) {
2119 2119
 				if ($stat = $this->mkdir($targetHash, $dir)) {
2120 2120
 					$result['added'][] = $stat;
2121 2121
 					$targetHash = $stat['hash'];
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
 	 * @author Naoki Sawada
2183 2183
 	 **/
2184 2184
 	protected function dirnameCE($path) {
2185
-		return (!$this->encoding)? $this->_dirname($path) :	$this->convEncOut($this->_dirname($this->convEncIn($path)));
2185
+		return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path)));
2186 2186
 	}
2187 2187
 	
2188 2188
 	/**
@@ -2193,7 +2193,7 @@  discard block
 block discarded – undo
2193 2193
 	 * @author Naoki Sawada
2194 2194
 	 **/
2195 2195
 	protected function basenameCE($path) {
2196
-		return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2196
+		return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2197 2197
 	}
2198 2198
 	
2199 2199
 	/**
@@ -2206,7 +2206,7 @@  discard block
 block discarded – undo
2206 2206
 	 * @author Naoki Sawada
2207 2207
 	 **/
2208 2208
 	protected function joinPathCE($dir, $name) {
2209
-		return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2209
+		return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2210 2210
 	}
2211 2211
 	
2212 2212
 	/**
@@ -2217,7 +2217,7 @@  discard block
 block discarded – undo
2217 2217
 	 * @author Naoki Sawada
2218 2218
 	 **/
2219 2219
 	protected function normpathCE($path) {
2220
-		return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2220
+		return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2221 2221
 	}
2222 2222
 	
2223 2223
 	/**
@@ -2228,7 +2228,7 @@  discard block
 block discarded – undo
2228 2228
 	 * @author Naoki Sawada
2229 2229
 	 **/
2230 2230
 	protected function relpathCE($path) {
2231
-		return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2231
+		return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2232 2232
 	}
2233 2233
 	
2234 2234
 	/**
@@ -2239,7 +2239,7 @@  discard block
 block discarded – undo
2239 2239
 	 * @author Naoki Sawada
2240 2240
 	 **/
2241 2241
 	protected function abspathCE($path) {
2242
-		return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path)));
2242
+		return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path)));
2243 2243
 	}
2244 2244
 	
2245 2245
 	/**
@@ -2251,7 +2251,7 @@  discard block
 block discarded – undo
2251 2251
 	 * @author Naoki Sawada
2252 2252
 	 **/
2253 2253
 	protected function inpathCE($path, $parent) {
2254
-		return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2254
+		return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2255 2255
 	}
2256 2256
 	
2257 2257
 	/**
@@ -2262,8 +2262,8 @@  discard block
 block discarded – undo
2262 2262
 	 * @return resource|false
2263 2263
 	 * @author Naoki Sawada
2264 2264
 	 **/
2265
-	protected function fopenCE($path, $mode='rb') {
2266
-		return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2265
+	protected function fopenCE($path, $mode = 'rb') {
2266
+		return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2267 2267
 	}
2268 2268
 	
2269 2269
 	/**
@@ -2274,8 +2274,8 @@  discard block
 block discarded – undo
2274 2274
 	 * @return bool
2275 2275
 	 * @author Naoki Sawada
2276 2276
 	 **/
2277
-	protected function fcloseCE($fp, $path='') {
2278
-		return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2277
+	protected function fcloseCE($fp, $path = '') {
2278
+		return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2279 2279
 	}
2280 2280
 	
2281 2281
 	/**
@@ -2290,7 +2290,7 @@  discard block
 block discarded – undo
2290 2290
 	 * @author Naoki Sawada
2291 2291
 	 **/
2292 2292
 	protected function saveCE($fp, $dir, $name, $stat) {
2293
-		return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2293
+		return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2294 2294
 	}
2295 2295
 	
2296 2296
 	/**
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
 	 **/
2303 2303
 	protected function subdirsCE($path) {
2304 2304
 		if (!isset($this->subdirsCache[$path])) {
2305
-			$this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2305
+			$this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2306 2306
 		}
2307 2307
 		return $this->subdirsCache[$path];
2308 2308
 	}
@@ -2315,7 +2315,7 @@  discard block
 block discarded – undo
2315 2315
 	 * @author Naoki Sawada
2316 2316
 	 **/
2317 2317
 	protected function scandirCE($path) {
2318
-		return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2318
+		return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2319 2319
 	}
2320 2320
 	
2321 2321
 	/**
@@ -2328,7 +2328,7 @@  discard block
 block discarded – undo
2328 2328
 	 * @author Naoki Sawada
2329 2329
 	 **/
2330 2330
 	protected function symlinkCE($source, $targetDir, $name) {
2331
-		return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2331
+		return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2332 2332
 	}
2333 2333
 	
2334 2334
 	/***************** paths *******************/
@@ -2347,7 +2347,7 @@  discard block
 block discarded – undo
2347 2347
 			// cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root
2348 2348
 			$p = $this->relpathCE($path);
2349 2349
 			// if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt
2350
-			if ($p === '')	{
2350
+			if ($p === '') {
2351 2351
 				$p = DIRECTORY_SEPARATOR;
2352 2352
 			}
2353 2353
 
@@ -2380,7 +2380,7 @@  discard block
 block discarded – undo
2380 2380
 			// TODO uncrypt hash and return path
2381 2381
 			$path = $this->uncrypt($h); 
2382 2382
 			// append ROOT to path after it was cut in encode
2383
-			return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2383
+			return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2384 2384
 		}
2385 2385
 	}
2386 2386
 	
@@ -2437,21 +2437,21 @@  discard block
 block discarded – undo
2437 2437
 	 * @author Dmitry (dio) Levashov
2438 2438
 	 **/
2439 2439
 	public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) {
2440
-		$ext  = '';
2440
+		$ext = '';
2441 2441
 
2442 2442
 		if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
2443 2443
 			$ext  = '.'.$m[1];
2444
-			$name = substr($name, 0,  strlen($name)-strlen($m[0]));
2444
+			$name = substr($name, 0, strlen($name) - strlen($m[0]));
2445 2445
 		} 
2446 2446
 		
2447 2447
 		if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) {
2448
-			$i    = (int)$m[2];
2449
-			$name = substr($name, 0, strlen($name)-strlen($m[2]));
2448
+			$i    = (int) $m[2];
2449
+			$name = substr($name, 0, strlen($name) - strlen($m[2]));
2450 2450
 		} else {
2451 2451
 			$i     = $start;
2452 2452
 			$name .= $suffix;
2453 2453
 		}
2454
-		$max = $i+100000;
2454
+		$max = $i + 100000;
2455 2455
 
2456 2456
 		while ($i <= $max) {
2457 2457
 			$n = $name.($i > 0 ? $i : '').$ext;
@@ -2475,7 +2475,7 @@  discard block
 block discarded – undo
2475 2475
 	 * @author Naoki Sawada
2476 2476
 	 */
2477 2477
 	public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') {
2478
-		return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2478
+		return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2479 2479
 	}
2480 2480
 	
2481 2481
 	/**
@@ -2488,7 +2488,7 @@  discard block
 block discarded – undo
2488 2488
 	 * @author Naoki Sawada
2489 2489
 	 */
2490 2490
 	public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') {
2491
-		return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2491
+		return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2492 2492
 	}
2493 2493
 	
2494 2494
 	/**
@@ -2508,7 +2508,7 @@  discard block
 block discarded – undo
2508 2508
 			}
2509 2509
 			if (is_array($var)) {
2510 2510
 				$_ret = array();
2511
-				foreach($var as $_k => $_v) {
2511
+				foreach ($var as $_k => $_v) {
2512 2512
 					$_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_');
2513 2513
 				}
2514 2514
 				$var = $_ret;
@@ -2520,7 +2520,7 @@  discard block
 block discarded – undo
2520 2520
 						$_var = str_replace('?', $unknown, $_var);
2521 2521
 					}
2522 2522
 				}
2523
-				if  ($_var !== false) {
2523
+				if ($_var !== false) {
2524 2524
 					$var = $_var;
2525 2525
 				}
2526 2526
 			}
@@ -2547,7 +2547,7 @@  discard block
 block discarded – undo
2547 2547
 		
2548 2548
 		$key = '';
2549 2549
 		if ($path !== '') {
2550
-			$key = $this->id . '#' . $path;
2550
+			$key = $this->id.'#'.$path;
2551 2551
 			if (isset($cache[$key])) {
2552 2552
 				return $cache[$key];
2553 2553
 			}
@@ -2579,7 +2579,7 @@  discard block
 block discarded – undo
2579 2579
 		if ($work = $this->getTempFile()) {
2580 2580
 			if ($wfp = fopen($work, 'wb')) {
2581 2581
 				if ($fp = $this->_fopen($path)) {
2582
-					while(!feof($fp)) {
2582
+					while (!feof($fp)) {
2583 2583
 						fwrite($wfp, fread($fp, 8192));
2584 2584
 					}
2585 2585
 					$this->_fclose($fp, $path);
@@ -2623,7 +2623,7 @@  discard block
 block discarded – undo
2623 2623
 			@set_time_limit(30);
2624 2624
 			$stat = $this->stat($this->convEncOut($p));
2625 2625
 			$this->convEncIn();
2626
-			($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p);
2626
+			($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p);
2627 2627
 		}
2628 2628
 		return $this->_rmdir($localpath);
2629 2629
 	}
@@ -2640,7 +2640,7 @@  discard block
 block discarded – undo
2640 2640
 	 * @return bool
2641 2641
 	 * @author Dmitry (dio) Levashov
2642 2642
 	 **/
2643
-	protected function attr($path, $name, $val=null, $isDir=null) {
2643
+	protected function attr($path, $name, $val = null, $isDir = null) {
2644 2644
 		if (!isset($this->defaults[$name])) {
2645 2645
 			return false;
2646 2646
 		}
@@ -2672,7 +2672,7 @@  discard block
 block discarded – undo
2672 2672
 			} 
2673 2673
 		}
2674 2674
 		
2675
-		return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm;
2675
+		return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm;
2676 2676
 	}
2677 2677
 	
2678 2678
 	/**
@@ -2716,7 +2716,7 @@  discard block
 block discarded – undo
2716 2716
 	protected function allowPutMime($mime) {
2717 2717
 		// logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order
2718 2718
 		$allow  = $this->mimeAccepted($mime, $this->uploadAllow, null);
2719
-		$deny   = $this->mimeAccepted($mime, $this->uploadDeny,  null);
2719
+		$deny   = $this->mimeAccepted($mime, $this->uploadDeny, null);
2720 2720
 		$res = true; // default to allow
2721 2721
 		if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny'
2722 2722
 			$res = false; // default is deny
@@ -2787,10 +2787,10 @@  discard block
 block discarded – undo
2787 2787
 			if ($this->rootName) {
2788 2788
 				$stat['name'] = $this->rootName;
2789 2789
 			}
2790
-			if (! empty($this->options['icon'])) {
2790
+			if (!empty($this->options['icon'])) {
2791 2791
 				$stat['icon'] = $this->options['icon'];
2792 2792
 			}
2793
-			if (! empty($this->options['rootCssClass'])) {
2793
+			if (!empty($this->options['rootCssClass'])) {
2794 2794
 				$stat['csscls'] = $this->options['rootCssClass'];
2795 2795
 			}
2796 2796
 		} else {
@@ -2834,7 +2834,7 @@  discard block
 block discarded – undo
2834 2834
 			// lock when parent directory is not writable
2835 2835
 			if (!isset($stat['locked'])) {
2836 2836
 				$parent = $this->dirnameCE($path);
2837
-				$pstat = isset($this->cache[$parent])? $this->cache[$parent] : array();
2837
+				$pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array();
2838 2838
 				if (isset($pstat['write']) && !$pstat['write']) {
2839 2839
 					$stat['locked'] = true;
2840 2840
 				}
@@ -2892,7 +2892,7 @@  discard block
 block discarded – undo
2892 2892
 			}
2893 2893
 			if (!isset($stat['url']) && $this->URL && $this->encoding) {
2894 2894
 				$_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1));
2895
-				$stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true)));
2895
+				$stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true)));
2896 2896
 			}
2897 2897
 		} else {
2898 2898
 			if ($isDir) {
@@ -3135,7 +3135,7 @@  discard block
 block discarded – undo
3135 3135
 	 * @return array
3136 3136
 	 * @author Dmitry (dio) Levashov
3137 3137
 	 **/
3138
-	protected function gettree($path, $deep, $exclude='') {
3138
+	protected function gettree($path, $deep, $exclude = '') {
3139 3139
 		$dirs = array();
3140 3140
 		
3141 3141
 		!isset($this->dirsCache[$path]) && $this->cacheDir($path);
@@ -3146,7 +3146,7 @@  discard block
 block discarded – undo
3146 3146
 			if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') {
3147 3147
 				$dirs[] = $stat;
3148 3148
 				if ($deep > 0 && !empty($stat['dirs'])) {
3149
-					$dirs = array_merge($dirs, $this->gettree($p, $deep-1));
3149
+					$dirs = array_merge($dirs, $this->gettree($p, $deep - 1));
3150 3150
 				}
3151 3151
 			}
3152 3152
 		}
@@ -3166,7 +3166,7 @@  discard block
 block discarded – undo
3166 3166
 	protected function doSearch($path, $q, $mimes) {
3167 3167
 		$result = array();
3168 3168
 
3169
-		foreach($this->scandirCE($path) as $p) {
3169
+		foreach ($this->scandirCE($path) as $p) {
3170 3170
 			@set_time_limit(30);
3171 3171
 			$stat = $this->stat($p);
3172 3172
 
@@ -3187,7 +3187,7 @@  discard block
 block discarded – undo
3187 3187
 					if ($this->encoding) {
3188 3188
 						$path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true)));
3189 3189
 					}
3190
-					$stat['url'] = $this->URL . $path;
3190
+					$stat['url'] = $this->URL.$path;
3191 3191
 				}
3192 3192
 				
3193 3193
 				$result[] = $stat;
@@ -3221,7 +3221,7 @@  discard block
 block discarded – undo
3221 3221
 			if (!$this->inpathCE($target, $this->root)) {
3222 3222
 				return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK);
3223 3223
 			}
3224
-			$stat   = $this->stat($target);
3224
+			$stat = $this->stat($target);
3225 3225
 			$this->clearcache();
3226 3226
 			return $stat && $this->symlinkCE($target, $dst, $name)
3227 3227
 				? $this->joinPathCE($dst, $name)
@@ -3502,15 +3502,15 @@  discard block
 block discarded – undo
3502 3502
 		}
3503 3503
 
3504 3504
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
3505
-		if ($s[0] <= $tmbSize && $s[1]	<= $tmbSize) {
3506
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3505
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
3506
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3507 3507
 		} else {
3508 3508
 		
3509 3509
 			if ($this->options['tmbCrop']) {
3510 3510
 		
3511 3511
 				$result = $tmb;
3512 3512
 				/* Resize and crop if image bigger than thumbnail */
3513
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3513
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3514 3514
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
3515 3515
 				}
3516 3516
 		
@@ -3527,7 +3527,7 @@  discard block
 block discarded – undo
3527 3527
 			}
3528 3528
 		
3529 3529
 			if ($result) {
3530
-				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3530
+				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3531 3531
 			}
3532 3532
 		}
3533 3533
 		
@@ -3568,18 +3568,18 @@  discard block
 block discarded – undo
3568 3568
 			/* Resizing by biggest side */
3569 3569
 			if ($resizeByBiggerSide) {
3570 3570
 				if ($orig_w > $orig_h) {
3571
-					$size_h = round($orig_h * $width / $orig_w);
3571
+					$size_h = round($orig_h*$width/$orig_w);
3572 3572
 					$size_w = $width;
3573 3573
 				} else {
3574
-					$size_w = round($orig_w * $height / $orig_h);
3574
+					$size_w = round($orig_w*$height/$orig_h);
3575 3575
 					$size_h = $height;
3576 3576
 				}
3577 3577
 			} else {
3578 3578
 				if ($orig_w > $orig_h) {
3579
-					$size_w = round($orig_w * $height / $orig_h);
3579
+					$size_w = round($orig_w*$height/$orig_h);
3580 3580
 					$size_h = $height;
3581 3581
 				} else {
3582
-					$size_h = round($orig_h * $width / $orig_w);
3582
+					$size_h = round($orig_h*$width/$orig_w);
3583 3583
 					$size_w = $width;
3584 3584
 				}
3585 3585
 			}
@@ -3597,7 +3597,7 @@  discard block
 block discarded – undo
3597 3597
 				// Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb
3598 3598
 				// resize bench: http://app-mgng.rhcloud.com/9
3599 3599
 				// resize sample: http://www.dylanbeattie.net/magick/filters/result.html
3600
-				$filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3600
+				$filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3601 3601
 				
3602 3602
 				$ani = ($img->getNumberImages() > 1);
3603 3603
 				if ($ani && is_null($destformat)) {
@@ -3622,11 +3622,11 @@  discard block
 block discarded – undo
3622 3622
 				break;
3623 3623
 
3624 3624
 			case 'gd':
3625
-				$img = self::gdImageCreate($path,$s['mime']);
3625
+				$img = self::gdImageCreate($path, $s['mime']);
3626 3626
 
3627
-				if ($img &&  false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3627
+				if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3628 3628
 				
3629
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3629
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3630 3630
 					
3631 3631
 					if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) {
3632 3632
 						return false;
@@ -3702,11 +3702,11 @@  discard block
 block discarded – undo
3702 3702
 				break;
3703 3703
 
3704 3704
 			case 'gd':
3705
-				$img = self::gdImageCreate($path,$s['mime']);
3705
+				$img = self::gdImageCreate($path, $s['mime']);
3706 3706
 
3707
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3707
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3708 3708
 					
3709
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3709
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3710 3710
 
3711 3711
 					$size_w = $width;
3712 3712
 					$size_h = $height;
@@ -3756,8 +3756,8 @@  discard block
 block discarded – undo
3756 3756
 		$result = false;
3757 3757
 
3758 3758
 		/* Coordinates for image over square aligning */
3759
-		$y = ceil(abs($height - $s[1]) / 2); 
3760
-		$x = ceil(abs($width - $s[0]) / 2);
3759
+		$y = ceil(abs($height - $s[1])/2); 
3760
+		$x = ceil(abs($width - $s[0])/2);
3761 3761
 
3762 3762
 		switch ($this->imgLib) {
3763 3763
 			case 'imagick':
@@ -3777,7 +3777,7 @@  discard block
 block discarded – undo
3777 3777
 						$gif->newImage($width, $height, new ImagickPixel($bgcolor));
3778 3778
 						$gif->setImageColorspace($img->getImageColorspace());
3779 3779
 						$gif->setImageFormat('gif');
3780
-						$gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3780
+						$gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3781 3781
 						$gif->setImageDelay($img->getImageDelay());
3782 3782
 						$gif->setImageIterations($img->getImageIterations());
3783 3783
 						$img1->addImage($gif);
@@ -3793,7 +3793,7 @@  discard block
 block discarded – undo
3793 3793
 					$img1->newImage($width, $height, new ImagickPixel($bgcolor));
3794 3794
 					$img1->setImageColorspace($img->getImageColorspace());
3795 3795
 					$img1->setImageFormat($destformat != null ? $destformat : $img->getFormat());
3796
-					$img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3796
+					$img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3797 3797
 					$result = $img1->writeImage($path);
3798 3798
 				}
3799 3799
 				
@@ -3804,11 +3804,11 @@  discard block
 block discarded – undo
3804 3804
 				break;
3805 3805
 
3806 3806
 			case 'gd':
3807
-				$img = self::gdImageCreate($path,$s['mime']);
3807
+				$img = self::gdImageCreate($path, $s['mime']);
3808 3808
 
3809
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3809
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3810 3810
 
3811
-					self::gdImageBackground($tmp,$bgcolor);
3811
+					self::gdImageBackground($tmp, $bgcolor);
3812 3812
 
3813 3813
 					if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) {
3814 3814
 						return false;
@@ -3839,15 +3839,15 @@  discard block
 block discarded – undo
3839 3839
 	 * @author Troex Nevelin
3840 3840
 	 **/
3841 3841
 	protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null) {
3842
-		if (($s = @getimagesize($path)) == false || $degree % 360 === 0) {
3842
+		if (($s = @getimagesize($path)) == false || $degree%360 === 0) {
3843 3843
 			return false;
3844 3844
 		}
3845 3845
 
3846 3846
 		$result = false;
3847 3847
 
3848 3848
 		// try lossless rotate
3849
-		if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3850
-			$count = ($degree / 90) % 4;
3849
+		if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3850
+			$count = ($degree/90)%4;
3851 3851
 			$exiftran = array(
3852 3852
 				1 => '-9',
3853 3853
 				2 => '-1',
@@ -3863,7 +3863,7 @@  discard block
 block discarded – undo
3863 3863
 				'exiftran -i '.$exiftran[$count].' '.$path,
3864 3864
 				'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath
3865 3865
 			);
3866
-			foreach($cmds as $cmd) {
3866
+			foreach ($cmds as $cmd) {
3867 3867
 				if ($this->procExec($cmd) === 0) {
3868 3868
 					$result = true;
3869 3869
 					break;
@@ -3899,12 +3899,12 @@  discard block
 block discarded – undo
3899 3899
 				break;
3900 3900
 
3901 3901
 			case 'gd':
3902
-				$img = self::gdImageCreate($path,$s['mime']);
3902
+				$img = self::gdImageCreate($path, $s['mime']);
3903 3903
 
3904 3904
 				$degree = 360 - $degree;
3905 3905
 				list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
3906 3906
 				$bgcolor = imagecolorallocate($img, $r, $g, $b);
3907
-				$tmp = imageRotate($img, $degree, (int)$bgcolor);
3907
+				$tmp = imageRotate($img, $degree, (int) $bgcolor);
3908 3908
 
3909 3909
 				$result = self::gdImage($tmp, $path, $destformat, $s['mime']);
3910 3910
 
@@ -3929,11 +3929,11 @@  discard block
 block discarded – undo
3929 3929
 	 * @return int     exit code
3930 3930
 	 * @author Alexey Sukhotin
3931 3931
 	 **/
3932
-	protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) {
3932
+	protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) {
3933 3933
 
3934 3934
 		$descriptorspec = array(
3935
-			0 => array("pipe", "r"),  // stdin
3936
-			1 => array("pipe", "w"),  // stdout
3935
+			0 => array("pipe", "r"), // stdin
3936
+			1 => array("pipe", "w"), // stdout
3937 3937
 			2 => array("pipe", "w")   // stderr
3938 3938
 		);
3939 3939
 
@@ -3990,8 +3990,8 @@  discard block
 block discarded – undo
3990 3990
 	 * @param string $mime
3991 3991
 	 * @return gd image resource identifier
3992 3992
 	 */
3993
-	protected function gdImageCreate($path,$mime){
3994
-		switch($mime){
3993
+	protected function gdImageCreate($path, $mime) {
3994
+		switch ($mime) {
3995 3995
 			case 'image/jpeg':
3996 3996
 			return imagecreatefromjpeg($path);
3997 3997
 
@@ -4015,7 +4015,7 @@  discard block
 block discarded – undo
4015 4015
 	 * @param string $destformat The Image type to use for $filename
4016 4016
 	 * @param string $mime The original image mime type
4017 4017
 	 */
4018
-	protected function gdImage($image, $filename, $destformat, $mime ){
4018
+	protected function gdImage($image, $filename, $destformat, $mime) {
4019 4019
 
4020 4020
 		if ($destformat == 'jpg' || ($destformat == null && $mime == 'image/jpeg')) {
4021 4021
 			return imagejpeg($image, $filename, 100);
@@ -4034,13 +4034,13 @@  discard block
 block discarded – undo
4034 4034
 	 * @param resource $image gd image resource
4035 4035
 	 * @param string $bgcolor background color in #rrggbb format
4036 4036
 	 */
4037
-	protected function gdImageBackground($image, $bgcolor){
4037
+	protected function gdImageBackground($image, $bgcolor) {
4038 4038
 
4039
-		if( $bgcolor == 'transparent' ){
4040
-			imagesavealpha($image,true);
4039
+		if ($bgcolor == 'transparent') {
4040
+			imagesavealpha($image, true);
4041 4041
 			$bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127);
4042 4042
 
4043
-		}else{
4043
+		} else {
4044 4044
 			list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4045 4045
 			$bgcolor1 = imagecolorallocate($image, $r, $g, $b);
4046 4046
 		}
@@ -4078,13 +4078,13 @@  discard block
 block discarded – undo
4078 4078
 	* @return int|bool
4079 4079
 	* @author Alexey Sukhotin
4080 4080
 	**/
4081
-	protected function stripos($haystack , $needle , $offset = 0) {
4081
+	protected function stripos($haystack, $needle, $offset = 0) {
4082 4082
 		if (function_exists('mb_stripos')) {
4083
-			return mb_stripos($haystack , $needle , $offset);
4083
+			return mb_stripos($haystack, $needle, $offset);
4084 4084
 		} else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) {
4085 4085
 			return mb_strpos(mb_strtolower($haystack), mb_strtolower($needle), $offset);
4086 4086
 		} 
4087
-		return stripos($haystack , $needle , $offset);
4087
+		return stripos($haystack, $needle, $offset);
4088 4088
 	}
4089 4089
 
4090 4090
 	/**
@@ -4134,22 +4134,22 @@  discard block
 block discarded – undo
4134 4134
 			unset($o);
4135 4135
 			$this->procExec('zip -v', $o, $c);
4136 4136
 			if ($c == 0) {
4137
-				$arcs['create']['application/zip']  = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4137
+				$arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4138 4138
 			}
4139 4139
 			unset($o);
4140 4140
 			$this->procExec('unzip --help', $o, $c);
4141 4141
 			if ($c == 0) {
4142
-				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '',  'ext' => 'zip');
4142
+				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip');
4143 4143
 			}
4144 4144
 			unset($o);
4145 4145
 			$this->procExec('rar --version', $o, $c);
4146 4146
 			if ($c == 0 || $c == 7) {
4147 4147
 				$arcs['create']['application/x-rar']  = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar');
4148
-				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y',    'ext' => 'rar');
4148
+				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar');
4149 4149
 			} else {
4150 4150
 				unset($o);
4151 4151
 				$test = $this->procExec('unrar', $o, $c);
4152
-				if ($c==0 || $c == 7) {
4152
+				if ($c == 0 || $c == 7) {
4153 4153
 					$arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar');
4154 4154
 				}
4155 4155
 			}
@@ -4171,7 +4171,7 @@  discard block
 block discarded – undo
4171 4171
 				if (empty($arcs['extract']['application/x-tar'])) {
4172 4172
 					$arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar');
4173 4173
 				}
4174
-			} else if (substr(PHP_OS,0,3) === 'WIN') {
4174
+			} else if (substr(PHP_OS, 0, 3) === 'WIN') {
4175 4175
 				// check `7z` for Windows server.
4176 4176
 				unset($o);
4177 4177
 				$this->procExec('7z', $o, $c);
@@ -4225,22 +4225,22 @@  discard block
 block discarded – undo
4225 4225
 
4226 4226
 		// normalize `/../`
4227 4227
 		$normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#';
4228
-		while(preg_match($normreg, $path)) {
4228
+		while (preg_match($normreg, $path)) {
4229 4229
 			$path = preg_replace($normreg, '$1', $path);
4230 4230
 		}
4231 4231
 		
4232 4232
 		// 'Here'
4233
-		if ($path === '' || $path === '.' . $separator) return $base;
4233
+		if ($path === '' || $path === '.'.$separator) return $base;
4234 4234
 		
4235 4235
 		// Absolute path
4236 4236
 		if ($path[0] === $separator || strpos($path, $systemroot) === 0) {
4237 4237
 			return $path;
4238 4238
 		}
4239 4239
 		
4240
-		$preg_separator = '#' . $sepquoted . '#';
4240
+		$preg_separator = '#'.$sepquoted.'#';
4241 4241
 		
4242 4242
 		// Relative path from 'Here'
4243
-		if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) {
4243
+		if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) {
4244 4244
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4245 4245
 			if ($arrn[0] !== '.') {
4246 4246
 				array_unshift($arrn, '.');
@@ -4254,12 +4254,11 @@  discard block
 block discarded – undo
4254 4254
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4255 4255
 			$arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY);
4256 4256
 		
4257
-			while (! empty($arrn) && $arrn[0] === '..') {
4257
+			while (!empty($arrn) && $arrn[0] === '..') {
4258 4258
 				array_shift($arrn);
4259 4259
 				array_pop($arrp);
4260 4260
 			}
4261
-			$path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) :
4262
-				(! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot);
4261
+			$path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot);
4263 4262
 		}
4264 4263
 		
4265 4264
 		return $path;
@@ -4277,7 +4276,7 @@  discard block
 block discarded – undo
4277 4276
 			@chmod($dir, 0777);
4278 4277
 			foreach (array_diff(scandir($dir), array('.', '..')) as $file) {
4279 4278
 				@set_time_limit(30);
4280
-				$path = $dir . DIRECTORY_SEPARATOR . $file;
4279
+				$path = $dir.DIRECTORY_SEPARATOR.$file;
4281 4280
 				if (!is_link($dir) && is_dir($path)) {
4282 4281
 					$this->rmdirRecursive($path);
4283 4282
 				} else {
@@ -4364,22 +4363,22 @@  discard block
 block discarded – undo
4364 4363
 		try {
4365 4364
 			if ($start = is_string($zipPath)) {
4366 4365
 				$zip = new ZipArchive();
4367
-				if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) {
4366
+				if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) {
4368 4367
 					$zip = false;
4369 4368
 				}
4370 4369
 			} else {
4371 4370
 				$zip = $zipPath;
4372 4371
 			}
4373 4372
 			if ($zip) {
4374
-				foreach($files as $file) {
4375
-					$path = $dir . DIRECTORY_SEPARATOR . $file;
4373
+				foreach ($files as $file) {
4374
+					$path = $dir.DIRECTORY_SEPARATOR.$file;
4376 4375
 					if (is_dir($path)) {
4377 4376
 						$zip->addEmptyDir($file);
4378 4377
 						$_files = array();
4379 4378
 						if ($handle = opendir($path)) {
4380 4379
 							while (false !== ($entry = readdir($handle))) {
4381 4380
 								if ($entry !== "." && $entry !== "..") {
4382
-									$_files[] = $file . DIRECTORY_SEPARATOR . $entry;
4381
+									$_files[] = $file.DIRECTORY_SEPARATOR.$entry;
4383 4382
 								}
4384 4383
 							}
4385 4384
 							closedir($handle);
@@ -4564,7 +4563,7 @@  discard block
 block discarded – undo
4564 4563
 	 * @return resource|false
4565 4564
 	 * @author Dmitry (dio) Levashov
4566 4565
 	 **/
4567
-	abstract protected function _fopen($path, $mode="rb");
4566
+	abstract protected function _fopen($path, $mode = "rb");
4568 4567
 	
4569 4568
 	/**
4570 4569
 	 * Close opened file
@@ -4574,7 +4573,7 @@  discard block
 block discarded – undo
4574 4573
 	 * @return bool
4575 4574
 	 * @author Dmitry (dio) Levashov
4576 4575
 	 **/
4577
-	abstract protected function _fclose($fp, $path='');
4576
+	abstract protected function _fclose($fp, $path = '');
4578 4577
 	
4579 4578
 	/********************  file/dir manipulations *************************/
4580 4579
 	
Please login to merge, or discard this patch.
php/plugins/Normalizer/plugin.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		$defaults = array(
59 59
 			'enable' => true, // For control by volume driver
60 60
 			'nfc'    => true, // Canonical Decomposition followed by Canonical Composition
61
-			'nfkc'   => true,  // Compatibility Decomposition followed by Canonical
61
+			'nfkc'   => true, // Compatibility Decomposition followed by Canonical
62 62
 			'lowercase'   => false  // Make chars lowercase
63 63
 		);
64 64
 	
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
 	
68 68
 	public function cmdPreprocess($cmd, &$args, $elfinder, $volume) {
69 69
 		$opts = $this->getOpts($volume);
70
-		if (! $opts['enable']) {
70
+		if (!$opts['enable']) {
71 71
 			return false;
72 72
 		}
73 73
 		
74 74
 		if (isset($args['name'])) {
75 75
 			if (is_array($args['name'])) {
76
-				foreach($args['name'] as $i => $name) {
76
+				foreach ($args['name'] as $i => $name) {
77 77
 					$args['name'][$i] = $this->normalize($name, $opts);
78 78
 				}
79 79
 			} else {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	
86 86
 	public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) {
87 87
 		$opts = $this->getOpts($volume);
88
-		if (! $opts['enable']) {
88
+		if (!$opts['enable']) {
89 89
 			return false;
90 90
 		}
91 91
 		
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
 	private function normalize($str, $opts) {
111 111
 		if ($opts['nfc'] || $opts['nfkc']) {
112 112
 			if (class_exists('Normalizer')) {
113
-				if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C))
113
+				if ($opts['nfc'] && !Normalizer::isNormalized($str, Normalizer::FORM_C))
114 114
 					$str = Normalizer::normalize($str, Normalizer::FORM_C);
115
-				if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC))
115
+				if ($opts['nfkc'] && !Normalizer::isNormalized($str, Normalizer::FORM_KC))
116 116
 					$str = Normalizer::normalize($str, Normalizer::FORM_KC);
117 117
 			} else {
118
-				if (! class_exists('I18N_UnicodeNormalizer')) {
118
+				if (!class_exists('I18N_UnicodeNormalizer')) {
119 119
 					@ include_once 'I18N/UnicodeNormalizer.php';
120 120
 				}
121 121
 				if (class_exists('I18N_UnicodeNormalizer')) {
Please login to merge, or discard this patch.
php/plugins/Sanitizer/plugin.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	
50 50
 	public function __construct($opts) {
51 51
 		$defaults = array(
52
-			'enable'   => true,  // For control by volume driver
53
-			'targets'  => array('\\','/',':','*','?','"','<','>','|'), // target chars
52
+			'enable'   => true, // For control by volume driver
53
+			'targets'  => array('\\', '/', ':', '*', '?', '"', '<', '>', '|'), // target chars
54 54
 			'replace'  => '_'    // replace to this
55 55
 		);
56 56
 	
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	
60 60
 	public function cmdPreprocess($cmd, &$args, $elfinder, $volume) {
61 61
 		$opts = $this->getOpts($volume);
62
-		if (! $opts['enable']) {
62
+		if (!$opts['enable']) {
63 63
 			return false;
64 64
 		}
65 65
 	
66 66
 		if (isset($args['name'])) {
67 67
 			if (is_array($args['name'])) {
68
-				foreach($args['name'] as $i => $name) {
68
+				foreach ($args['name'] as $i => $name) {
69 69
 					$args['name'][$i] = $this->sanitizeFileName($name, $opts);
70 70
 				}
71 71
 			} else {
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 	public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) {
79 79
 		$opts = $this->getOpts($volume);
80
-		if (! $opts['enable']) {
80
+		if (!$opts['enable']) {
81 81
 			return false;
82 82
 		}
83 83
 	
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 	
102 102
 	private function sanitizeFileName($filename, $opts, $allows = array()) {
103
-		$targets = $allows? array_diff($opts['targets'], $allows) : $opts['targets'];
103
+		$targets = $allows ? array_diff($opts['targets'], $allows) : $opts['targets'];
104 104
 		return str_replace($targets, $opts['replace'], $filename);
105 105
   	}
106 106
 }
Please login to merge, or discard this patch.