Completed
Push — 2.x ( 0befff...05c5ea )
by Naoki
04:36
created
php/elFinderVolumeDriver.class.php 1 patch
Spacing   +138 added lines, -139 removed lines patch added patch discarded remove patch
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 		'utf8fix'      => false,
299 299
 		 //                           й                 ё              Й               Ё              Ø         Å
300 300
 		'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"),
301
-		'utf8replace'  => array("\u0439",        "\u0451",       "\u0419",       "\u0401",       "\u00d8", "\u00c5")
301
+		'utf8replace'  => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5")
302 302
 	);
303 303
 
304 304
 	/**
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 	 **/
594 594
 	protected function configure() {
595 595
 		// set ARGS
596
-		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET;
596
+		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
597 597
 		// set thumbnails path
598 598
 		$path = $this->options['tmbPath'];
599 599
 		if ($path) {
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 		
625 625
 		// check 'statOwner' for command `chmod`
626 626
 		if (empty($this->options['statOwner'])) {
627
-			$this->disabled[] ='chmod';
627
+			$this->disabled[] = 'chmod';
628 628
 		}
629 629
 		
630 630
 		// check 'mimeMap'
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 	 **/
749 749
 	public function mount(array $opts) {
750 750
 		if (!isset($opts['path']) || $opts['path'] === '') {
751
-			return $this->setError('Path undefined.');;
751
+			return $this->setError('Path undefined.'); ;
752 752
 		}
753 753
 		
754 754
 		$this->options = array_merge($this->options, $opts);
@@ -767,14 +767,14 @@  discard block
 block discarded – undo
767 767
 		$argInit = !empty($this->ARGS['init']);
768 768
 		
769 769
 		// session cache
770
-		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
770
+		if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
771 771
 			$_SESSION[elFinder::$sessionCacheKey][$this->id] = array();
772 772
 		}
773 773
 		$this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id];
774 774
 		
775 775
 		// default file attribute
776 776
 		$this->defaults = array(
777
-			'read'    => isset($this->options['defaults']['read'])  ? !!$this->options['defaults']['read']  : true,
777
+			'read'    => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true,
778 778
 			'write'   => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true,
779 779
 			'locked'  => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false,
780 780
 			'hidden'  => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false
@@ -801,8 +801,8 @@  discard block
 block discarded – undo
801 801
 			$this->access = $this->options['accessControl'];
802 802
 		}
803 803
 		
804
-		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y'));
805
-		$this->yesterday = $this->today-86400;
804
+		$this->today     = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
805
+		$this->yesterday = $this->today - 86400;
806 806
 		
807 807
 		// debug($this->attributes);
808 808
 		if (!$this->init()) {
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 				foreach ($mimecf as $line_num => $line) {
902 902
 					if (!preg_match('/^\s*#/', $line)) {
903 903
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
904
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
904
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
905 905
 							if (!isset(self::$mimetypes[$mime[$i]])) {
906 906
 								self::$mimetypes[$mime[$i]] = $mime[0];
907 907
 							}
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 		
931 931
 		if ($root['read']) {
932 932
 			// check startPath - path to open by default instead of root
933
-			$startPath = $this->options['startPath']? $this->normpathCE($this->options['startPath']) : '';
933
+			$startPath = $this->options['startPath'] ? $this->normpathCE($this->options['startPath']) : '';
934 934
 			if ($startPath) {
935 935
 				$start = $this->stat($startPath);
936 936
 				if (!empty($start)
@@ -954,8 +954,8 @@  discard block
 block discarded – undo
954 954
 				'read'    => false
955 955
 			));
956 956
 		}
957
-		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1;
958
-		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48;
957
+		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1;
958
+		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48;
959 959
 		$this->URL      = $this->options['URL'];
960 960
 		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) {
961 961
 			$this->URL .= '/';
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 		$this->configure();
1009 1009
 		
1010 1010
 		// fix sync interval
1011
-		$this->options['syncMinMs'] = max($this->options[$this->options['syncChkAsTs']? 'tsPlSleep' : 'lsPlSleep'] * 1000, intval($this->options['syncMinMs']));
1011
+		$this->options['syncMinMs'] = max($this->options[$this->options['syncChkAsTs'] ? 'tsPlSleep' : 'lsPlSleep']*1000, intval($this->options['syncMinMs']));
1012 1012
 
1013 1013
 
1014 1014
 		return $this->mounted = true;
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 	public function options($hash) {
1113 1113
 		$create = $createext = array();
1114 1114
 		if (isset($this->archivers['create']) && is_array($this->archivers['create'])) {
1115
-			foreach($this->archivers['create'] as $m => $v) {
1115
+			foreach ($this->archivers['create'] as $m => $v) {
1116 1116
 				$create[] = $m;
1117 1117
 				$createext[$m] = $v['ext'];
1118 1118
 			}
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 				'extract'   => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(),
1134 1134
 				'createext' => $createext
1135 1135
 			),
1136
-			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(),
1136
+			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(),
1137 1137
 			'syncChkAsTs'     => intval($this->options['syncChkAsTs']),
1138 1138
 			'syncMinMs'       => intval($this->options['syncMinMs'])
1139 1139
 		);
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 	 * @author Naoki Sawada
1148 1148
 	 */
1149 1149
 	public function getOption($name) {
1150
-		return isset($this->options[$name])? $this->options[$name] : null;
1150
+		return isset($this->options[$name]) ? $this->options[$name] : null;
1151 1151
 	}
1152 1152
 	
1153 1153
 	/**
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 	 */
1160 1160
 	public function getOptionsPlugin($name = '') {
1161 1161
 		if ($name) {
1162
-			return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array();
1162
+			return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array();
1163 1163
 		} else {
1164 1164
 			return $this->options['plugin'];
1165 1165
 		}
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 		$file = $this->stat($path);
1294 1294
 		
1295 1295
 		if ($isRoot) {
1296
-			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array();
1296
+			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array();
1297 1297
 			$file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON
1298 1298
 		}
1299 1299
 		
@@ -1308,7 +1308,7 @@  discard block
 block discarded – undo
1308 1308
 	 * @return array|false
1309 1309
 	 * @author Dmitry (dio) Levashov
1310 1310
 	 **/
1311
-	public function dir($hash, $resolveLink=false) {
1311
+	public function dir($hash, $resolveLink = false) {
1312 1312
 		if (($dir = $this->file($hash)) == false) {
1313 1313
 			return $this->setError(elFinder::ERROR_DIR_NOT_FOUND);
1314 1314
 		}
@@ -1372,14 +1372,14 @@  discard block
 block discarded – undo
1372 1372
 	 * @return array|false
1373 1373
 	 * @author Dmitry (dio) Levashov
1374 1374
 	 **/
1375
-	public function tree($hash='', $deep=0, $exclude='') {
1375
+	public function tree($hash = '', $deep = 0, $exclude = '') {
1376 1376
 		$path = $hash ? $this->decode($hash) : $this->root;
1377 1377
 		
1378 1378
 		if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') {
1379 1379
 			return false;
1380 1380
 		}
1381 1381
 		
1382
-		$dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null);
1382
+		$dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null);
1383 1383
 		array_unshift($dirs, $dir);
1384 1384
 		return $dirs;
1385 1385
 	}
@@ -1609,7 +1609,7 @@  discard block
 block discarded – undo
1609 1609
 	 * @return array|false
1610 1610
 	 * @author Dmitry (dio) Levashov
1611 1611
 	 **/
1612
-	public function duplicate($hash, $suffix='copy') {
1612
+	public function duplicate($hash, $suffix = 'copy') {
1613 1613
 		if ($this->commandDisabled('duplicate')) {
1614 1614
 			return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED);
1615 1615
 		}
@@ -1685,7 +1685,7 @@  discard block
 block discarded – undo
1685 1685
 		
1686 1686
 		if ($file) { // file exists
1687 1687
 			// check POST data `overwrite` for 3rd party uploader
1688
-			$overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite'];
1688
+			$overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite'];
1689 1689
 			if ($overwrite) {
1690 1690
 				if (!$file['write']) {
1691 1691
 					return $this->setError(elFinder::ERROR_PERM_DENIED);
@@ -1756,7 +1756,7 @@  discard block
 block discarded – undo
1756 1756
 		if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) {
1757 1757
 			return $rmSrc
1758 1758
 				? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test))
1759
-				: $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1759
+				: $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1760 1760
 		}
1761 1761
 
1762 1762
 		$test = $this->joinPathCE($destination, $name);
@@ -1919,7 +1919,7 @@  discard block
 block discarded – undo
1919 1919
 			return $this->setError(elFinder::ERROR_PERM_DENIED);
1920 1920
 		}
1921 1921
 		$this->clearcache();
1922
-		$this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir;
1922
+		$this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir;
1923 1923
 		
1924 1924
 		if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) {
1925 1925
 			if (is_array($path)) {
@@ -1977,9 +1977,9 @@  discard block
 block discarded – undo
1977 1977
 		if ($name === '') {
1978 1978
 			$name = count($files) == 1 ? $files[0] : 'Archive';
1979 1979
 		} else {
1980
-			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name));
1980
+			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name));
1981 1981
 		}
1982
-		$name .='.' . $archiver['ext'];
1982
+		$name .= '.'.$archiver['ext'];
1983 1983
 		$name = $this->uniqueName($dir, $name, '');
1984 1984
 		$this->clearcache();
1985 1985
 		return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false;
@@ -2018,7 +2018,7 @@  discard block
 block discarded – undo
2018 2018
 		
2019 2019
 		$path = $this->decode($hash);
2020 2020
 		
2021
-		$work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path);
2021
+		$work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path);
2022 2022
 
2023 2023
 		if (!$work_path || !is_writable($work_path)) {
2024 2024
 			if ($work_path && $path !== $work_path && is_file($work_path)) {
@@ -2033,7 +2033,7 @@  discard block
 block discarded – undo
2033 2033
 			}
2034 2034
 		}
2035 2035
 
2036
-		switch($mode) {
2036
+		switch ($mode) {
2037 2037
 			
2038 2038
 			case 'propresize':
2039 2039
 				$result = $this->imgResize($work_path, $width, $height, true, true, null, $jpgQuality);
@@ -2129,7 +2129,7 @@  discard block
 block discarded – undo
2129 2129
 		}
2130 2130
 		return ($q === '' || $this->commandDisabled('search'))
2131 2131
 			? array()
2132
-			: $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes);
2132
+			: $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes);
2133 2133
 	}
2134 2134
 	
2135 2135
 	/**
@@ -2201,9 +2201,9 @@  discard block
 block discarded – undo
2201 2201
 		$path = ltrim($path, $this->separator);
2202 2202
 		$dirs = explode($this->separator, $path);
2203 2203
 		array_pop($dirs);
2204
-		foreach($dirs as $dir) {
2204
+		foreach ($dirs as $dir) {
2205 2205
 			$targetPath = $this->joinPathCE($base, $dir);
2206
-			if (! $_realpath = $this->realpath($this->encode($targetPath))) {
2206
+			if (!$_realpath = $this->realpath($this->encode($targetPath))) {
2207 2207
 				if ($stat = $this->mkdir($targetHash, $dir)) {
2208 2208
 					$result['added'][] = $stat;
2209 2209
 					$targetHash = $stat['hash'];
@@ -2270,7 +2270,7 @@  discard block
 block discarded – undo
2270 2270
 	 * @author Naoki Sawada
2271 2271
 	 **/
2272 2272
 	protected function dirnameCE($path) {
2273
-		return (!$this->encoding)? $this->_dirname($path) :	$this->convEncOut($this->_dirname($this->convEncIn($path)));
2273
+		return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path)));
2274 2274
 	}
2275 2275
 	
2276 2276
 	/**
@@ -2281,7 +2281,7 @@  discard block
 block discarded – undo
2281 2281
 	 * @author Naoki Sawada
2282 2282
 	 **/
2283 2283
 	protected function basenameCE($path) {
2284
-		return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2284
+		return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2285 2285
 	}
2286 2286
 	
2287 2287
 	/**
@@ -2294,7 +2294,7 @@  discard block
 block discarded – undo
2294 2294
 	 * @author Naoki Sawada
2295 2295
 	 **/
2296 2296
 	protected function joinPathCE($dir, $name) {
2297
-		return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2297
+		return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2298 2298
 	}
2299 2299
 	
2300 2300
 	/**
@@ -2305,7 +2305,7 @@  discard block
 block discarded – undo
2305 2305
 	 * @author Naoki Sawada
2306 2306
 	 **/
2307 2307
 	protected function normpathCE($path) {
2308
-		return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2308
+		return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2309 2309
 	}
2310 2310
 	
2311 2311
 	/**
@@ -2316,7 +2316,7 @@  discard block
 block discarded – undo
2316 2316
 	 * @author Naoki Sawada
2317 2317
 	 **/
2318 2318
 	protected function relpathCE($path) {
2319
-		return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2319
+		return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2320 2320
 	}
2321 2321
 	
2322 2322
 	/**
@@ -2327,7 +2327,7 @@  discard block
 block discarded – undo
2327 2327
 	 * @author Naoki Sawada
2328 2328
 	 **/
2329 2329
 	protected function abspathCE($path) {
2330
-		return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path)));
2330
+		return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path)));
2331 2331
 	}
2332 2332
 	
2333 2333
 	/**
@@ -2339,7 +2339,7 @@  discard block
 block discarded – undo
2339 2339
 	 * @author Naoki Sawada
2340 2340
 	 **/
2341 2341
 	protected function inpathCE($path, $parent) {
2342
-		return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2342
+		return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2343 2343
 	}
2344 2344
 	
2345 2345
 	/**
@@ -2350,8 +2350,8 @@  discard block
 block discarded – undo
2350 2350
 	 * @return resource|false
2351 2351
 	 * @author Naoki Sawada
2352 2352
 	 **/
2353
-	protected function fopenCE($path, $mode='rb') {
2354
-		return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2353
+	protected function fopenCE($path, $mode = 'rb') {
2354
+		return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2355 2355
 	}
2356 2356
 	
2357 2357
 	/**
@@ -2362,8 +2362,8 @@  discard block
 block discarded – undo
2362 2362
 	 * @return bool
2363 2363
 	 * @author Naoki Sawada
2364 2364
 	 **/
2365
-	protected function fcloseCE($fp, $path='') {
2366
-		return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2365
+	protected function fcloseCE($fp, $path = '') {
2366
+		return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2367 2367
 	}
2368 2368
 	
2369 2369
 	/**
@@ -2378,7 +2378,7 @@  discard block
 block discarded – undo
2378 2378
 	 * @author Naoki Sawada
2379 2379
 	 **/
2380 2380
 	protected function saveCE($fp, $dir, $name, $stat) {
2381
-		return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2381
+		return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2382 2382
 	}
2383 2383
 	
2384 2384
 	/**
@@ -2390,7 +2390,7 @@  discard block
 block discarded – undo
2390 2390
 	 **/
2391 2391
 	protected function subdirsCE($path) {
2392 2392
 		if (!isset($this->subdirsCache[$path])) {
2393
-			$this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2393
+			$this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2394 2394
 		}
2395 2395
 		return $this->subdirsCache[$path];
2396 2396
 	}
@@ -2403,7 +2403,7 @@  discard block
 block discarded – undo
2403 2403
 	 * @author Naoki Sawada
2404 2404
 	 **/
2405 2405
 	protected function scandirCE($path) {
2406
-		return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2406
+		return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2407 2407
 	}
2408 2408
 	
2409 2409
 	/**
@@ -2416,7 +2416,7 @@  discard block
 block discarded – undo
2416 2416
 	 * @author Naoki Sawada
2417 2417
 	 **/
2418 2418
 	protected function symlinkCE($source, $targetDir, $name) {
2419
-		return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2419
+		return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2420 2420
 	}
2421 2421
 	
2422 2422
 	/***************** paths *******************/
@@ -2435,7 +2435,7 @@  discard block
 block discarded – undo
2435 2435
 			// cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root
2436 2436
 			$p = $this->relpathCE($path);
2437 2437
 			// if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt
2438
-			if ($p === '')	{
2438
+			if ($p === '') {
2439 2439
 				$p = DIRECTORY_SEPARATOR;
2440 2440
 			}
2441 2441
 
@@ -2468,7 +2468,7 @@  discard block
 block discarded – undo
2468 2468
 			// TODO uncrypt hash and return path
2469 2469
 			$path = $this->uncrypt($h); 
2470 2470
 			// append ROOT to path after it was cut in encode
2471
-			return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2471
+			return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2472 2472
 		}
2473 2473
 	}
2474 2474
 	
@@ -2528,21 +2528,21 @@  discard block
 block discarded – undo
2528 2528
 	 * @author Dmitry (dio) Levashov
2529 2529
 	 **/
2530 2530
 	public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) {
2531
-		$ext  = '';
2531
+		$ext = '';
2532 2532
 
2533 2533
 		if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
2534 2534
 			$ext  = '.'.$m[1];
2535
-			$name = substr($name, 0,  strlen($name)-strlen($m[0]));
2535
+			$name = substr($name, 0, strlen($name) - strlen($m[0]));
2536 2536
 		} 
2537 2537
 		
2538 2538
 		if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) {
2539
-			$i    = (int)$m[2];
2540
-			$name = substr($name, 0, strlen($name)-strlen($m[2]));
2539
+			$i    = (int) $m[2];
2540
+			$name = substr($name, 0, strlen($name) - strlen($m[2]));
2541 2541
 		} else {
2542 2542
 			$i     = $start;
2543 2543
 			$name .= $suffix;
2544 2544
 		}
2545
-		$max = $i+100000;
2545
+		$max = $i + 100000;
2546 2546
 
2547 2547
 		while ($i <= $max) {
2548 2548
 			$n = $name.($i > 0 ? $i : '').$ext;
@@ -2566,7 +2566,7 @@  discard block
 block discarded – undo
2566 2566
 	 * @author Naoki Sawada
2567 2567
 	 */
2568 2568
 	public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') {
2569
-		return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2569
+		return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2570 2570
 	}
2571 2571
 	
2572 2572
 	/**
@@ -2579,7 +2579,7 @@  discard block
 block discarded – undo
2579 2579
 	 * @author Naoki Sawada
2580 2580
 	 */
2581 2581
 	public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') {
2582
-		return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2582
+		return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2583 2583
 	}
2584 2584
 	
2585 2585
 	/**
@@ -2599,7 +2599,7 @@  discard block
 block discarded – undo
2599 2599
 			}
2600 2600
 			if (is_array($var)) {
2601 2601
 				$_ret = array();
2602
-				foreach($var as $_k => $_v) {
2602
+				foreach ($var as $_k => $_v) {
2603 2603
 					$_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_');
2604 2604
 				}
2605 2605
 				$var = $_ret;
@@ -2611,7 +2611,7 @@  discard block
 block discarded – undo
2611 2611
 						$_var = str_replace('?', $unknown, $_var);
2612 2612
 					}
2613 2613
 				}
2614
-				if  ($_var !== false) {
2614
+				if ($_var !== false) {
2615 2615
 					$var = $_var;
2616 2616
 				}
2617 2617
 			}
@@ -2638,7 +2638,7 @@  discard block
 block discarded – undo
2638 2638
 		
2639 2639
 		$key = '';
2640 2640
 		if ($path !== '') {
2641
-			$key = $this->id . '#' . $path;
2641
+			$key = $this->id.'#'.$path;
2642 2642
 			if (isset($cache[$key])) {
2643 2643
 				return $cache[$key];
2644 2644
 			}
@@ -2670,7 +2670,7 @@  discard block
 block discarded – undo
2670 2670
 		if ($work = $this->getTempFile()) {
2671 2671
 			if ($wfp = fopen($work, 'wb')) {
2672 2672
 				if ($fp = $this->_fopen($path)) {
2673
-					while(!feof($fp)) {
2673
+					while (!feof($fp)) {
2674 2674
 						fwrite($wfp, fread($fp, 8192));
2675 2675
 					}
2676 2676
 					$this->_fclose($fp, $path);
@@ -2714,7 +2714,7 @@  discard block
 block discarded – undo
2714 2714
 			@set_time_limit(30);
2715 2715
 			$stat = $this->stat($this->convEncOut($p));
2716 2716
 			$this->convEncIn();
2717
-			($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p);
2717
+			($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p);
2718 2718
 		}
2719 2719
 		return $this->_rmdir($localpath);
2720 2720
 	}
@@ -2731,7 +2731,7 @@  discard block
 block discarded – undo
2731 2731
 	 * @return bool
2732 2732
 	 * @author Dmitry (dio) Levashov
2733 2733
 	 **/
2734
-	protected function attr($path, $name, $val=null, $isDir=null) {
2734
+	protected function attr($path, $name, $val = null, $isDir = null) {
2735 2735
 		if (!isset($this->defaults[$name])) {
2736 2736
 			return false;
2737 2737
 		}
@@ -2763,7 +2763,7 @@  discard block
 block discarded – undo
2763 2763
 			} 
2764 2764
 		}
2765 2765
 		
2766
-		return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm;
2766
+		return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm;
2767 2767
 	}
2768 2768
 	
2769 2769
 	/**
@@ -2807,7 +2807,7 @@  discard block
 block discarded – undo
2807 2807
 	protected function allowPutMime($mime) {
2808 2808
 		// logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order
2809 2809
 		$allow  = $this->mimeAccepted($mime, $this->uploadAllow, null);
2810
-		$deny   = $this->mimeAccepted($mime, $this->uploadDeny,  null);
2810
+		$deny   = $this->mimeAccepted($mime, $this->uploadDeny, null);
2811 2811
 		$res = true; // default to allow
2812 2812
 		if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny'
2813 2813
 			$res = false; // default is deny
@@ -2841,7 +2841,7 @@  discard block
 block discarded – undo
2841 2841
 				$this->sessionCache['rootstat'] = array();
2842 2842
 			}
2843 2843
 			//if (empty($this->ARGS['reload']) || empty($this->ARGS['target']) || strpos($this->ARGS['target'], $this->id) !== 0) {
2844
-			if (! $this->isMyReload()) {
2844
+			if (!$this->isMyReload()) {
2845 2845
 				// need $path as key for netmount/netunmount
2846 2846
 				if (isset($this->sessionCache['rootstat'][$rootKey])) {
2847 2847
 					if ($ret = elFinder::sessionDataDecode($this->sessionCache['rootstat'][$rootKey], 'array')) {
@@ -2881,10 +2881,10 @@  discard block
 block discarded – undo
2881 2881
 			if ($this->rootName) {
2882 2882
 				$stat['name'] = $this->rootName;
2883 2883
 			}
2884
-			if (! empty($this->options['icon'])) {
2884
+			if (!empty($this->options['icon'])) {
2885 2885
 				$stat['icon'] = $this->options['icon'];
2886 2886
 			}
2887
-			if (! empty($this->options['rootCssClass'])) {
2887
+			if (!empty($this->options['rootCssClass'])) {
2888 2888
 				$stat['csscls'] = $this->options['rootCssClass'];
2889 2889
 			}
2890 2890
 		} else {
@@ -2932,7 +2932,7 @@  discard block
 block discarded – undo
2932 2932
 			// lock when parent directory is not writable
2933 2933
 			if (!isset($stat['locked'])) {
2934 2934
 				$parent = $this->dirnameCE($path);
2935
-				$pstat = isset($this->cache[$parent])? $this->cache[$parent] : array();
2935
+				$pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array();
2936 2936
 				if (isset($pstat['write']) && !$pstat['write']) {
2937 2937
 					$stat['locked'] = true;
2938 2938
 				}
@@ -2990,7 +2990,7 @@  discard block
 block discarded – undo
2990 2990
 			}
2991 2991
 			if (!isset($stat['url']) && $this->URL && $this->encoding) {
2992 2992
 				$_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1));
2993
-				$stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN')? $_path : $this->convEncIn($_path, true)));
2993
+				$stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN') ? $_path : $this->convEncIn($_path, true)));
2994 2994
 			}
2995 2995
 		} else {
2996 2996
 			if ($isDir) {
@@ -3113,7 +3113,7 @@  discard block
 block discarded – undo
3113 3113
 				foreach ($mimecf as $line_num => $line) {
3114 3114
 					if (!preg_match('/^\s*#/', $line)) {
3115 3115
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
3116
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
3116
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
3117 3117
 							if (!isset(elFinderVolumeDriver::$mimetypes[$mime[$i]])) {
3118 3118
 								elFinderVolumeDriver::$mimetypes[$mime[$i]] = $mime[0];
3119 3119
 							}
@@ -3219,10 +3219,10 @@  discard block
 block discarded – undo
3219 3219
 	}
3220 3220
 	
3221 3221
 	protected function isMyReload($target = '', $ARGtarget = '') {
3222
-		if (! empty($this->ARGS['reload'])) {
3222
+		if (!empty($this->ARGS['reload'])) {
3223 3223
 			if ($ARGtarget === '') {
3224
-				$ARGtarget = isset($this->ARGS['target'])? $this->ARGS['target']
3225
-					: ((isset($this->ARGS['targets']) && is_array($this->ARGS['targets']) && count($this->ARGS['targets']) === 1)?
3224
+				$ARGtarget = isset($this->ARGS['target']) ? $this->ARGS['target']
3225
+					: ((isset($this->ARGS['targets']) && is_array($this->ARGS['targets']) && count($this->ARGS['targets']) === 1) ?
3226 3226
 						$this->ARGS['targets'][0] : '');
3227 3227
 			}
3228 3228
 			if ($ARGtarget !== '') {
@@ -3271,7 +3271,7 @@  discard block
 block discarded – undo
3271 3271
 	 * @return array
3272 3272
 	 * @author Dmitry (dio) Levashov
3273 3273
 	 **/
3274
-	protected function gettree($path, $deep, $exclude='') {
3274
+	protected function gettree($path, $deep, $exclude = '') {
3275 3275
 		$dirs = array();
3276 3276
 		
3277 3277
 		!isset($this->dirsCache[$path]) && $this->cacheDir($path);
@@ -3282,7 +3282,7 @@  discard block
 block discarded – undo
3282 3282
 			if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') {
3283 3283
 				$dirs[] = $stat;
3284 3284
 				if ($deep > 0 && !empty($stat['dirs'])) {
3285
-					$dirs = array_merge($dirs, $this->gettree($p, $deep-1));
3285
+					$dirs = array_merge($dirs, $this->gettree($p, $deep - 1));
3286 3286
 				}
3287 3287
 			}
3288 3288
 		}
@@ -3302,7 +3302,7 @@  discard block
 block discarded – undo
3302 3302
 	protected function doSearch($path, $q, $mimes) {
3303 3303
 		$result = array();
3304 3304
 
3305
-		foreach($this->scandirCE($path) as $p) {
3305
+		foreach ($this->scandirCE($path) as $p) {
3306 3306
 			@set_time_limit(30);
3307 3307
 			$stat = $this->stat($p);
3308 3308
 
@@ -3323,7 +3323,7 @@  discard block
 block discarded – undo
3323 3323
 					if ($this->encoding) {
3324 3324
 						$path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true)));
3325 3325
 					}
3326
-					$stat['url'] = $this->URL . $path;
3326
+					$stat['url'] = $this->URL.$path;
3327 3327
 				}
3328 3328
 				
3329 3329
 				$result[] = $stat;
@@ -3357,7 +3357,7 @@  discard block
 block discarded – undo
3357 3357
 			if (!$this->inpathCE($target, $this->root)) {
3358 3358
 				return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK);
3359 3359
 			}
3360
-			$stat   = $this->stat($target);
3360
+			$stat = $this->stat($target);
3361 3361
 			$this->clearcache();
3362 3362
 			return $stat && $this->symlinkCE($target, $dst, $name)
3363 3363
 				? $this->joinPathCE($dst, $name)
@@ -3638,15 +3638,15 @@  discard block
 block discarded – undo
3638 3638
 		}
3639 3639
 
3640 3640
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
3641
-		if ($s[0] <= $tmbSize && $s[1]	<= $tmbSize) {
3642
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3641
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
3642
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3643 3643
 		} else {
3644 3644
 		
3645 3645
 			if ($this->options['tmbCrop']) {
3646 3646
 		
3647 3647
 				$result = $tmb;
3648 3648
 				/* Resize and crop if image bigger than thumbnail */
3649
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3649
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3650 3650
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
3651 3651
 				}
3652 3652
 		
@@ -3663,7 +3663,7 @@  discard block
 block discarded – undo
3663 3663
 			}
3664 3664
 		
3665 3665
 			if ($result) {
3666
-				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3666
+				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3667 3667
 			}
3668 3668
 		}
3669 3669
 		
@@ -3709,18 +3709,18 @@  discard block
 block discarded – undo
3709 3709
 			/* Resizing by biggest side */
3710 3710
 			if ($resizeByBiggerSide) {
3711 3711
 				if ($orig_w > $orig_h) {
3712
-					$size_h = round($orig_h * $width / $orig_w);
3712
+					$size_h = round($orig_h*$width/$orig_w);
3713 3713
 					$size_w = $width;
3714 3714
 				} else {
3715
-					$size_w = round($orig_w * $height / $orig_h);
3715
+					$size_w = round($orig_w*$height/$orig_h);
3716 3716
 					$size_h = $height;
3717 3717
 				}
3718 3718
 			} else {
3719 3719
 				if ($orig_w > $orig_h) {
3720
-					$size_w = round($orig_w * $height / $orig_h);
3720
+					$size_w = round($orig_w*$height/$orig_h);
3721 3721
 					$size_h = $height;
3722 3722
 				} else {
3723
-					$size_h = round($orig_h * $width / $orig_w);
3723
+					$size_h = round($orig_h*$width/$orig_w);
3724 3724
 					$size_w = $width;
3725 3725
 				}
3726 3726
 			}
@@ -3738,7 +3738,7 @@  discard block
 block discarded – undo
3738 3738
 				// Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb
3739 3739
 				// resize bench: http://app-mgng.rhcloud.com/9
3740 3740
 				// resize sample: http://www.dylanbeattie.net/magick/filters/result.html
3741
-				$filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3741
+				$filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3742 3742
 				
3743 3743
 				$ani = ($img->getNumberImages() > 1);
3744 3744
 				if ($ani && is_null($destformat)) {
@@ -3763,11 +3763,11 @@  discard block
 block discarded – undo
3763 3763
 				break;
3764 3764
 
3765 3765
 			case 'gd':
3766
-				$img = $this->gdImageCreate($path,$s['mime']);
3766
+				$img = $this->gdImageCreate($path, $s['mime']);
3767 3767
 
3768
-				if ($img &&  false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3768
+				if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3769 3769
 				
3770
-					$this->gdImageBackground($tmp,$this->options['tmbBgColor']);
3770
+					$this->gdImageBackground($tmp, $this->options['tmbBgColor']);
3771 3771
 					
3772 3772
 					if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) {
3773 3773
 						return false;
@@ -3848,11 +3848,11 @@  discard block
 block discarded – undo
3848 3848
 				break;
3849 3849
 
3850 3850
 			case 'gd':
3851
-				$img = $this->gdImageCreate($path,$s['mime']);
3851
+				$img = $this->gdImageCreate($path, $s['mime']);
3852 3852
 
3853
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3853
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3854 3854
 					
3855
-					$this->gdImageBackground($tmp,$this->options['tmbBgColor']);
3855
+					$this->gdImageBackground($tmp, $this->options['tmbBgColor']);
3856 3856
 
3857 3857
 					$size_w = $width;
3858 3858
 					$size_h = $height;
@@ -3903,8 +3903,8 @@  discard block
 block discarded – undo
3903 3903
 		$result = false;
3904 3904
 
3905 3905
 		/* Coordinates for image over square aligning */
3906
-		$y = ceil(abs($height - $s[1]) / 2); 
3907
-		$x = ceil(abs($width - $s[0]) / 2);
3906
+		$y = ceil(abs($height - $s[1])/2); 
3907
+		$x = ceil(abs($width - $s[0])/2);
3908 3908
 
3909 3909
 		if (!$jpgQuality) {
3910 3910
 			$jpgQuality = $this->options['jpgQuality'];
@@ -3928,7 +3928,7 @@  discard block
 block discarded – undo
3928 3928
 						$gif->newImage($width, $height, new ImagickPixel($bgcolor));
3929 3929
 						$gif->setImageColorspace($img->getImageColorspace());
3930 3930
 						$gif->setImageFormat('gif');
3931
-						$gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3931
+						$gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3932 3932
 						$gif->setImageDelay($img->getImageDelay());
3933 3933
 						$gif->setImageIterations($img->getImageIterations());
3934 3934
 						$img1->addImage($gif);
@@ -3943,7 +3943,7 @@  discard block
 block discarded – undo
3943 3943
 					$img1 = new Imagick();
3944 3944
 					$img1->newImage($width, $height, new ImagickPixel($bgcolor));
3945 3945
 					$img1->setImageColorspace($img->getImageColorspace());
3946
-					$img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3946
+					$img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3947 3947
 					$result = $this->imagickImage($img, $path, $destformat, $jpgQuality);
3948 3948
 				}
3949 3949
 				
@@ -3954,11 +3954,11 @@  discard block
 block discarded – undo
3954 3954
 				break;
3955 3955
 
3956 3956
 			case 'gd':
3957
-				$img = $this->gdImageCreate($path,$s['mime']);
3957
+				$img = $this->gdImageCreate($path, $s['mime']);
3958 3958
 
3959
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3959
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3960 3960
 
3961
-					$this->gdImageBackground($tmp,$bgcolor);
3961
+					$this->gdImageBackground($tmp, $bgcolor);
3962 3962
 
3963 3963
 					if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) {
3964 3964
 						return false;
@@ -3990,15 +3990,15 @@  discard block
 block discarded – undo
3990 3990
 	 * @author Troex Nevelin
3991 3991
 	 **/
3992 3992
 	protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null, $jpgQuality = null) {
3993
-		if (($s = @getimagesize($path)) == false || $degree % 360 === 0) {
3993
+		if (($s = @getimagesize($path)) == false || $degree%360 === 0) {
3994 3994
 			return false;
3995 3995
 		}
3996 3996
 
3997 3997
 		$result = false;
3998 3998
 
3999 3999
 		// try lossless rotate
4000
-		if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
4001
-			$count = ($degree / 90) % 4;
4000
+		if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
4001
+			$count = ($degree/90)%4;
4002 4002
 			$exiftran = array(
4003 4003
 				1 => '-9',
4004 4004
 				2 => '-1',
@@ -4014,7 +4014,7 @@  discard block
 block discarded – undo
4014 4014
 				'exiftran -i '.$exiftran[$count].' '.$path,
4015 4015
 				'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath
4016 4016
 			);
4017
-			foreach($cmds as $cmd) {
4017
+			foreach ($cmds as $cmd) {
4018 4018
 				if ($this->procExec($cmd) === 0) {
4019 4019
 					$result = true;
4020 4020
 					break;
@@ -4054,12 +4054,12 @@  discard block
 block discarded – undo
4054 4054
 				break;
4055 4055
 
4056 4056
 			case 'gd':
4057
-				$img = $this->gdImageCreate($path,$s['mime']);
4057
+				$img = $this->gdImageCreate($path, $s['mime']);
4058 4058
 
4059 4059
 				$degree = 360 - $degree;
4060 4060
 				list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4061 4061
 				$bgcolor = imagecolorallocate($img, $r, $g, $b);
4062
-				$tmp = imageRotate($img, $degree, (int)$bgcolor);
4062
+				$tmp = imageRotate($img, $degree, (int) $bgcolor);
4063 4063
 
4064 4064
 				$result = $this->gdImage($tmp, $path, $destformat, $s['mime'], $jpgQuality);
4065 4065
 
@@ -4084,11 +4084,11 @@  discard block
 block discarded – undo
4084 4084
 	 * @return int     exit code
4085 4085
 	 * @author Alexey Sukhotin
4086 4086
 	 **/
4087
-	protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) {
4087
+	protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) {
4088 4088
 
4089 4089
 		$descriptorspec = array(
4090
-			0 => array("pipe", "r"),  // stdin
4091
-			1 => array("pipe", "w"),  // stdout
4090
+			0 => array("pipe", "r"), // stdin
4091
+			1 => array("pipe", "w"), // stdout
4092 4092
 			2 => array("pipe", "w")   // stderr
4093 4093
 		);
4094 4094
 
@@ -4145,8 +4145,8 @@  discard block
 block discarded – undo
4145 4145
 	 * @param string $mime
4146 4146
 	 * @return gd image resource identifier
4147 4147
 	 */
4148
-	protected function gdImageCreate($path,$mime){
4149
-		switch($mime){
4148
+	protected function gdImageCreate($path, $mime) {
4149
+		switch ($mime) {
4150 4150
 			case 'image/jpeg':
4151 4151
 			return imagecreatefromjpeg($path);
4152 4152
 
@@ -4171,7 +4171,7 @@  discard block
 block discarded – undo
4171 4171
 	 * @param string $mime The original image mime type
4172 4172
 	 * @param int    $jpgQuality  JEPG quality (1-100)
4173 4173
 	 */
4174
-	protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null ){
4174
+	protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null) {
4175 4175
 
4176 4176
 		if (!$jpgQuality) {
4177 4177
 			$jpgQuality = $this->options['jpgQuality'];
@@ -4195,7 +4195,7 @@  discard block
 block discarded – undo
4195 4195
 	 * @param string $destformat The Image type to use for $filename
4196 4196
 	 * @param int    $jpgQuality  JEPG quality (1-100)
4197 4197
 	 */
4198
-	protected function imagickImage($img, $filename, $destformat, $jpgQuality = null ){
4198
+	protected function imagickImage($img, $filename, $destformat, $jpgQuality = null) {
4199 4199
 
4200 4200
 		if (!$jpgQuality) {
4201 4201
 			$jpgQuality = $this->options['jpgQuality'];
@@ -4250,13 +4250,13 @@  discard block
 block discarded – undo
4250 4250
 	 * @param resource $image gd image resource
4251 4251
 	 * @param string $bgcolor background color in #rrggbb format
4252 4252
 	 */
4253
-	protected function gdImageBackground($image, $bgcolor){
4253
+	protected function gdImageBackground($image, $bgcolor) {
4254 4254
 
4255
-		if( $bgcolor == 'transparent' ){
4256
-			imagesavealpha($image,true);
4255
+		if ($bgcolor == 'transparent') {
4256
+			imagesavealpha($image, true);
4257 4257
 			$bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127);
4258 4258
 
4259
-		}else{
4259
+		} else {
4260 4260
 			list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4261 4261
 			$bgcolor1 = imagecolorallocate($image, $r, $g, $b);
4262 4262
 		}
@@ -4294,13 +4294,13 @@  discard block
 block discarded – undo
4294 4294
 	* @return int|bool
4295 4295
 	* @author Alexey Sukhotin
4296 4296
 	**/
4297
-	protected function stripos($haystack , $needle , $offset = 0) {
4297
+	protected function stripos($haystack, $needle, $offset = 0) {
4298 4298
 		if (function_exists('mb_stripos')) {
4299
-			return mb_stripos($haystack , $needle , $offset, 'UTF-8');
4299
+			return mb_stripos($haystack, $needle, $offset, 'UTF-8');
4300 4300
 		} else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) {
4301 4301
 			return mb_strpos(mb_strtolower($haystack, 'UTF-8'), mb_strtolower($needle, 'UTF-8'), $offset);
4302 4302
 		} 
4303
-		return stripos($haystack , $needle , $offset);
4303
+		return stripos($haystack, $needle, $offset);
4304 4304
 	}
4305 4305
 
4306 4306
 	/**
@@ -4350,22 +4350,22 @@  discard block
 block discarded – undo
4350 4350
 			unset($o);
4351 4351
 			$this->procExec('zip -v', $o, $c);
4352 4352
 			if ($c == 0) {
4353
-				$arcs['create']['application/zip']  = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4353
+				$arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4354 4354
 			}
4355 4355
 			unset($o);
4356 4356
 			$this->procExec('unzip --help', $o, $c);
4357 4357
 			if ($c == 0) {
4358
-				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '',  'ext' => 'zip');
4358
+				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip');
4359 4359
 			}
4360 4360
 			unset($o);
4361 4361
 			$this->procExec('rar --version', $o, $c);
4362 4362
 			if ($c == 0 || $c == 7) {
4363 4363
 				$arcs['create']['application/x-rar']  = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar');
4364
-				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y',    'ext' => 'rar');
4364
+				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar');
4365 4365
 			} else {
4366 4366
 				unset($o);
4367 4367
 				$test = $this->procExec('unrar', $o, $c);
4368
-				if ($c==0 || $c == 7) {
4368
+				if ($c == 0 || $c == 7) {
4369 4369
 					$arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar');
4370 4370
 				}
4371 4371
 			}
@@ -4387,7 +4387,7 @@  discard block
 block discarded – undo
4387 4387
 				if (empty($arcs['extract']['application/x-tar'])) {
4388 4388
 					$arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar');
4389 4389
 				}
4390
-			} else if (substr(PHP_OS,0,3) === 'WIN') {
4390
+			} else if (substr(PHP_OS, 0, 3) === 'WIN') {
4391 4391
 				// check `7z` for Windows server.
4392 4392
 				unset($o);
4393 4393
 				$this->procExec('7z', $o, $c);
@@ -4441,22 +4441,22 @@  discard block
 block discarded – undo
4441 4441
 
4442 4442
 		// normalize `/../`
4443 4443
 		$normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#';
4444
-		while(preg_match($normreg, $path)) {
4444
+		while (preg_match($normreg, $path)) {
4445 4445
 			$path = preg_replace($normreg, '$1', $path);
4446 4446
 		}
4447 4447
 		
4448 4448
 		// 'Here'
4449
-		if ($path === '' || $path === '.' . $separator) return $base;
4449
+		if ($path === '' || $path === '.'.$separator) return $base;
4450 4450
 		
4451 4451
 		// Absolute path
4452 4452
 		if ($path[0] === $separator || strpos($path, $systemroot) === 0) {
4453 4453
 			return $path;
4454 4454
 		}
4455 4455
 		
4456
-		$preg_separator = '#' . $sepquoted . '#';
4456
+		$preg_separator = '#'.$sepquoted.'#';
4457 4457
 		
4458 4458
 		// Relative path from 'Here'
4459
-		if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) {
4459
+		if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) {
4460 4460
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4461 4461
 			if ($arrn[0] !== '.') {
4462 4462
 				array_unshift($arrn, '.');
@@ -4470,12 +4470,11 @@  discard block
 block discarded – undo
4470 4470
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4471 4471
 			$arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY);
4472 4472
 		
4473
-			while (! empty($arrn) && $arrn[0] === '..') {
4473
+			while (!empty($arrn) && $arrn[0] === '..') {
4474 4474
 				array_shift($arrn);
4475 4475
 				array_pop($arrp);
4476 4476
 			}
4477
-			$path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) :
4478
-				(! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot);
4477
+			$path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot);
4479 4478
 		}
4480 4479
 		
4481 4480
 		return $path;
@@ -4493,7 +4492,7 @@  discard block
 block discarded – undo
4493 4492
 			@chmod($dir, 0777);
4494 4493
 			foreach (array_diff(scandir($dir), array('.', '..')) as $file) {
4495 4494
 				@set_time_limit(30);
4496
-				$path = $dir . DIRECTORY_SEPARATOR . $file;
4495
+				$path = $dir.DIRECTORY_SEPARATOR.$file;
4497 4496
 				if (!is_link($dir) && is_dir($path)) {
4498 4497
 					$this->rmdirRecursive($path);
4499 4498
 				} else {
@@ -4580,22 +4579,22 @@  discard block
 block discarded – undo
4580 4579
 		try {
4581 4580
 			if ($start = is_string($zipPath)) {
4582 4581
 				$zip = new ZipArchive();
4583
-				if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) {
4582
+				if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) {
4584 4583
 					$zip = false;
4585 4584
 				}
4586 4585
 			} else {
4587 4586
 				$zip = $zipPath;
4588 4587
 			}
4589 4588
 			if ($zip) {
4590
-				foreach($files as $file) {
4591
-					$path = $dir . DIRECTORY_SEPARATOR . $file;
4589
+				foreach ($files as $file) {
4590
+					$path = $dir.DIRECTORY_SEPARATOR.$file;
4592 4591
 					if (is_dir($path)) {
4593 4592
 						$zip->addEmptyDir($file);
4594 4593
 						$_files = array();
4595 4594
 						if ($handle = opendir($path)) {
4596 4595
 							while (false !== ($entry = readdir($handle))) {
4597 4596
 								if ($entry !== "." && $entry !== "..") {
4598
-									$_files[] = $file . DIRECTORY_SEPARATOR . $entry;
4597
+									$_files[] = $file.DIRECTORY_SEPARATOR.$entry;
4599 4598
 								}
4600 4599
 							}
4601 4600
 							closedir($handle);
@@ -4780,7 +4779,7 @@  discard block
 block discarded – undo
4780 4779
 	 * @return resource|false
4781 4780
 	 * @author Dmitry (dio) Levashov
4782 4781
 	 **/
4783
-	abstract protected function _fopen($path, $mode="rb");
4782
+	abstract protected function _fopen($path, $mode = "rb");
4784 4783
 	
4785 4784
 	/**
4786 4785
 	 * Close opened file
@@ -4790,7 +4789,7 @@  discard block
 block discarded – undo
4790 4789
 	 * @return bool
4791 4790
 	 * @author Dmitry (dio) Levashov
4792 4791
 	 **/
4793
-	abstract protected function _fclose($fp, $path='');
4792
+	abstract protected function _fclose($fp, $path = '');
4794 4793
 	
4795 4794
 	/********************  file/dir manipulations *************************/
4796 4795
 	
Please login to merge, or discard this patch.