Completed
Push — 2.x ( 03af2a...1b6e15 )
by Naoki
07:15
created
php/elFinderVolumeDriver.class.php 1 patch
Spacing   +139 added lines, -140 removed lines patch added patch discarded remove patch
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 		'utf8fix'      => false,
302 302
 		 //                           й                 ё              Й               Ё              Ø         Å
303 303
 		'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"),
304
-		'utf8replace'  => array("\u0439",        "\u0451",       "\u0419",       "\u0401",       "\u00d8", "\u00c5")
304
+		'utf8replace'  => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5")
305 305
 	);
306 306
 
307 307
 	/**
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 	 **/
605 605
 	protected function configure() {
606 606
 		// set ARGS
607
-		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET;
607
+		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
608 608
 		// set thumbnails path
609 609
 		$path = $this->options['tmbPath'];
610 610
 		if ($path) {
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 		
636 636
 		// check 'statOwner' for command `chmod`
637 637
 		if (empty($this->options['statOwner'])) {
638
-			$this->disabled[] ='chmod';
638
+			$this->disabled[] = 'chmod';
639 639
 		}
640 640
 		
641 641
 		// check 'mimeMap'
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 	 **/
760 760
 	public function mount(array $opts) {
761 761
 		if (!isset($opts['path']) || $opts['path'] === '') {
762
-			return $this->setError('Path undefined.');;
762
+			return $this->setError('Path undefined.'); ;
763 763
 		}
764 764
 		
765 765
 		$this->options = array_merge($this->options, $opts);
@@ -778,14 +778,14 @@  discard block
 block discarded – undo
778 778
 		$argInit = !empty($this->ARGS['init']);
779 779
 		
780 780
 		// session cache
781
-		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
781
+		if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
782 782
 			$_SESSION[elFinder::$sessionCacheKey][$this->id] = array();
783 783
 		}
784 784
 		$this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id];
785 785
 		
786 786
 		// default file attribute
787 787
 		$this->defaults = array(
788
-			'read'    => isset($this->options['defaults']['read'])  ? !!$this->options['defaults']['read']  : true,
788
+			'read'    => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true,
789 789
 			'write'   => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true,
790 790
 			'locked'  => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false,
791 791
 			'hidden'  => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
 			$this->access = $this->options['accessControl'];
813 813
 		}
814 814
 		
815
-		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y'));
816
-		$this->yesterday = $this->today-86400;
815
+		$this->today     = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
816
+		$this->yesterday = $this->today - 86400;
817 817
 		
818 818
 		// debug($this->attributes);
819 819
 		if (!$this->init()) {
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 				foreach ($mimecf as $line_num => $line) {
913 913
 					if (!preg_match('/^\s*#/', $line)) {
914 914
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
915
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
915
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
916 916
 							if (!isset(self::$mimetypes[$mime[$i]])) {
917 917
 								self::$mimetypes[$mime[$i]] = $mime[0];
918 918
 							}
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
 		
942 942
 		if ($root['read']) {
943 943
 			// check startPath - path to open by default instead of root
944
-			$startPath = $this->options['startPath']? $this->normpathCE($this->options['startPath']) : '';
944
+			$startPath = $this->options['startPath'] ? $this->normpathCE($this->options['startPath']) : '';
945 945
 			if ($startPath) {
946 946
 				$start = $this->stat($startPath);
947 947
 				if (!empty($start)
@@ -965,8 +965,8 @@  discard block
 block discarded – undo
965 965
 				'read'    => false
966 966
 			));
967 967
 		}
968
-		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1;
969
-		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48;
968
+		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1;
969
+		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48;
970 970
 		$this->URL      = $this->options['URL'];
971 971
 		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) {
972 972
 			$this->URL .= '/';
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
 		
1021 1021
 		// fix sync interval
1022 1022
 		if ($this->options['syncMinMs'] !== 0) {
1023
-			$this->options['syncMinMs'] = max($this->options[$this->options['syncChkAsTs']? 'tsPlSleep' : 'lsPlSleep'] * 1000, intval($this->options['syncMinMs']));
1023
+			$this->options['syncMinMs'] = max($this->options[$this->options['syncChkAsTs'] ? 'tsPlSleep' : 'lsPlSleep']*1000, intval($this->options['syncMinMs']));
1024 1024
 		}
1025 1025
 
1026 1026
 		return $this->mounted = true;
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 	public function options($hash) {
1125 1125
 		$create = $createext = array();
1126 1126
 		if (isset($this->archivers['create']) && is_array($this->archivers['create'])) {
1127
-			foreach($this->archivers['create'] as $m => $v) {
1127
+			foreach ($this->archivers['create'] as $m => $v) {
1128 1128
 				$create[] = $m;
1129 1129
 				$createext[$m] = $v['ext'];
1130 1130
 			}
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
 				'extract'   => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(),
1146 1146
 				'createext' => $createext
1147 1147
 			),
1148
-			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(),
1148
+			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(),
1149 1149
 			'syncChkAsTs'     => intval($this->options['syncChkAsTs']),
1150 1150
 			'syncMinMs'       => intval($this->options['syncMinMs'])
1151 1151
 		);
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 	 * @author Naoki Sawada
1160 1160
 	 */
1161 1161
 	public function getOption($name) {
1162
-		return isset($this->options[$name])? $this->options[$name] : null;
1162
+		return isset($this->options[$name]) ? $this->options[$name] : null;
1163 1163
 	}
1164 1164
 	
1165 1165
 	/**
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
 	 */
1172 1172
 	public function getOptionsPlugin($name = '') {
1173 1173
 		if ($name) {
1174
-			return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array();
1174
+			return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array();
1175 1175
 		} else {
1176 1176
 			return $this->options['plugin'];
1177 1177
 		}
@@ -1302,7 +1302,7 @@  discard block
 block discarded – undo
1302 1302
 		$file = $this->stat($path);
1303 1303
 		
1304 1304
 		if ($isRoot) {
1305
-			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array();
1305
+			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array();
1306 1306
 			$file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON
1307 1307
 			if (isset($this->options['netkey'])) {
1308 1308
 				$file['netkey'] = $this->options['netkey'];
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
 	 * @return array|false
1321 1321
 	 * @author Dmitry (dio) Levashov
1322 1322
 	 **/
1323
-	public function dir($hash, $resolveLink=false) {
1323
+	public function dir($hash, $resolveLink = false) {
1324 1324
 		if (($dir = $this->file($hash)) == false) {
1325 1325
 			return $this->setError(elFinder::ERROR_DIR_NOT_FOUND);
1326 1326
 		}
@@ -1384,14 +1384,14 @@  discard block
 block discarded – undo
1384 1384
 	 * @return array|false
1385 1385
 	 * @author Dmitry (dio) Levashov
1386 1386
 	 **/
1387
-	public function tree($hash='', $deep=0, $exclude='') {
1387
+	public function tree($hash = '', $deep = 0, $exclude = '') {
1388 1388
 		$path = $hash ? $this->decode($hash) : $this->root;
1389 1389
 		
1390 1390
 		if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') {
1391 1391
 			return false;
1392 1392
 		}
1393 1393
 		
1394
-		$dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null);
1394
+		$dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null);
1395 1395
 		array_unshift($dirs, $dir);
1396 1396
 		return $dirs;
1397 1397
 	}
@@ -1621,7 +1621,7 @@  discard block
 block discarded – undo
1621 1621
 	 * @return array|false
1622 1622
 	 * @author Dmitry (dio) Levashov
1623 1623
 	 **/
1624
-	public function duplicate($hash, $suffix='copy') {
1624
+	public function duplicate($hash, $suffix = 'copy') {
1625 1625
 		if ($this->commandDisabled('duplicate')) {
1626 1626
 			return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED);
1627 1627
 		}
@@ -1697,7 +1697,7 @@  discard block
 block discarded – undo
1697 1697
 		
1698 1698
 		if ($file) { // file exists
1699 1699
 			// check POST data `overwrite` for 3rd party uploader
1700
-			$overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite'];
1700
+			$overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite'];
1701 1701
 			if ($overwrite) {
1702 1702
 				if (!$file['write']) {
1703 1703
 					return $this->setError(elFinder::ERROR_PERM_DENIED);
@@ -1768,7 +1768,7 @@  discard block
 block discarded – undo
1768 1768
 		if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) {
1769 1769
 			return $rmSrc
1770 1770
 				? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test))
1771
-				: $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1771
+				: $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1772 1772
 		}
1773 1773
 
1774 1774
 		$test = $this->joinPathCE($destination, $name);
@@ -1931,7 +1931,7 @@  discard block
 block discarded – undo
1931 1931
 			return $this->setError(elFinder::ERROR_PERM_DENIED);
1932 1932
 		}
1933 1933
 		$this->clearcache();
1934
-		$this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir;
1934
+		$this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir;
1935 1935
 		
1936 1936
 		if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) {
1937 1937
 			if (is_array($path)) {
@@ -1989,9 +1989,9 @@  discard block
 block discarded – undo
1989 1989
 		if ($name === '') {
1990 1990
 			$name = count($files) == 1 ? $files[0] : 'Archive';
1991 1991
 		} else {
1992
-			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name));
1992
+			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name));
1993 1993
 		}
1994
-		$name .='.' . $archiver['ext'];
1994
+		$name .= '.'.$archiver['ext'];
1995 1995
 		$name = $this->uniqueName($dir, $name, '');
1996 1996
 		$this->clearcache();
1997 1997
 		return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false;
@@ -2030,7 +2030,7 @@  discard block
 block discarded – undo
2030 2030
 		
2031 2031
 		$path = $this->decode($hash);
2032 2032
 		
2033
-		$work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path);
2033
+		$work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path);
2034 2034
 
2035 2035
 		if (!$work_path || !is_writable($work_path)) {
2036 2036
 			if ($work_path && $path !== $work_path && is_file($work_path)) {
@@ -2045,7 +2045,7 @@  discard block
 block discarded – undo
2045 2045
 			}
2046 2046
 		}
2047 2047
 
2048
-		switch($mode) {
2048
+		switch ($mode) {
2049 2049
 			
2050 2050
 			case 'propresize':
2051 2051
 				$result = $this->imgResize($work_path, $width, $height, true, true, null, $jpgQuality);
@@ -2142,7 +2142,7 @@  discard block
 block discarded – undo
2142 2142
 		$this->searchStart = time();
2143 2143
 		return ($q === '' || $this->commandDisabled('search'))
2144 2144
 			? array()
2145
-			: $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes);
2145
+			: $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes);
2146 2146
 	}
2147 2147
 	
2148 2148
 	/**
@@ -2214,9 +2214,9 @@  discard block
 block discarded – undo
2214 2214
 		$path = ltrim($path, $this->separator);
2215 2215
 		$dirs = explode($this->separator, $path);
2216 2216
 		array_pop($dirs);
2217
-		foreach($dirs as $dir) {
2217
+		foreach ($dirs as $dir) {
2218 2218
 			$targetPath = $this->joinPathCE($base, $dir);
2219
-			if (! $_realpath = $this->realpath($this->encode($targetPath))) {
2219
+			if (!$_realpath = $this->realpath($this->encode($targetPath))) {
2220 2220
 				if ($stat = $this->mkdir($targetHash, $dir)) {
2221 2221
 					$result['added'][] = $stat;
2222 2222
 					$targetHash = $stat['hash'];
@@ -2283,7 +2283,7 @@  discard block
 block discarded – undo
2283 2283
 	 * @author Naoki Sawada
2284 2284
 	 **/
2285 2285
 	protected function dirnameCE($path) {
2286
-		return (!$this->encoding)? $this->_dirname($path) :	$this->convEncOut($this->_dirname($this->convEncIn($path)));
2286
+		return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path)));
2287 2287
 	}
2288 2288
 	
2289 2289
 	/**
@@ -2294,7 +2294,7 @@  discard block
 block discarded – undo
2294 2294
 	 * @author Naoki Sawada
2295 2295
 	 **/
2296 2296
 	protected function basenameCE($path) {
2297
-		return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2297
+		return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2298 2298
 	}
2299 2299
 	
2300 2300
 	/**
@@ -2307,7 +2307,7 @@  discard block
 block discarded – undo
2307 2307
 	 * @author Naoki Sawada
2308 2308
 	 **/
2309 2309
 	protected function joinPathCE($dir, $name) {
2310
-		return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2310
+		return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2311 2311
 	}
2312 2312
 	
2313 2313
 	/**
@@ -2318,7 +2318,7 @@  discard block
 block discarded – undo
2318 2318
 	 * @author Naoki Sawada
2319 2319
 	 **/
2320 2320
 	protected function normpathCE($path) {
2321
-		return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2321
+		return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2322 2322
 	}
2323 2323
 	
2324 2324
 	/**
@@ -2329,7 +2329,7 @@  discard block
 block discarded – undo
2329 2329
 	 * @author Naoki Sawada
2330 2330
 	 **/
2331 2331
 	protected function relpathCE($path) {
2332
-		return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2332
+		return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2333 2333
 	}
2334 2334
 	
2335 2335
 	/**
@@ -2340,7 +2340,7 @@  discard block
 block discarded – undo
2340 2340
 	 * @author Naoki Sawada
2341 2341
 	 **/
2342 2342
 	protected function abspathCE($path) {
2343
-		return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path)));
2343
+		return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path)));
2344 2344
 	}
2345 2345
 	
2346 2346
 	/**
@@ -2352,7 +2352,7 @@  discard block
 block discarded – undo
2352 2352
 	 * @author Naoki Sawada
2353 2353
 	 **/
2354 2354
 	protected function inpathCE($path, $parent) {
2355
-		return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2355
+		return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2356 2356
 	}
2357 2357
 	
2358 2358
 	/**
@@ -2363,8 +2363,8 @@  discard block
 block discarded – undo
2363 2363
 	 * @return resource|false
2364 2364
 	 * @author Naoki Sawada
2365 2365
 	 **/
2366
-	protected function fopenCE($path, $mode='rb') {
2367
-		return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2366
+	protected function fopenCE($path, $mode = 'rb') {
2367
+		return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2368 2368
 	}
2369 2369
 	
2370 2370
 	/**
@@ -2375,8 +2375,8 @@  discard block
 block discarded – undo
2375 2375
 	 * @return bool
2376 2376
 	 * @author Naoki Sawada
2377 2377
 	 **/
2378
-	protected function fcloseCE($fp, $path='') {
2379
-		return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2378
+	protected function fcloseCE($fp, $path = '') {
2379
+		return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2380 2380
 	}
2381 2381
 	
2382 2382
 	/**
@@ -2391,7 +2391,7 @@  discard block
 block discarded – undo
2391 2391
 	 * @author Naoki Sawada
2392 2392
 	 **/
2393 2393
 	protected function saveCE($fp, $dir, $name, $stat) {
2394
-		return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2394
+		return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2395 2395
 	}
2396 2396
 	
2397 2397
 	/**
@@ -2403,7 +2403,7 @@  discard block
 block discarded – undo
2403 2403
 	 **/
2404 2404
 	protected function subdirsCE($path) {
2405 2405
 		if (!isset($this->subdirsCache[$path])) {
2406
-			$this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2406
+			$this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2407 2407
 		}
2408 2408
 		return $this->subdirsCache[$path];
2409 2409
 	}
@@ -2416,7 +2416,7 @@  discard block
 block discarded – undo
2416 2416
 	 * @author Naoki Sawada
2417 2417
 	 **/
2418 2418
 	protected function scandirCE($path) {
2419
-		return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2419
+		return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2420 2420
 	}
2421 2421
 	
2422 2422
 	/**
@@ -2429,7 +2429,7 @@  discard block
 block discarded – undo
2429 2429
 	 * @author Naoki Sawada
2430 2430
 	 **/
2431 2431
 	protected function symlinkCE($source, $targetDir, $name) {
2432
-		return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2432
+		return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2433 2433
 	}
2434 2434
 	
2435 2435
 	/***************** paths *******************/
@@ -2448,7 +2448,7 @@  discard block
 block discarded – undo
2448 2448
 			// cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root
2449 2449
 			$p = $this->relpathCE($path);
2450 2450
 			// if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt
2451
-			if ($p === '')	{
2451
+			if ($p === '') {
2452 2452
 				$p = DIRECTORY_SEPARATOR;
2453 2453
 			}
2454 2454
 
@@ -2481,7 +2481,7 @@  discard block
 block discarded – undo
2481 2481
 			// TODO uncrypt hash and return path
2482 2482
 			$path = $this->uncrypt($h); 
2483 2483
 			// append ROOT to path after it was cut in encode
2484
-			return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2484
+			return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2485 2485
 		}
2486 2486
 	}
2487 2487
 	
@@ -2541,21 +2541,21 @@  discard block
 block discarded – undo
2541 2541
 	 * @author Dmitry (dio) Levashov
2542 2542
 	 **/
2543 2543
 	public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) {
2544
-		$ext  = '';
2544
+		$ext = '';
2545 2545
 
2546 2546
 		if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
2547 2547
 			$ext  = '.'.$m[1];
2548
-			$name = substr($name, 0,  strlen($name)-strlen($m[0]));
2548
+			$name = substr($name, 0, strlen($name) - strlen($m[0]));
2549 2549
 		} 
2550 2550
 		
2551 2551
 		if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) {
2552
-			$i    = (int)$m[2];
2553
-			$name = substr($name, 0, strlen($name)-strlen($m[2]));
2552
+			$i    = (int) $m[2];
2553
+			$name = substr($name, 0, strlen($name) - strlen($m[2]));
2554 2554
 		} else {
2555 2555
 			$i     = $start;
2556 2556
 			$name .= $suffix;
2557 2557
 		}
2558
-		$max = $i+100000;
2558
+		$max = $i + 100000;
2559 2559
 
2560 2560
 		while ($i <= $max) {
2561 2561
 			$n = $name.($i > 0 ? $i : '').$ext;
@@ -2579,7 +2579,7 @@  discard block
 block discarded – undo
2579 2579
 	 * @author Naoki Sawada
2580 2580
 	 */
2581 2581
 	public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') {
2582
-		return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2582
+		return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2583 2583
 	}
2584 2584
 	
2585 2585
 	/**
@@ -2592,7 +2592,7 @@  discard block
 block discarded – undo
2592 2592
 	 * @author Naoki Sawada
2593 2593
 	 */
2594 2594
 	public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') {
2595
-		return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2595
+		return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2596 2596
 	}
2597 2597
 	
2598 2598
 	/**
@@ -2612,7 +2612,7 @@  discard block
 block discarded – undo
2612 2612
 			}
2613 2613
 			if (is_array($var)) {
2614 2614
 				$_ret = array();
2615
-				foreach($var as $_k => $_v) {
2615
+				foreach ($var as $_k => $_v) {
2616 2616
 					$_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_');
2617 2617
 				}
2618 2618
 				$var = $_ret;
@@ -2624,7 +2624,7 @@  discard block
 block discarded – undo
2624 2624
 						$_var = str_replace('?', $unknown, $_var);
2625 2625
 					}
2626 2626
 				}
2627
-				if  ($_var !== false) {
2627
+				if ($_var !== false) {
2628 2628
 					$var = $_var;
2629 2629
 				}
2630 2630
 			}
@@ -2651,7 +2651,7 @@  discard block
 block discarded – undo
2651 2651
 		
2652 2652
 		$key = '';
2653 2653
 		if ($path !== '') {
2654
-			$key = $this->id . '#' . $path;
2654
+			$key = $this->id.'#'.$path;
2655 2655
 			if (isset($cache[$key])) {
2656 2656
 				return $cache[$key];
2657 2657
 			}
@@ -2683,7 +2683,7 @@  discard block
 block discarded – undo
2683 2683
 		if ($work = $this->getTempFile()) {
2684 2684
 			if ($wfp = fopen($work, 'wb')) {
2685 2685
 				if ($fp = $this->_fopen($path)) {
2686
-					while(!feof($fp)) {
2686
+					while (!feof($fp)) {
2687 2687
 						fwrite($wfp, fread($fp, 8192));
2688 2688
 					}
2689 2689
 					$this->_fclose($fp, $path);
@@ -2727,7 +2727,7 @@  discard block
 block discarded – undo
2727 2727
 			@set_time_limit(30);
2728 2728
 			$stat = $this->stat($this->convEncOut($p));
2729 2729
 			$this->convEncIn();
2730
-			($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p);
2730
+			($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p);
2731 2731
 		}
2732 2732
 		return $this->_rmdir($localpath);
2733 2733
 	}
@@ -2744,7 +2744,7 @@  discard block
 block discarded – undo
2744 2744
 	 * @return bool
2745 2745
 	 * @author Dmitry (dio) Levashov
2746 2746
 	 **/
2747
-	protected function attr($path, $name, $val=null, $isDir=null) {
2747
+	protected function attr($path, $name, $val = null, $isDir = null) {
2748 2748
 		if (!isset($this->defaults[$name])) {
2749 2749
 			return false;
2750 2750
 		}
@@ -2776,7 +2776,7 @@  discard block
 block discarded – undo
2776 2776
 			} 
2777 2777
 		}
2778 2778
 		
2779
-		return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm;
2779
+		return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm;
2780 2780
 	}
2781 2781
 	
2782 2782
 	/**
@@ -2820,7 +2820,7 @@  discard block
 block discarded – undo
2820 2820
 	protected function allowPutMime($mime) {
2821 2821
 		// logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order
2822 2822
 		$allow  = $this->mimeAccepted($mime, $this->uploadAllow, null);
2823
-		$deny   = $this->mimeAccepted($mime, $this->uploadDeny,  null);
2823
+		$deny   = $this->mimeAccepted($mime, $this->uploadDeny, null);
2824 2824
 		$res = true; // default to allow
2825 2825
 		if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny'
2826 2826
 			$res = false; // default is deny
@@ -2853,7 +2853,7 @@  discard block
 block discarded – undo
2853 2853
 			if (!isset($this->sessionCache['rootstat'])) {
2854 2854
 				$this->sessionCache['rootstat'] = array();
2855 2855
 			}
2856
-			if (! $this->isMyReload()) {
2856
+			if (!$this->isMyReload()) {
2857 2857
 				// need $path as key for netmount/netunmount
2858 2858
 				if (isset($this->sessionCache['rootstat'][$rootKey])) {
2859 2859
 					if ($ret = elFinder::sessionDataDecode($this->sessionCache['rootstat'][$rootKey], 'array')) {
@@ -2893,10 +2893,10 @@  discard block
 block discarded – undo
2893 2893
 			if ($this->rootName) {
2894 2894
 				$stat['name'] = $this->rootName;
2895 2895
 			}
2896
-			if (! empty($this->options['icon'])) {
2896
+			if (!empty($this->options['icon'])) {
2897 2897
 				$stat['icon'] = $this->options['icon'];
2898 2898
 			}
2899
-			if (! empty($this->options['rootCssClass'])) {
2899
+			if (!empty($this->options['rootCssClass'])) {
2900 2900
 				$stat['csscls'] = $this->options['rootCssClass'];
2901 2901
 			}
2902 2902
 		} else {
@@ -2944,7 +2944,7 @@  discard block
 block discarded – undo
2944 2944
 			// lock when parent directory is not writable
2945 2945
 			if (!isset($stat['locked'])) {
2946 2946
 				$parent = $this->dirnameCE($path);
2947
-				$pstat = isset($this->cache[$parent])? $this->cache[$parent] : array();
2947
+				$pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array();
2948 2948
 				if (isset($pstat['write']) && !$pstat['write']) {
2949 2949
 					$stat['locked'] = true;
2950 2950
 				}
@@ -3002,7 +3002,7 @@  discard block
 block discarded – undo
3002 3002
 			}
3003 3003
 			if (!isset($stat['url']) && $this->URL && $this->encoding) {
3004 3004
 				$_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1));
3005
-				$stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN')? $_path : $this->convEncIn($_path, true)));
3005
+				$stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN') ? $_path : $this->convEncIn($_path, true)));
3006 3006
 			}
3007 3007
 		} else {
3008 3008
 			if ($isDir) {
@@ -3125,7 +3125,7 @@  discard block
 block discarded – undo
3125 3125
 				foreach ($mimecf as $line_num => $line) {
3126 3126
 					if (!preg_match('/^\s*#/', $line)) {
3127 3127
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
3128
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
3128
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
3129 3129
 							if (!isset(elFinderVolumeDriver::$mimetypes[$mime[$i]])) {
3130 3130
 								elFinderVolumeDriver::$mimetypes[$mime[$i]] = $mime[0];
3131 3131
 							}
@@ -3231,10 +3231,10 @@  discard block
 block discarded – undo
3231 3231
 	}
3232 3232
 	
3233 3233
 	protected function isMyReload($target = '', $ARGtarget = '') {
3234
-		if (! empty($this->ARGS['reload'])) {
3234
+		if (!empty($this->ARGS['reload'])) {
3235 3235
 			if ($ARGtarget === '') {
3236
-				$ARGtarget = isset($this->ARGS['target'])? $this->ARGS['target']
3237
-					: ((isset($this->ARGS['targets']) && is_array($this->ARGS['targets']) && count($this->ARGS['targets']) === 1)?
3236
+				$ARGtarget = isset($this->ARGS['target']) ? $this->ARGS['target']
3237
+					: ((isset($this->ARGS['targets']) && is_array($this->ARGS['targets']) && count($this->ARGS['targets']) === 1) ?
3238 3238
 						$this->ARGS['targets'][0] : '');
3239 3239
 			}
3240 3240
 			if ($ARGtarget !== '') {
@@ -3283,7 +3283,7 @@  discard block
 block discarded – undo
3283 3283
 	 * @return array
3284 3284
 	 * @author Dmitry (dio) Levashov
3285 3285
 	 **/
3286
-	protected function gettree($path, $deep, $exclude='') {
3286
+	protected function gettree($path, $deep, $exclude = '') {
3287 3287
 		$dirs = array();
3288 3288
 		
3289 3289
 		!isset($this->dirsCache[$path]) && $this->cacheDir($path);
@@ -3294,7 +3294,7 @@  discard block
 block discarded – undo
3294 3294
 			if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') {
3295 3295
 				$dirs[] = $stat;
3296 3296
 				if ($deep > 0 && !empty($stat['dirs'])) {
3297
-					$dirs = array_merge($dirs, $this->gettree($p, $deep-1));
3297
+					$dirs = array_merge($dirs, $this->gettree($p, $deep - 1));
3298 3298
 				}
3299 3299
 			}
3300 3300
 		}
@@ -3314,13 +3314,13 @@  discard block
 block discarded – undo
3314 3314
 	protected function doSearch($path, $q, $mimes) {
3315 3315
 		$result = array();
3316 3316
 		
3317
-		$timeout = $this->options['searchTimeout']? $this->searchStart + $this->options['searchTimeout'] : 0;
3317
+		$timeout = $this->options['searchTimeout'] ? $this->searchStart + $this->options['searchTimeout'] : 0;
3318 3318
 		if ($timeout && $timeout < time()) {
3319 3319
 			$this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode($path)));
3320 3320
 			return $result;
3321 3321
 		}
3322 3322
 		
3323
-		foreach($this->scandirCE($path) as $p) {
3323
+		foreach ($this->scandirCE($path) as $p) {
3324 3324
 			@set_time_limit($this->options['searchTimeout'] + 30);
3325 3325
 			
3326 3326
 			if ($timeout && ($this->error || $timeout < time())) {
@@ -3348,7 +3348,7 @@  discard block
 block discarded – undo
3348 3348
 					if ($this->encoding) {
3349 3349
 						$path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true)));
3350 3350
 					}
3351
-					$stat['url'] = $this->URL . $path;
3351
+					$stat['url'] = $this->URL.$path;
3352 3352
 				}
3353 3353
 				
3354 3354
 				$result[] = $stat;
@@ -3382,7 +3382,7 @@  discard block
 block discarded – undo
3382 3382
 			if (!$this->inpathCE($target, $this->root)) {
3383 3383
 				return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK);
3384 3384
 			}
3385
-			$stat   = $this->stat($target);
3385
+			$stat = $this->stat($target);
3386 3386
 			$this->clearcache();
3387 3387
 			return $stat && $this->symlinkCE($target, $dst, $name)
3388 3388
 				? $this->joinPathCE($dst, $name)
@@ -3663,15 +3663,15 @@  discard block
 block discarded – undo
3663 3663
 		}
3664 3664
 
3665 3665
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
3666
-		if ($s[0] <= $tmbSize && $s[1]	<= $tmbSize) {
3667
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3666
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
3667
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3668 3668
 		} else {
3669 3669
 		
3670 3670
 			if ($this->options['tmbCrop']) {
3671 3671
 		
3672 3672
 				$result = $tmb;
3673 3673
 				/* Resize and crop if image bigger than thumbnail */
3674
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3674
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3675 3675
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
3676 3676
 				}
3677 3677
 		
@@ -3688,7 +3688,7 @@  discard block
 block discarded – undo
3688 3688
 			}
3689 3689
 		
3690 3690
 			if ($result) {
3691
-				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3691
+				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3692 3692
 			}
3693 3693
 		}
3694 3694
 		
@@ -3734,18 +3734,18 @@  discard block
 block discarded – undo
3734 3734
 			/* Resizing by biggest side */
3735 3735
 			if ($resizeByBiggerSide) {
3736 3736
 				if ($orig_w > $orig_h) {
3737
-					$size_h = round($orig_h * $width / $orig_w);
3737
+					$size_h = round($orig_h*$width/$orig_w);
3738 3738
 					$size_w = $width;
3739 3739
 				} else {
3740
-					$size_w = round($orig_w * $height / $orig_h);
3740
+					$size_w = round($orig_w*$height/$orig_h);
3741 3741
 					$size_h = $height;
3742 3742
 				}
3743 3743
 			} else {
3744 3744
 				if ($orig_w > $orig_h) {
3745
-					$size_w = round($orig_w * $height / $orig_h);
3745
+					$size_w = round($orig_w*$height/$orig_h);
3746 3746
 					$size_h = $height;
3747 3747
 				} else {
3748
-					$size_h = round($orig_h * $width / $orig_w);
3748
+					$size_h = round($orig_h*$width/$orig_w);
3749 3749
 					$size_w = $width;
3750 3750
 				}
3751 3751
 			}
@@ -3763,7 +3763,7 @@  discard block
 block discarded – undo
3763 3763
 				// Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb
3764 3764
 				// resize bench: http://app-mgng.rhcloud.com/9
3765 3765
 				// resize sample: http://www.dylanbeattie.net/magick/filters/result.html
3766
-				$filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3766
+				$filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3767 3767
 				
3768 3768
 				$ani = ($img->getNumberImages() > 1);
3769 3769
 				if ($ani && is_null($destformat)) {
@@ -3788,11 +3788,11 @@  discard block
 block discarded – undo
3788 3788
 				break;
3789 3789
 
3790 3790
 			case 'gd':
3791
-				$img = $this->gdImageCreate($path,$s['mime']);
3791
+				$img = $this->gdImageCreate($path, $s['mime']);
3792 3792
 
3793
-				if ($img &&  false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3793
+				if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3794 3794
 				
3795
-					$this->gdImageBackground($tmp,$this->options['tmbBgColor']);
3795
+					$this->gdImageBackground($tmp, $this->options['tmbBgColor']);
3796 3796
 					
3797 3797
 					if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) {
3798 3798
 						return false;
@@ -3873,11 +3873,11 @@  discard block
 block discarded – undo
3873 3873
 				break;
3874 3874
 
3875 3875
 			case 'gd':
3876
-				$img = $this->gdImageCreate($path,$s['mime']);
3876
+				$img = $this->gdImageCreate($path, $s['mime']);
3877 3877
 
3878
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3878
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3879 3879
 					
3880
-					$this->gdImageBackground($tmp,$this->options['tmbBgColor']);
3880
+					$this->gdImageBackground($tmp, $this->options['tmbBgColor']);
3881 3881
 
3882 3882
 					$size_w = $width;
3883 3883
 					$size_h = $height;
@@ -3928,8 +3928,8 @@  discard block
 block discarded – undo
3928 3928
 		$result = false;
3929 3929
 
3930 3930
 		/* Coordinates for image over square aligning */
3931
-		$y = ceil(abs($height - $s[1]) / 2); 
3932
-		$x = ceil(abs($width - $s[0]) / 2);
3931
+		$y = ceil(abs($height - $s[1])/2); 
3932
+		$x = ceil(abs($width - $s[0])/2);
3933 3933
 
3934 3934
 		if (!$jpgQuality) {
3935 3935
 			$jpgQuality = $this->options['jpgQuality'];
@@ -3953,7 +3953,7 @@  discard block
 block discarded – undo
3953 3953
 						$gif->newImage($width, $height, new ImagickPixel($bgcolor));
3954 3954
 						$gif->setImageColorspace($img->getImageColorspace());
3955 3955
 						$gif->setImageFormat('gif');
3956
-						$gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3956
+						$gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3957 3957
 						$gif->setImageDelay($img->getImageDelay());
3958 3958
 						$gif->setImageIterations($img->getImageIterations());
3959 3959
 						$img1->addImage($gif);
@@ -3968,7 +3968,7 @@  discard block
 block discarded – undo
3968 3968
 					$img1 = new Imagick();
3969 3969
 					$img1->newImage($width, $height, new ImagickPixel($bgcolor));
3970 3970
 					$img1->setImageColorspace($img->getImageColorspace());
3971
-					$img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3971
+					$img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3972 3972
 					$result = $this->imagickImage($img, $path, $destformat, $jpgQuality);
3973 3973
 				}
3974 3974
 				
@@ -3979,11 +3979,11 @@  discard block
 block discarded – undo
3979 3979
 				break;
3980 3980
 
3981 3981
 			case 'gd':
3982
-				$img = $this->gdImageCreate($path,$s['mime']);
3982
+				$img = $this->gdImageCreate($path, $s['mime']);
3983 3983
 
3984
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3984
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3985 3985
 
3986
-					$this->gdImageBackground($tmp,$bgcolor);
3986
+					$this->gdImageBackground($tmp, $bgcolor);
3987 3987
 
3988 3988
 					if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) {
3989 3989
 						return false;
@@ -4015,15 +4015,15 @@  discard block
 block discarded – undo
4015 4015
 	 * @author Troex Nevelin
4016 4016
 	 **/
4017 4017
 	protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null, $jpgQuality = null) {
4018
-		if (($s = @getimagesize($path)) == false || $degree % 360 === 0) {
4018
+		if (($s = @getimagesize($path)) == false || $degree%360 === 0) {
4019 4019
 			return false;
4020 4020
 		}
4021 4021
 
4022 4022
 		$result = false;
4023 4023
 
4024 4024
 		// try lossless rotate
4025
-		if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
4026
-			$count = ($degree / 90) % 4;
4025
+		if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
4026
+			$count = ($degree/90)%4;
4027 4027
 			$exiftran = array(
4028 4028
 				1 => '-9',
4029 4029
 				2 => '-1',
@@ -4039,7 +4039,7 @@  discard block
 block discarded – undo
4039 4039
 				'exiftran -i '.$exiftran[$count].' '.$path,
4040 4040
 				'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath
4041 4041
 			);
4042
-			foreach($cmds as $cmd) {
4042
+			foreach ($cmds as $cmd) {
4043 4043
 				if ($this->procExec($cmd) === 0) {
4044 4044
 					$result = true;
4045 4045
 					break;
@@ -4079,12 +4079,12 @@  discard block
 block discarded – undo
4079 4079
 				break;
4080 4080
 
4081 4081
 			case 'gd':
4082
-				$img = $this->gdImageCreate($path,$s['mime']);
4082
+				$img = $this->gdImageCreate($path, $s['mime']);
4083 4083
 
4084 4084
 				$degree = 360 - $degree;
4085 4085
 				list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4086 4086
 				$bgcolor = imagecolorallocate($img, $r, $g, $b);
4087
-				$tmp = imageRotate($img, $degree, (int)$bgcolor);
4087
+				$tmp = imageRotate($img, $degree, (int) $bgcolor);
4088 4088
 
4089 4089
 				$result = $this->gdImage($tmp, $path, $destformat, $s['mime'], $jpgQuality);
4090 4090
 
@@ -4109,11 +4109,11 @@  discard block
 block discarded – undo
4109 4109
 	 * @return int     exit code
4110 4110
 	 * @author Alexey Sukhotin
4111 4111
 	 **/
4112
-	protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) {
4112
+	protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) {
4113 4113
 
4114 4114
 		$descriptorspec = array(
4115
-			0 => array("pipe", "r"),  // stdin
4116
-			1 => array("pipe", "w"),  // stdout
4115
+			0 => array("pipe", "r"), // stdin
4116
+			1 => array("pipe", "w"), // stdout
4117 4117
 			2 => array("pipe", "w")   // stderr
4118 4118
 		);
4119 4119
 
@@ -4170,8 +4170,8 @@  discard block
 block discarded – undo
4170 4170
 	 * @param string $mime
4171 4171
 	 * @return gd image resource identifier
4172 4172
 	 */
4173
-	protected function gdImageCreate($path,$mime){
4174
-		switch($mime){
4173
+	protected function gdImageCreate($path, $mime) {
4174
+		switch ($mime) {
4175 4175
 			case 'image/jpeg':
4176 4176
 			return imagecreatefromjpeg($path);
4177 4177
 
@@ -4196,7 +4196,7 @@  discard block
 block discarded – undo
4196 4196
 	 * @param string $mime The original image mime type
4197 4197
 	 * @param int    $jpgQuality  JEPG quality (1-100)
4198 4198
 	 */
4199
-	protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null ){
4199
+	protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null) {
4200 4200
 
4201 4201
 		if (!$jpgQuality) {
4202 4202
 			$jpgQuality = $this->options['jpgQuality'];
@@ -4220,7 +4220,7 @@  discard block
 block discarded – undo
4220 4220
 	 * @param string $destformat The Image type to use for $filename
4221 4221
 	 * @param int    $jpgQuality  JEPG quality (1-100)
4222 4222
 	 */
4223
-	protected function imagickImage($img, $filename, $destformat, $jpgQuality = null ){
4223
+	protected function imagickImage($img, $filename, $destformat, $jpgQuality = null) {
4224 4224
 
4225 4225
 		if (!$jpgQuality) {
4226 4226
 			$jpgQuality = $this->options['jpgQuality'];
@@ -4275,13 +4275,13 @@  discard block
 block discarded – undo
4275 4275
 	 * @param resource $image gd image resource
4276 4276
 	 * @param string $bgcolor background color in #rrggbb format
4277 4277
 	 */
4278
-	protected function gdImageBackground($image, $bgcolor){
4278
+	protected function gdImageBackground($image, $bgcolor) {
4279 4279
 
4280
-		if( $bgcolor == 'transparent' ){
4281
-			imagesavealpha($image,true);
4280
+		if ($bgcolor == 'transparent') {
4281
+			imagesavealpha($image, true);
4282 4282
 			$bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127);
4283 4283
 
4284
-		}else{
4284
+		} else {
4285 4285
 			list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4286 4286
 			$bgcolor1 = imagecolorallocate($image, $r, $g, $b);
4287 4287
 		}
@@ -4319,13 +4319,13 @@  discard block
 block discarded – undo
4319 4319
 	* @return int|bool
4320 4320
 	* @author Alexey Sukhotin
4321 4321
 	**/
4322
-	protected function stripos($haystack , $needle , $offset = 0) {
4322
+	protected function stripos($haystack, $needle, $offset = 0) {
4323 4323
 		if (function_exists('mb_stripos')) {
4324
-			return mb_stripos($haystack , $needle , $offset, 'UTF-8');
4324
+			return mb_stripos($haystack, $needle, $offset, 'UTF-8');
4325 4325
 		} else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) {
4326 4326
 			return mb_strpos(mb_strtolower($haystack, 'UTF-8'), mb_strtolower($needle, 'UTF-8'), $offset);
4327 4327
 		} 
4328
-		return stripos($haystack , $needle , $offset);
4328
+		return stripos($haystack, $needle, $offset);
4329 4329
 	}
4330 4330
 
4331 4331
 	/**
@@ -4375,22 +4375,22 @@  discard block
 block discarded – undo
4375 4375
 			unset($o);
4376 4376
 			$this->procExec('zip -v', $o, $c);
4377 4377
 			if ($c == 0) {
4378
-				$arcs['create']['application/zip']  = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4378
+				$arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4379 4379
 			}
4380 4380
 			unset($o);
4381 4381
 			$this->procExec('unzip --help', $o, $c);
4382 4382
 			if ($c == 0) {
4383
-				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '',  'ext' => 'zip');
4383
+				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip');
4384 4384
 			}
4385 4385
 			unset($o);
4386 4386
 			$this->procExec('rar --version', $o, $c);
4387 4387
 			if ($c == 0 || $c == 7) {
4388 4388
 				$arcs['create']['application/x-rar']  = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar');
4389
-				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y',    'ext' => 'rar');
4389
+				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar');
4390 4390
 			} else {
4391 4391
 				unset($o);
4392 4392
 				$test = $this->procExec('unrar', $o, $c);
4393
-				if ($c==0 || $c == 7) {
4393
+				if ($c == 0 || $c == 7) {
4394 4394
 					$arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar');
4395 4395
 				}
4396 4396
 			}
@@ -4412,7 +4412,7 @@  discard block
 block discarded – undo
4412 4412
 				if (empty($arcs['extract']['application/x-tar'])) {
4413 4413
 					$arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar');
4414 4414
 				}
4415
-			} else if (substr(PHP_OS,0,3) === 'WIN') {
4415
+			} else if (substr(PHP_OS, 0, 3) === 'WIN') {
4416 4416
 				// check `7z` for Windows server.
4417 4417
 				unset($o);
4418 4418
 				$this->procExec('7z', $o, $c);
@@ -4466,22 +4466,22 @@  discard block
 block discarded – undo
4466 4466
 
4467 4467
 		// normalize `/../`
4468 4468
 		$normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#';
4469
-		while(preg_match($normreg, $path)) {
4469
+		while (preg_match($normreg, $path)) {
4470 4470
 			$path = preg_replace($normreg, '$1', $path);
4471 4471
 		}
4472 4472
 		
4473 4473
 		// 'Here'
4474
-		if ($path === '' || $path === '.' . $separator) return $base;
4474
+		if ($path === '' || $path === '.'.$separator) return $base;
4475 4475
 		
4476 4476
 		// Absolute path
4477 4477
 		if ($path[0] === $separator || strpos($path, $systemroot) === 0) {
4478 4478
 			return $path;
4479 4479
 		}
4480 4480
 		
4481
-		$preg_separator = '#' . $sepquoted . '#';
4481
+		$preg_separator = '#'.$sepquoted.'#';
4482 4482
 		
4483 4483
 		// Relative path from 'Here'
4484
-		if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) {
4484
+		if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) {
4485 4485
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4486 4486
 			if ($arrn[0] !== '.') {
4487 4487
 				array_unshift($arrn, '.');
@@ -4495,12 +4495,11 @@  discard block
 block discarded – undo
4495 4495
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4496 4496
 			$arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY);
4497 4497
 		
4498
-			while (! empty($arrn) && $arrn[0] === '..') {
4498
+			while (!empty($arrn) && $arrn[0] === '..') {
4499 4499
 				array_shift($arrn);
4500 4500
 				array_pop($arrp);
4501 4501
 			}
4502
-			$path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) :
4503
-				(! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot);
4502
+			$path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot);
4504 4503
 		}
4505 4504
 		
4506 4505
 		return $path;
@@ -4518,7 +4517,7 @@  discard block
 block discarded – undo
4518 4517
 			@chmod($dir, 0777);
4519 4518
 			foreach (array_diff(scandir($dir), array('.', '..')) as $file) {
4520 4519
 				@set_time_limit(30);
4521
-				$path = $dir . DIRECTORY_SEPARATOR . $file;
4520
+				$path = $dir.DIRECTORY_SEPARATOR.$file;
4522 4521
 				if (!is_link($dir) && is_dir($path)) {
4523 4522
 					$this->rmdirRecursive($path);
4524 4523
 				} else {
@@ -4605,22 +4604,22 @@  discard block
 block discarded – undo
4605 4604
 		try {
4606 4605
 			if ($start = is_string($zipPath)) {
4607 4606
 				$zip = new ZipArchive();
4608
-				if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) {
4607
+				if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) {
4609 4608
 					$zip = false;
4610 4609
 				}
4611 4610
 			} else {
4612 4611
 				$zip = $zipPath;
4613 4612
 			}
4614 4613
 			if ($zip) {
4615
-				foreach($files as $file) {
4616
-					$path = $dir . DIRECTORY_SEPARATOR . $file;
4614
+				foreach ($files as $file) {
4615
+					$path = $dir.DIRECTORY_SEPARATOR.$file;
4617 4616
 					if (is_dir($path)) {
4618 4617
 						$zip->addEmptyDir($file);
4619 4618
 						$_files = array();
4620 4619
 						if ($handle = opendir($path)) {
4621 4620
 							while (false !== ($entry = readdir($handle))) {
4622 4621
 								if ($entry !== "." && $entry !== "..") {
4623
-									$_files[] = $file . DIRECTORY_SEPARATOR . $entry;
4622
+									$_files[] = $file.DIRECTORY_SEPARATOR.$entry;
4624 4623
 								}
4625 4624
 							}
4626 4625
 							closedir($handle);
@@ -4805,7 +4804,7 @@  discard block
 block discarded – undo
4805 4804
 	 * @return resource|false
4806 4805
 	 * @author Dmitry (dio) Levashov
4807 4806
 	 **/
4808
-	abstract protected function _fopen($path, $mode="rb");
4807
+	abstract protected function _fopen($path, $mode = "rb");
4809 4808
 	
4810 4809
 	/**
4811 4810
 	 * Close opened file
@@ -4815,7 +4814,7 @@  discard block
 block discarded – undo
4815 4814
 	 * @return bool
4816 4815
 	 * @author Dmitry (dio) Levashov
4817 4816
 	 **/
4818
-	abstract protected function _fclose($fp, $path='');
4817
+	abstract protected function _fclose($fp, $path = '');
4819 4818
 	
4820 4819
 	/********************  file/dir manipulations *************************/
4821 4820
 	
Please login to merge, or discard this patch.
php/elFinderVolumeDropbox.class.php 1 patch
Spacing   +68 added lines, -69 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		
139 139
 		if ($options['user'] === 'init') {
140 140
 
141
-			if (! $this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) {
141
+			if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) {
142 142
 				return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}');
143 143
 			}
144 144
 			
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 				if (class_exists('OAuth', false)) {
149 149
 					$this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']);
150 150
 				} else {
151
-					if (! class_exists('HTTP_OAuth_Consumer', false)) {
151
+					if (!class_exists('HTTP_OAuth_Consumer', false)) {
152 152
 						// We're going to try to load in manually
153 153
 						include 'HTTP/OAuth/Consumer.php';
154 154
 					}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 				}
159 159
 			}
160 160
 			
161
-			if (! $this->oauth) {
161
+			if (!$this->oauth) {
162 162
 				return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}');
163 163
 			}
164 164
 
@@ -179,25 +179,25 @@  discard block
 block discarded – undo
179 179
 						unset($_SESSION['elFinderDropboxTokens']);
180 180
 					}
181 181
 				}
182
-				if (! $html) {
182
+				if (!$html) {
183 183
 					// get customdata
184 184
 					$cdata = '';
185 185
 					$innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user');
186
-					$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET;
187
-					foreach($this->ARGS as $k => $v) {
188
-						if (! in_array($k, $innerKeys)) {
189
-							$cdata .= '&' . $k . '=' . rawurlencode($v);
186
+					$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
187
+					foreach ($this->ARGS as $k => $v) {
188
+						if (!in_array($k, $innerKeys)) {
189
+							$cdata .= '&'.$k.'='.rawurlencode($v);
190 190
 						}
191 191
 					}
192
-					if (strpos($options['url'], 'http') !== 0 ) {
192
+					if (strpos($options['url'], 'http') !== 0) {
193 193
 						$options['url'] = $this->getConnectorUrl();
194 194
 					}
195
-					$callback  = $options['url']
195
+					$callback = $options['url']
196 196
 					           . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata;
197 197
 					
198 198
 					try {
199 199
 						$tokens = $this->oauth->getRequestToken();
200
-						$url= $this->oauth->getAuthorizeUrl(rawurlencode($callback));
200
+						$url = $this->oauth->getAuthorizeUrl(rawurlencode($callback));
201 201
 					} catch (Dropbox_Exception $e) {
202 202
 						return array('exit' => true, 'body' => '{msg:errAccess}');
203 203
 					}
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 		if (isset($netVolumes[$key])) {
245 245
 			$dropboxUid = $netVolumes[$key]['dropboxUid'];
246 246
 		}
247
-		foreach($netVolumes as $volume) {
247
+		foreach ($netVolumes as $volume) {
248 248
 			if (@$volume['host'] === 'dropbox' && @$volume['dropboxUid'] === $dropboxUid) {
249 249
 				$count++;
250 250
 			}
251 251
 		}
252 252
 		if ($count === 1) {
253 253
 			$this->DB->exec('drop table '.$this->DB_TableName);
254
-			foreach(glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) {
254
+			foreach (glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) {
255 255
 				unlink($tmb);
256 256
 			}
257 257
 		}
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 	 * @author Naoki Sawada
266 266
 	 */
267 267
 	private function getConnectorUrl() {
268
-		$url  = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://')
268
+		$url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://')
269 269
 		       . $_SERVER['SERVER_NAME']                                              // host
270
-		      . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT'])  // port
271
-		       . $_SERVER['REQUEST_URI'];                                             // path & query
270
+		      . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT'])  // port
271
+		       . $_SERVER['REQUEST_URI']; // path & query
272 272
 		list($url) = explode('?', $url);
273 273
 		return $url;
274 274
 	}
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
 		// make net mount key
305 305
 		$this->netMountKey = md5(join('-', array('dropbox', $this->options['path'])));
306 306
 
307
-		if (! $this->oauth) {
307
+		if (!$this->oauth) {
308 308
 			if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) {
309 309
 				$this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']);
310 310
 			} else {
311 311
 				if (class_exists('OAuth', false)) {
312 312
 					$this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']);
313 313
 				} else {
314
-					if (! class_exists('HTTP_OAuth_Consumer', false)) {
314
+					if (!class_exists('HTTP_OAuth_Consumer', false)) {
315 315
 						// We're going to try to load in manually
316 316
 						include 'HTTP/OAuth/Consumer.php';
317 317
 					}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			}
323 323
 		}
324 324
 		
325
-		if (! $this->oauth) {
325
+		if (!$this->oauth) {
326 326
 			return $this->setError('OAuth extension not loaded.');
327 327
 		}
328 328
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 		$this->root = $this->options['path'] = $this->_normpath($this->options['path']);
331 331
 
332 332
 		if (empty($this->options['alias'])) {
333
-			$this->options['alias'] = ($this->options['path'] === '/')? 'Dropbox.com'  : 'Dropbox'.$this->options['path'];
333
+			$this->options['alias'] = ($this->options['path'] === '/') ? 'Dropbox.com' : 'Dropbox'.$this->options['path'];
334 334
 		}
335 335
 
336 336
 		$this->rootName = $this->options['alias'];
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 		}
386 386
 		
387 387
 		// setup PDO
388
-		if (! $this->options['PDO_DSN']) {
388
+		if (!$this->options['PDO_DSN']) {
389 389
 			$this->options['PDO_DSN'] = 'sqlite:'.$this->metaCache.DIRECTORY_SEPARATOR.'.elFinder_dropbox_db_'.md5($this->dropboxUid.$this->options['consumerSecret']);
390 390
 		}
391 391
 		// DataBase table name
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 		// DataBase check or make table
394 394
 		try {
395 395
 			$this->DB = new PDO($this->options['PDO_DSN'], $this->options['PDO_User'], $this->options['PDO_Pass'], $this->options['PDO_Options']);
396
-			if (! $this->checkDB()) {
396
+			if (!$this->checkDB()) {
397 397
 				return $this->setError('Can not make DB table');
398 398
 			}
399 399
 		} catch (PDOException $e) {
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 				$res = false;
456 456
 			}
457 457
 		}
458
-		if (! $res) {
458
+		if (!$res) {
459 459
 			try {
460 460
 				$this->DB->exec('CREATE TABLE '.$this->DB_TableName.'(path text, fname text, dat blob, isdir integer);');
461 461
 				$this->DB->exec('CREATE UNIQUE INDEX nameidx ON '.$this->DB_TableName.'(path, fname)');
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 	 */
506 506
 	private function updateDBdat($path, $dat) {
507 507
 		return $this->query('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($dat))
508
-				. ', isdir=' . ($dat['is_dir']? 1 : 0)
508
+				. ', isdir='.($dat['is_dir'] ? 1 : 0)
509 509
 				. ' where path='.$this->DB->quote(strtolower($this->_dirname($path))).' and fname='.$this->DB->quote(strtolower(basename($path))));
510 510
 	}
511 511
 	/*********************************************************************/
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 	 */
531 531
 	protected function deltaCheck($refresh = true) {
532 532
 		$chk = false;
533
-		if (! $refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) {
533
+		if (!$refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) {
534 534
 			$chk = unserialize($chk[0]);
535 535
 		}
536 536
 		if ($chk && ($chk['mtime'] + $this->options['metaCacheTime']) > $_SERVER['REQUEST_TIME']) {
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 			do {
555 555
 				@ ini_set('max_execution_time', 120);
556 556
 				$_info = $this->dropbox->delta($cursor);
557
-				if (! empty($_info['reset'])) {
557
+				if (!empty($_info['reset'])) {
558 558
 					$this->DB->exec('TRUNCATE table '.$this->DB_TableName);
559 559
 					$this->DB->exec('insert into '.$this->DB_TableName.' values(\'\', \'\', \''.serialize(array('cursor' => '', 'mtime' => 0)).'\', 0);');
560 560
 					$this->DB->exec('insert into '.$this->DB_TableName.' values(\'/\', \'\', \''.serialize(array(
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 				}
568 568
 				$cursor = $_info['cursor'];
569 569
 				
570
-				foreach($_info['entries'] as $entry) {
570
+				foreach ($_info['entries'] as $entry) {
571 571
 					$key = strtolower($entry[0]);
572 572
 					$pkey = strtolower($this->_dirname($key));
573 573
 					
@@ -576,22 +576,22 @@  discard block
 block discarded – undo
576 576
 					$where = 'where path='.$path.' and fname='.$fname;
577 577
 					
578 578
 					if (empty($entry[1])) {
579
-						$ptimes[$pkey] = isset($ptimes[$pkey])? max(array($now, $ptimes[$pkey])) : $now;
579
+						$ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($now, $ptimes[$pkey])) : $now;
580 580
 						$this->DB->exec('delete from '.$this->DB_TableName.' '.$where);
581
-						! $delete && $delete = true;
581
+						!$delete && $delete = true;
582 582
 						continue;
583 583
 					}
584 584
 
585
-					$_itemTime = strtotime(isset($entry[1]['client_mtime'])? $entry[1]['client_mtime'] : $entry[1]['modified']);
586
-					$ptimes[$pkey] = isset($ptimes[$pkey])? max(array($_itemTime, $ptimes[$pkey])) : $_itemTime;
585
+					$_itemTime = strtotime(isset($entry[1]['client_mtime']) ? $entry[1]['client_mtime'] : $entry[1]['modified']);
586
+					$ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($_itemTime, $ptimes[$pkey])) : $_itemTime;
587 587
 					$sql = 'select path from '.$this->DB_TableName.' '.$where.' limit 1';
588
-					if (! $reset && $this->query($sql)) {
589
-						$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir']? 1 : 0).' ' .$where);
588
+					if (!$reset && $this->query($sql)) {
589
+						$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir'] ? 1 : 0).' '.$where);
590 590
 					} else {
591
-						$this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int)$entry[1]['is_dir'].')');
591
+						$this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int) $entry[1]['is_dir'].')');
592 592
 					}
593 593
 				}
594
-			} while (! empty($_info['has_more']));
594
+			} while (!empty($_info['has_more']));
595 595
 			
596 596
 			// update time stamp of parent holder
597 597
 			foreach ($ptimes as $_p => $_t) {
@@ -613,14 +613,14 @@  discard block
 block discarded – undo
613 613
 			}
614 614
 			
615 615
 			$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize(array('cursor'=>$cursor, 'mtime'=>$_SERVER['REQUEST_TIME']))).' where path=\'\' and fname=\'\'');
616
-			if (! $this->DB->commit()) {
616
+			if (!$this->DB->commit()) {
617 617
 				$e = $this->DB->errorInfo();
618 618
 				return $e[2];
619 619
 			}
620 620
 			if ($delete) {
621 621
 				$this->DB->exec('vacuum');
622 622
 			}
623
-		} catch(Dropbox_Exception $e) {
623
+		} catch (Dropbox_Exception $e) {
624 624
 			return $e->getMessage();
625 625
 		}
626 626
 		return true;
@@ -636,15 +636,14 @@  discard block
 block discarded – undo
636 636
 	protected function parseRaw($raw) {
637 637
 		$stat = array();
638 638
 
639
-		$stat['rev']   = isset($raw['rev'])? $raw['rev'] : 'root';
639
+		$stat['rev']   = isset($raw['rev']) ? $raw['rev'] : 'root';
640 640
 		$stat['name']  = basename($raw['path']);
641
-		$stat['mime']  = $raw['is_dir']? 'directory' : $raw['mime_type'];
641
+		$stat['mime']  = $raw['is_dir'] ? 'directory' : $raw['mime_type'];
642 642
 		$stat['size']  = $stat['mime'] == 'directory' ? 0 : $raw['bytes'];
643
-		$stat['ts']    = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) :
644
-		                (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']);
643
+		$stat['ts']    = isset($raw['client_mtime']) ? strtotime($raw['client_mtime']) : (isset($raw['modified']) ? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']);
645 644
 		$stat['dirs'] = 0;
646 645
 		if ($raw['is_dir']) {
647
-			$stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path'])));
646
+			$stat['dirs'] = (int) (bool) $this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path'])));
648 647
 		}
649 648
 		
650 649
 		if (!empty($raw['url'])) {
@@ -670,7 +669,7 @@  discard block
 block discarded – undo
670 669
 		$res = $this->query('select dat from '.$this->DB_TableName.' where path='.$this->DB->quote(strtolower($path)));
671 670
 		
672 671
 		if ($res) {
673
-			foreach($res as $raw) {
672
+			foreach ($res as $raw) {
674 673
 				$raw = unserialize($raw);
675 674
 				if ($stat = $this->parseRaw($raw)) {
676 675
 					$stat = $this->updateCache($raw['path'], $stat);
@@ -695,12 +694,12 @@  discard block
 block discarded – undo
695 694
 	protected function doSearch($path, $q, $mimes) {
696 695
 		$result = array();
697 696
 		$sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?');
698
-		$sth->execute(array((($path === '/')? '' : strtolower($path)).'%', '%'.strtolower($q).'%'));
697
+		$sth->execute(array((($path === '/') ? '' : strtolower($path)).'%', '%'.strtolower($q).'%'));
699 698
 		$res = $sth->fetchAll(PDO::FETCH_COLUMN);
700
-		$timeout = $this->options['searchTimeout']? $this->searchStart + $this->options['searchTimeout'] : 0;
699
+		$timeout = $this->options['searchTimeout'] ? $this->searchStart + $this->options['searchTimeout'] : 0;
701 700
 		
702 701
 		if ($res) {
703
-			foreach($res as $raw) {
702
+			foreach ($res as $raw) {
704 703
 				if ($timeout && $timeout < time()) {
705 704
 					$this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode($path)));
706 705
 					break;
@@ -798,10 +797,10 @@  discard block
 block discarded – undo
798 797
 		$tmb  = $this->tmbPath.DIRECTORY_SEPARATOR.$name;
799 798
 	
800 799
 		// copy image into tmbPath so some drivers does not store files on local fs
801
-		if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) {
800
+		if (!$data = $this->getThumbnail($path, $this->options['getTmbSize'])) {
802 801
 			return false;
803 802
 		}
804
-		if (! file_put_contents($tmb, $data)) {
803
+		if (!file_put_contents($tmb, $data)) {
805 804
 			return false;
806 805
 		}
807 806
 	
@@ -814,15 +813,15 @@  discard block
 block discarded – undo
814 813
 		}
815 814
 	
816 815
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
817
-		if ($s[0] <= $tmbSize && $s[1]  <= $tmbSize) {
818
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
816
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
817
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
819 818
 	
820 819
 		} else {
821 820
 	
822 821
 			if ($this->options['tmbCrop']) {
823 822
 	
824 823
 				/* Resize and crop if image bigger than thumbnail */
825
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
824
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
826 825
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
827 826
 				}
828 827
 	
@@ -836,7 +835,7 @@  discard block
 block discarded – undo
836 835
 				$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png');
837 836
 			}
838 837
 		
839
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
838
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
840 839
 		}
841 840
 		
842 841
 		if (!$result) {
@@ -893,7 +892,7 @@  discard block
 block discarded – undo
893 892
 					}
894 893
 				}
895 894
 			}
896
-			if (! $url) {
895
+			if (!$url) {
897 896
 				try {
898 897
 					$res = $this->dropbox->share($path, null, false);
899 898
 					$url = $res['url'];
@@ -905,7 +904,7 @@  discard block
 block discarded – undo
905 904
 					}
906 905
 					list($url) = explode('?', $url);
907 906
 					$url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url);
908
-					if (! isset($cache['share']) || $cache['share'] !== $url) {
907
+					if (!isset($cache['share']) || $cache['share'] !== $url) {
909 908
 						$cache['share'] = $url;
910 909
 						$this->updateDBdat($path, $cache);
911 910
 					}
@@ -929,12 +928,12 @@  discard block
 block discarded – undo
929 928
 		if (function_exists('curl_exec')) {
930 929
 
931 930
 			$c = curl_init();
932
-			curl_setopt( $c, CURLOPT_RETURNTRANSFER, true );
933
-			curl_setopt( $c, CURLOPT_CUSTOMREQUEST, 'HEAD' );
934
-			curl_setopt( $c, CURLOPT_HEADER, 1 );
935
-			curl_setopt( $c, CURLOPT_NOBODY, true );
936
-			curl_setopt( $c, CURLOPT_URL, $url );
937
-			$res = curl_exec( $c );
931
+			curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
932
+			curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD');
933
+			curl_setopt($c, CURLOPT_HEADER, 1);
934
+			curl_setopt($c, CURLOPT_NOBODY, true);
935
+			curl_setopt($c, CURLOPT_URL, $url);
936
+			$res = curl_exec($c);
938 937
 			
939 938
 		} else {
940 939
 			
@@ -950,13 +949,13 @@  discard block
 block discarded – undo
950 949
 				$result = $request2->send();
951 950
 				$res = array();
952 951
 				$res[] = 'HTTP/'.$result->getVersion().' '.$result->getStatus().' '.$result->getReasonPhrase();
953
-				foreach($result->getHeader() as $key => $val) {
954
-					$res[] = $key . ': ' . $val;
952
+				foreach ($result->getHeader() as $key => $val) {
953
+					$res[] = $key.': '.$val;
955 954
 				}
956 955
 				$res = join("\r\n", $res);
957
-			} catch( HTTP_Request2_Exception $e ){
956
+			} catch (HTTP_Request2_Exception $e) {
958 957
 				$res = '';
959
-			} catch (Exception $e){
958
+			} catch (Exception $e) {
960 959
 				$res = '';
961 960
 			}
962 961
 		
@@ -1008,7 +1007,7 @@  discard block
 block discarded – undo
1008 1007
 	 * @author Troex Nevelin
1009 1008
 	 **/
1010 1009
 	protected function _normpath($path) {
1011
-		$path = '/' . ltrim($path, '/');
1010
+		$path = '/'.ltrim($path, '/');
1012 1011
 		return $path;
1013 1012
 	}
1014 1013
 
@@ -1042,7 +1041,7 @@  discard block
 block discarded – undo
1042 1041
 	 * @author Dmitry (dio) Levashov
1043 1042
 	 **/
1044 1043
 	protected function _path($path) {
1045
-		return $this->rootName . $this->_normpath(substr($path, strlen($this->root)));
1044
+		return $this->rootName.$this->_normpath(substr($path, strlen($this->root)));
1046 1045
 	}
1047 1046
 
1048 1047
 	/**
@@ -1151,7 +1150,7 @@  discard block
 block discarded – undo
1151 1150
 	 * @return resource|false
1152 1151
 	 * @author Dmitry (dio) Levashov
1153 1152
 	 **/
1154
-	protected function _fopen($path, $mode='rb') {
1153
+	protected function _fopen($path, $mode = 'rb') {
1155 1154
 
1156 1155
 		if (($mode == 'rb' || $mode == 'r')) {
1157 1156
 			try {
@@ -1161,7 +1160,7 @@  discard block
 block discarded – undo
1161 1160
  				fputs($fp, "GET {$url['path']} HTTP/1.0\r\n");
1162 1161
  				fputs($fp, "Host: {$url['host']}\r\n");
1163 1162
  				fputs($fp, "\r\n");
1164
- 				while(trim(fgets($fp)) !== ''){};
1163
+ 				while (trim(fgets($fp)) !== '') {};
1165 1164
  				return $fp;
1166 1165
 			} catch (Dropbox_Exception $e) {
1167 1166
 				return false;
@@ -1192,7 +1191,7 @@  discard block
 block discarded – undo
1192 1191
 	 * @return bool
1193 1192
 	 * @author Dmitry (dio) Levashov
1194 1193
 	 **/
1195
-	protected function _fclose($fp, $path='') {
1194
+	protected function _fclose($fp, $path = '') {
1196 1195
 		@fclose($fp);
1197 1196
 		if ($path) {
1198 1197
 			@unlink($this->getTempFile($path));
Please login to merge, or discard this patch.
php/elFinderVolumeMySQL.class.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
 	 **/
310 310
 	protected function doSearch($path, $q, $mimes) {
311 311
 		$dirs = array();
312
-		$timeout = $this->options['searchTimeout']? $this->searchStart + $this->options['searchTimeout'] : 0;
312
+		$timeout = $this->options['searchTimeout'] ? $this->searchStart + $this->options['searchTimeout'] : 0;
313 313
 		
314 314
 		if ($path != $this->root) {
315 315
 			$inpath = array(intval($path));
316
-			while($inpath) {
316
+			while ($inpath) {
317 317
 				$in = '('.join(',', $inpath).')';
318 318
 				$inpath = array();
319 319
 				$sql = 'SELECT f.id FROM %s AS f WHERE f.parent_id IN '.$in.' AND `mime` = \'directory\'';
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 		
333 333
 		if ($mimes) {
334 334
 			$whrs = array();
335
-			foreach($mimes as $mime) {
335
+			foreach ($mimes as $mime) {
336 336
 				if (strpos($mime, '/') === false) {
337 337
 					$whrs[] = sprintf('f.mime LIKE "%s/%%"', $this->db->real_escape_string($mime));
338 338
 				} else {
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 			$whr = sprintf('f.name RLIKE "%s"', $this->db->real_escape_string($q));
345 345
 		}
346 346
 		if ($dirs) {
347
-			$whr = '(' . $whr . ') AND (`parent_id` IN (' . join(',', $dirs) . '))';
347
+			$whr = '('.$whr.') AND (`parent_id` IN ('.join(',', $dirs).'))';
348 348
 		}
349 349
 		
350 350
 		$sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, 0 AS dirs 
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 	 * @return resource|false
596 596
 	 * @author Dmitry (dio) Levashov
597 597
 	 **/
598
-	protected function _fopen($path, $mode='rb') {
598
+	protected function _fopen($path, $mode = 'rb') {
599 599
 		$fp = $this->tmbPath
600 600
 			? @fopen($this->getTempFile($path), 'w+')
601 601
 			: @tmpfile();
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 	 * @return bool
623 623
 	 * @author Dmitry (dio) Levashov
624 624
 	 **/
625
-	protected function _fclose($fp, $path='') {
625
+	protected function _fclose($fp, $path = '') {
626 626
 		@fclose($fp);
627 627
 		if ($path) {
628 628
 			@unlink($this->getTempFile($path));
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 		$this->clearcache();
755 755
 		
756 756
 		$mime = $stat['mime'];
757
-		$w = !empty($stat['width'])  ? $stat['width']  : 0;
757
+		$w = !empty($stat['width']) ? $stat['width'] : 0;
758 758
 		$h = !empty($stat['height']) ? $stat['height'] : 0;
759 759
 		
760 760
 		$id = $this->_joinPath($dir, $name);
Please login to merge, or discard this patch.