Completed
Pull Request — 2.x (#1148)
by
unknown
03:16
created
php/plugins/Normalizer/plugin.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		$defaults = array(
59 59
 			'enable' => true, // For control by volume driver
60 60
 			'nfc'    => true, // Canonical Decomposition followed by Canonical Composition
61
-			'nfkc'   => true,  // Compatibility Decomposition followed by Canonical
61
+			'nfkc'   => true, // Compatibility Decomposition followed by Canonical
62 62
 			'lowercase'   => false  // Make chars lowercase
63 63
 		);
64 64
 	
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	
68 68
 	public function cmdPreprocess($cmd, &$args, $elfinder, $volume) {
69 69
 		$opts = $this->getOpts($volume);
70
-		if (! $opts['enable']) {
70
+		if (!$opts['enable']) {
71 71
 			return false;
72 72
 		}
73 73
 		
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	
80 80
 	public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) {
81 81
 		$opts = $this->getOpts($volume);
82
-		if (! $opts['enable']) {
82
+		if (!$opts['enable']) {
83 83
 			return false;
84 84
 		}
85 85
 		
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 	private function normalize($str, $opts) {
105 105
 		if ($opts['nfc'] || $opts['nfkc']) {
106 106
 			if (class_exists('Normalizer')) {
107
-				if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C))
107
+				if ($opts['nfc'] && !Normalizer::isNormalized($str, Normalizer::FORM_C))
108 108
 					$str = Normalizer::normalize($str, Normalizer::FORM_C);
109
-				if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC))
109
+				if ($opts['nfkc'] && !Normalizer::isNormalized($str, Normalizer::FORM_KC))
110 110
 					$str = Normalizer::normalize($str, Normalizer::FORM_KC);
111 111
 			} else {
112
-				if (! class_exists('I18N_UnicodeNormalizer')) {
112
+				if (!class_exists('I18N_UnicodeNormalizer')) {
113 113
 					@ include_once 'I18N/UnicodeNormalizer.php';
114 114
 				}
115 115
 				if (class_exists('I18N_UnicodeNormalizer')) {
Please login to merge, or discard this patch.
php/elFinderVolumeDriver.class.php 1 patch
Spacing   +130 added lines, -131 removed lines patch added patch discarded remove patch
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 		'utf8fix'      => false,
275 275
 		 //                           й                 ё              Й               Ё              Ø         Å
276 276
 		'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"),
277
-		'utf8replace'  => array("\u0439",        "\u0451",       "\u0419",       "\u0401",       "\u00d8", "\u00c5")
277
+		'utf8replace'  => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5")
278 278
 	);
279 279
 
280 280
 	/**
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 **/
567 567
 	protected function configure() {
568 568
 		// set ARGS
569
-		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET;
569
+		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
570 570
 		// set thumbnails path
571 571
 		$path = $this->options['tmbPath'];
572 572
 		if ($path) {
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 		
598 598
 		// check 'statOwner' for command `chmod`
599 599
 		if (empty($this->options['statOwner'])) {
600
-			$this->disabled[] ='chmod';
600
+			$this->disabled[] = 'chmod';
601 601
 		}
602 602
 		
603 603
 		// check 'mimeMap'
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	 **/
703 703
 	public function mount(array $opts) {
704 704
 		if (!isset($opts['path']) || $opts['path'] === '') {
705
-			return $this->setError('Path undefined.');;
705
+			return $this->setError('Path undefined.'); ;
706 706
 		}
707 707
 		
708 708
 		$this->options = array_merge($this->options, $opts);
@@ -721,14 +721,14 @@  discard block
 block discarded – undo
721 721
 		$argInit = !empty($this->ARGS['init']);
722 722
 		
723 723
 		// session cache
724
-		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
724
+		if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
725 725
 			$_SESSION[elFinder::$sessionCacheKey][$this->id] = array();
726 726
 		}
727 727
 		$this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id];
728 728
 		
729 729
 		// default file attribute
730 730
 		$this->defaults = array(
731
-			'read'    => isset($this->options['defaults']['read'])  ? !!$this->options['defaults']['read']  : true,
731
+			'read'    => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true,
732 732
 			'write'   => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true,
733 733
 			'locked'  => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false,
734 734
 			'hidden'  => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false
@@ -755,8 +755,8 @@  discard block
 block discarded – undo
755 755
 			$this->access = $this->options['accessControl'];
756 756
 		}
757 757
 		
758
-		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y'));
759
-		$this->yesterday = $this->today-86400;
758
+		$this->today     = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
759
+		$this->yesterday = $this->today - 86400;
760 760
 		
761 761
 		// debug($this->attributes);
762 762
 		if (!$this->init()) {
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 				foreach ($mimecf as $line_num => $line) {
856 856
 					if (!preg_match('/^\s*#/', $line)) {
857 857
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
858
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
858
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
859 859
 							if (!isset(self::$mimetypes[$mime[$i]])) {
860 860
 								self::$mimetypes[$mime[$i]] = $mime[0];
861 861
 							}
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
 				'read'    => false
908 908
 			));
909 909
 		}
910
-		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1;
911
-		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48;
910
+		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1;
911
+		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48;
912 912
 		$this->URL      = $this->options['URL'];
913 913
 		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) {
914 914
 			$this->URL .= '/';
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 	public function options($hash) {
1036 1036
 		$create = $createext = array();
1037 1037
 		if (isset($this->archivers['create']) && is_array($this->archivers['create'])) {
1038
-			foreach($this->archivers['create'] as $m => $v) {
1038
+			foreach ($this->archivers['create'] as $m => $v) {
1039 1039
 				$create[] = $m;
1040 1040
 				$createext[$m] = $v['ext'];
1041 1041
 			}
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 				'extract' => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(),
1054 1054
 				'createext' => $createext
1055 1055
 			),
1056
-			'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array()
1056
+			'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array()
1057 1057
 		);
1058 1058
 	}
1059 1059
 	
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
 	 */
1067 1067
 	public function getOptionsPlugin($name = '') {
1068 1068
 		if ($name) {
1069
-			return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array();
1069
+			return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array();
1070 1070
 		} else {
1071 1071
 			return $this->options['plugin'];
1072 1072
 		}
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 		$file = $this->stat($path);
1197 1197
 		
1198 1198
 		if ($hash === $this->root()) {
1199
-			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array();
1199
+			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array();
1200 1200
 			$file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON
1201 1201
 		}
1202 1202
 		
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 	 * @return array|false
1212 1212
 	 * @author Dmitry (dio) Levashov
1213 1213
 	 **/
1214
-	public function dir($hash, $resolveLink=false) {
1214
+	public function dir($hash, $resolveLink = false) {
1215 1215
 		if (($dir = $this->file($hash)) == false) {
1216 1216
 			return $this->setError(elFinder::ERROR_DIR_NOT_FOUND);
1217 1217
 		}
@@ -1275,14 +1275,14 @@  discard block
 block discarded – undo
1275 1275
 	 * @return array|false
1276 1276
 	 * @author Dmitry (dio) Levashov
1277 1277
 	 **/
1278
-	public function tree($hash='', $deep=0, $exclude='') {
1278
+	public function tree($hash = '', $deep = 0, $exclude = '') {
1279 1279
 		$path = $hash ? $this->decode($hash) : $this->root;
1280 1280
 		
1281 1281
 		if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') {
1282 1282
 			return false;
1283 1283
 		}
1284 1284
 		
1285
-		$dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null);
1285
+		$dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null);
1286 1286
 		array_unshift($dirs, $dir);
1287 1287
 		return $dirs;
1288 1288
 	}
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
 	 * @return array|false
1513 1513
 	 * @author Dmitry (dio) Levashov
1514 1514
 	 **/
1515
-	public function duplicate($hash, $suffix='copy') {
1515
+	public function duplicate($hash, $suffix = 'copy') {
1516 1516
 		if ($this->commandDisabled('duplicate')) {
1517 1517
 			return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED);
1518 1518
 		}
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
 		
1589 1589
 		if ($file) { // file exists
1590 1590
 			// check POST data `overwrite` for 3rd party uploader
1591
-			$overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite'];
1591
+			$overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite'];
1592 1592
 			if ($overwrite) {
1593 1593
 				if (!$file['write']) {
1594 1594
 					return $this->setError(elFinder::ERROR_PERM_DENIED);
@@ -1659,7 +1659,7 @@  discard block
 block discarded – undo
1659 1659
 		if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) {
1660 1660
 			return $rmSrc
1661 1661
 				? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test))
1662
-				: $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1662
+				: $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1663 1663
 		}
1664 1664
 
1665 1665
 		$test = $this->joinPathCE($destination, $name);
@@ -1822,7 +1822,7 @@  discard block
 block discarded – undo
1822 1822
 			return $this->setError(elFinder::ERROR_PERM_DENIED);
1823 1823
 		}
1824 1824
 		$this->clearcache();
1825
-		$this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir;
1825
+		$this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir;
1826 1826
 		
1827 1827
 		if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) {
1828 1828
 			if (is_array($path)) {
@@ -1880,9 +1880,9 @@  discard block
 block discarded – undo
1880 1880
 		if ($name === '') {
1881 1881
 			$name = count($files) == 1 ? $files[0] : 'Archive';
1882 1882
 		} else {
1883
-			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name));
1883
+			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name));
1884 1884
 		}
1885
-		$name .='.' . $archiver['ext'];
1885
+		$name .= '.'.$archiver['ext'];
1886 1886
 		$name = $this->uniqueName($dir, $name, '');
1887 1887
 		$this->clearcache();
1888 1888
 		return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false;
@@ -1918,7 +1918,7 @@  discard block
 block discarded – undo
1918 1918
 		
1919 1919
 		$path = $this->decode($hash);
1920 1920
 		
1921
-		$work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path);
1921
+		$work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path);
1922 1922
 
1923 1923
 		if (!$work_path || !is_writable($work_path)) {
1924 1924
 			if ($work_path && $path !== $work_path && is_file($work_path)) {
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
 			}
1934 1934
 		}
1935 1935
 
1936
-		switch($mode) {
1936
+		switch ($mode) {
1937 1937
 			
1938 1938
 			case 'propresize':
1939 1939
 				$result = $this->imgResize($work_path, $width, $height, true, true);
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
 		}
2030 2030
 		return ($q === '' || $this->commandDisabled('search'))
2031 2031
 			? array()
2032
-			: $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes);
2032
+			: $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes);
2033 2033
 	}
2034 2034
 	
2035 2035
 	/**
@@ -2098,9 +2098,9 @@  discard block
 block discarded – undo
2098 2098
 		$path = ltrim($path, $this->separator);
2099 2099
 		$dirs = explode($this->separator, $path);
2100 2100
 		array_pop($dirs);
2101
-		foreach($dirs as $dir) {
2101
+		foreach ($dirs as $dir) {
2102 2102
 			$targetPath = $this->joinPathCE($base, $dir);
2103
-			if (! $_realpath = $this->realpath($this->encode($targetPath))) {
2103
+			if (!$_realpath = $this->realpath($this->encode($targetPath))) {
2104 2104
 				if ($stat = $this->mkdir($targetHash, $dir)) {
2105 2105
 					$result['added'][] = $stat;
2106 2106
 					$targetHash = $stat['hash'];
@@ -2167,7 +2167,7 @@  discard block
 block discarded – undo
2167 2167
 	 * @author Naoki Sawada
2168 2168
 	 **/
2169 2169
 	protected function dirnameCE($path) {
2170
-		return (!$this->encoding)? $this->_dirname($path) :	$this->convEncOut($this->_dirname($this->convEncIn($path)));
2170
+		return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path)));
2171 2171
 	}
2172 2172
 	
2173 2173
 	/**
@@ -2178,7 +2178,7 @@  discard block
 block discarded – undo
2178 2178
 	 * @author Naoki Sawada
2179 2179
 	 **/
2180 2180
 	protected function basenameCE($path) {
2181
-		return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2181
+		return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2182 2182
 	}
2183 2183
 	
2184 2184
 	/**
@@ -2191,7 +2191,7 @@  discard block
 block discarded – undo
2191 2191
 	 * @author Naoki Sawada
2192 2192
 	 **/
2193 2193
 	protected function joinPathCE($dir, $name) {
2194
-		return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2194
+		return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2195 2195
 	}
2196 2196
 	
2197 2197
 	/**
@@ -2202,7 +2202,7 @@  discard block
 block discarded – undo
2202 2202
 	 * @author Naoki Sawada
2203 2203
 	 **/
2204 2204
 	protected function normpathCE($path) {
2205
-		return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2205
+		return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2206 2206
 	}
2207 2207
 	
2208 2208
 	/**
@@ -2213,7 +2213,7 @@  discard block
 block discarded – undo
2213 2213
 	 * @author Naoki Sawada
2214 2214
 	 **/
2215 2215
 	protected function relpathCE($path) {
2216
-		return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2216
+		return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2217 2217
 	}
2218 2218
 	
2219 2219
 	/**
@@ -2224,7 +2224,7 @@  discard block
 block discarded – undo
2224 2224
 	 * @author Naoki Sawada
2225 2225
 	 **/
2226 2226
 	protected function abspathCE($path) {
2227
-		return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path)));
2227
+		return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path)));
2228 2228
 	}
2229 2229
 	
2230 2230
 	/**
@@ -2236,7 +2236,7 @@  discard block
 block discarded – undo
2236 2236
 	 * @author Naoki Sawada
2237 2237
 	 **/
2238 2238
 	protected function inpathCE($path, $parent) {
2239
-		return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2239
+		return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2240 2240
 	}
2241 2241
 	
2242 2242
 	/**
@@ -2247,8 +2247,8 @@  discard block
 block discarded – undo
2247 2247
 	 * @return resource|false
2248 2248
 	 * @author Naoki Sawada
2249 2249
 	 **/
2250
-	protected function fopenCE($path, $mode='rb') {
2251
-		return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2250
+	protected function fopenCE($path, $mode = 'rb') {
2251
+		return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2252 2252
 	}
2253 2253
 	
2254 2254
 	/**
@@ -2259,8 +2259,8 @@  discard block
 block discarded – undo
2259 2259
 	 * @return bool
2260 2260
 	 * @author Naoki Sawada
2261 2261
 	 **/
2262
-	protected function fcloseCE($fp, $path='') {
2263
-		return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2262
+	protected function fcloseCE($fp, $path = '') {
2263
+		return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2264 2264
 	}
2265 2265
 	
2266 2266
 	/**
@@ -2275,7 +2275,7 @@  discard block
 block discarded – undo
2275 2275
 	 * @author Naoki Sawada
2276 2276
 	 **/
2277 2277
 	protected function saveCE($fp, $dir, $name, $stat) {
2278
-		return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2278
+		return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2279 2279
 	}
2280 2280
 	
2281 2281
 	/**
@@ -2287,7 +2287,7 @@  discard block
 block discarded – undo
2287 2287
 	 **/
2288 2288
 	protected function subdirsCE($path) {
2289 2289
 		if (!isset($this->subdirsCache[$path])) {
2290
-			$this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2290
+			$this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2291 2291
 		}
2292 2292
 		return $this->subdirsCache[$path];
2293 2293
 	}
@@ -2300,7 +2300,7 @@  discard block
 block discarded – undo
2300 2300
 	 * @author Naoki Sawada
2301 2301
 	 **/
2302 2302
 	protected function scandirCE($path) {
2303
-		return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2303
+		return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2304 2304
 	}
2305 2305
 	
2306 2306
 	/**
@@ -2313,7 +2313,7 @@  discard block
 block discarded – undo
2313 2313
 	 * @author Naoki Sawada
2314 2314
 	 **/
2315 2315
 	protected function symlinkCE($source, $targetDir, $name) {
2316
-		return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2316
+		return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2317 2317
 	}
2318 2318
 	
2319 2319
 	/***************** paths *******************/
@@ -2332,7 +2332,7 @@  discard block
 block discarded – undo
2332 2332
 			// cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root
2333 2333
 			$p = $this->relpathCE($path);
2334 2334
 			// if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt
2335
-			if ($p === '')	{
2335
+			if ($p === '') {
2336 2336
 				$p = DIRECTORY_SEPARATOR;
2337 2337
 			}
2338 2338
 
@@ -2365,7 +2365,7 @@  discard block
 block discarded – undo
2365 2365
 			// TODO uncrypt hash and return path
2366 2366
 			$path = $this->uncrypt($h); 
2367 2367
 			// append ROOT to path after it was cut in encode
2368
-			return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2368
+			return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2369 2369
 		}
2370 2370
 	}
2371 2371
 	
@@ -2421,22 +2421,22 @@  discard block
 block discarded – undo
2421 2421
 	 * @return string
2422 2422
 	 * @author Dmitry (dio) Levashov
2423 2423
 	 **/
2424
-	public function uniqueName($dir, $name, $suffix = ' copy', $checkNum=true) {
2425
-		$ext  = '';
2424
+	public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true) {
2425
+		$ext = '';
2426 2426
 
2427 2427
 		if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
2428 2428
 			$ext  = '.'.$m[1];
2429
-			$name = substr($name, 0,  strlen($name)-strlen($m[0]));
2429
+			$name = substr($name, 0, strlen($name) - strlen($m[0]));
2430 2430
 		} 
2431 2431
 		
2432 2432
 		if ($checkNum && preg_match('/('.$suffix.')(\d*)$/i', $name, $m)) {
2433
-			$i    = (int)$m[2];
2434
-			$name = substr($name, 0, strlen($name)-strlen($m[2]));
2433
+			$i    = (int) $m[2];
2434
+			$name = substr($name, 0, strlen($name) - strlen($m[2]));
2435 2435
 		} else {
2436 2436
 			$i     = 1;
2437 2437
 			$name .= $suffix;
2438 2438
 		}
2439
-		$max = $i+100000;
2439
+		$max = $i + 100000;
2440 2440
 
2441 2441
 		while ($i <= $max) {
2442 2442
 			$n = $name.($i > 0 ? $i : '').$ext;
@@ -2460,7 +2460,7 @@  discard block
 block discarded – undo
2460 2460
 	 * @author Naoki Sawada
2461 2461
 	 */
2462 2462
 	public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') {
2463
-		return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2463
+		return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2464 2464
 	}
2465 2465
 	
2466 2466
 	/**
@@ -2473,7 +2473,7 @@  discard block
 block discarded – undo
2473 2473
 	 * @author Naoki Sawada
2474 2474
 	 */
2475 2475
 	public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') {
2476
-		return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2476
+		return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2477 2477
 	}
2478 2478
 	
2479 2479
 	/**
@@ -2493,7 +2493,7 @@  discard block
 block discarded – undo
2493 2493
 			}
2494 2494
 			if (is_array($var)) {
2495 2495
 				$_ret = array();
2496
-				foreach($var as $_k => $_v) {
2496
+				foreach ($var as $_k => $_v) {
2497 2497
 					$_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_');
2498 2498
 				}
2499 2499
 				$var = $_ret;
@@ -2505,7 +2505,7 @@  discard block
 block discarded – undo
2505 2505
 						$_var = str_replace('?', $unknown, $_var);
2506 2506
 					}
2507 2507
 				}
2508
-				if  ($_var !== false) {
2508
+				if ($_var !== false) {
2509 2509
 					$var = $_var;
2510 2510
 				}
2511 2511
 			}
@@ -2532,7 +2532,7 @@  discard block
 block discarded – undo
2532 2532
 		
2533 2533
 		$key = '';
2534 2534
 		if ($path !== '') {
2535
-			$key = $this->id . '#' . $path;
2535
+			$key = $this->id.'#'.$path;
2536 2536
 			if (isset($cache[$key])) {
2537 2537
 				return $cache[$key];
2538 2538
 			}
@@ -2564,7 +2564,7 @@  discard block
 block discarded – undo
2564 2564
 		if ($work = $this->getTempFile()) {
2565 2565
 			if ($wfp = fopen($work, 'wb')) {
2566 2566
 				if ($fp = $this->_fopen($path)) {
2567
-					while(!feof($fp)) {
2567
+					while (!feof($fp)) {
2568 2568
 						fwrite($wfp, fread($fp, 8192));
2569 2569
 					}
2570 2570
 					$this->_fclose($fp, $path);
@@ -2608,7 +2608,7 @@  discard block
 block discarded – undo
2608 2608
 			@set_time_limit(30);
2609 2609
 			$stat = $this->stat($this->convEncOut($p));
2610 2610
 			$this->convEncIn();
2611
-			($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p);
2611
+			($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p);
2612 2612
 		}
2613 2613
 		return $this->_rmdir($localpath);
2614 2614
 	}
@@ -2625,7 +2625,7 @@  discard block
 block discarded – undo
2625 2625
 	 * @return bool
2626 2626
 	 * @author Dmitry (dio) Levashov
2627 2627
 	 **/
2628
-	protected function attr($path, $name, $val=null, $isDir=null) {
2628
+	protected function attr($path, $name, $val = null, $isDir = null) {
2629 2629
 		if (!isset($this->defaults[$name])) {
2630 2630
 			return false;
2631 2631
 		}
@@ -2657,7 +2657,7 @@  discard block
 block discarded – undo
2657 2657
 			} 
2658 2658
 		}
2659 2659
 		
2660
-		return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm;
2660
+		return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm;
2661 2661
 	}
2662 2662
 	
2663 2663
 	/**
@@ -2701,7 +2701,7 @@  discard block
 block discarded – undo
2701 2701
 	protected function allowPutMime($mime) {
2702 2702
 		// logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order
2703 2703
 		$allow  = $this->mimeAccepted($mime, $this->uploadAllow, null);
2704
-		$deny   = $this->mimeAccepted($mime, $this->uploadDeny,  null);
2704
+		$deny   = $this->mimeAccepted($mime, $this->uploadDeny, null);
2705 2705
 		$res = true; // default to allow
2706 2706
 		if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny'
2707 2707
 			$res = false; // default is deny
@@ -2772,10 +2772,10 @@  discard block
 block discarded – undo
2772 2772
 			if ($this->rootName) {
2773 2773
 				$stat['name'] = $this->rootName;
2774 2774
 			}
2775
-			if (! empty($this->options['icon'])) {
2775
+			if (!empty($this->options['icon'])) {
2776 2776
 				$stat['icon'] = $this->options['icon'];
2777 2777
 			}
2778
-			if (! empty($this->options['rootCssClass'])) {
2778
+			if (!empty($this->options['rootCssClass'])) {
2779 2779
 				$stat['csscls'] = $this->options['rootCssClass'];
2780 2780
 			}
2781 2781
 		} else {
@@ -2819,7 +2819,7 @@  discard block
 block discarded – undo
2819 2819
 			// lock when parent directory is not writable
2820 2820
 			if (!isset($stat['locked'])) {
2821 2821
 				$parent = $this->dirnameCE($path);
2822
-				$pstat = isset($this->cache[$parent])? $this->cache[$parent] : array();
2822
+				$pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array();
2823 2823
 				if (isset($pstat['write']) && !$pstat['write']) {
2824 2824
 					$stat['locked'] = true;
2825 2825
 				}
@@ -2877,7 +2877,7 @@  discard block
 block discarded – undo
2877 2877
 			}
2878 2878
 			if (!isset($stat['url']) && $this->URL && $this->encoding) {
2879 2879
 				$_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1));
2880
-				$stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true)));
2880
+				$stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true)));
2881 2881
 			}
2882 2882
 		} else {
2883 2883
 			if ($isDir) {
@@ -3120,7 +3120,7 @@  discard block
 block discarded – undo
3120 3120
 	 * @return array
3121 3121
 	 * @author Dmitry (dio) Levashov
3122 3122
 	 **/
3123
-	protected function gettree($path, $deep, $exclude='') {
3123
+	protected function gettree($path, $deep, $exclude = '') {
3124 3124
 		$dirs = array();
3125 3125
 		
3126 3126
 		!isset($this->dirsCache[$path]) && $this->cacheDir($path);
@@ -3131,7 +3131,7 @@  discard block
 block discarded – undo
3131 3131
 			if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') {
3132 3132
 				$dirs[] = $stat;
3133 3133
 				if ($deep > 0 && !empty($stat['dirs'])) {
3134
-					$dirs = array_merge($dirs, $this->gettree($p, $deep-1));
3134
+					$dirs = array_merge($dirs, $this->gettree($p, $deep - 1));
3135 3135
 				}
3136 3136
 			}
3137 3137
 		}
@@ -3151,7 +3151,7 @@  discard block
 block discarded – undo
3151 3151
 	protected function doSearch($path, $q, $mimes) {
3152 3152
 		$result = array();
3153 3153
 
3154
-		foreach($this->scandirCE($path) as $p) {
3154
+		foreach ($this->scandirCE($path) as $p) {
3155 3155
 			@set_time_limit(30);
3156 3156
 			$stat = $this->stat($p);
3157 3157
 
@@ -3172,7 +3172,7 @@  discard block
 block discarded – undo
3172 3172
 					if ($this->encoding) {
3173 3173
 						$path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true)));
3174 3174
 					}
3175
-					$stat['url'] = $this->URL . $path;
3175
+					$stat['url'] = $this->URL.$path;
3176 3176
 				}
3177 3177
 				
3178 3178
 				$result[] = $stat;
@@ -3206,7 +3206,7 @@  discard block
 block discarded – undo
3206 3206
 			if (!$this->inpathCE($target, $this->root)) {
3207 3207
 				return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK);
3208 3208
 			}
3209
-			$stat   = $this->stat($target);
3209
+			$stat = $this->stat($target);
3210 3210
 			$this->clearcache();
3211 3211
 			return $stat && $this->symlinkCE($target, $dst, $name)
3212 3212
 				? $this->joinPathCE($dst, $name)
@@ -3483,15 +3483,15 @@  discard block
 block discarded – undo
3483 3483
 		}
3484 3484
 
3485 3485
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
3486
-		if ($s[0] <= $tmbSize && $s[1]	<= $tmbSize) {
3487
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3486
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
3487
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3488 3488
 		} else {
3489 3489
 		
3490 3490
 			if ($this->options['tmbCrop']) {
3491 3491
 		
3492 3492
 				$result = $tmb;
3493 3493
 				/* Resize and crop if image bigger than thumbnail */
3494
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3494
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3495 3495
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
3496 3496
 				}
3497 3497
 		
@@ -3508,7 +3508,7 @@  discard block
 block discarded – undo
3508 3508
 			}
3509 3509
 		
3510 3510
 			if ($result) {
3511
-				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3511
+				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3512 3512
 			}
3513 3513
 		}
3514 3514
 		
@@ -3549,18 +3549,18 @@  discard block
 block discarded – undo
3549 3549
 			/* Resizing by biggest side */
3550 3550
 			if ($resizeByBiggerSide) {
3551 3551
 				if ($orig_w > $orig_h) {
3552
-					$size_h = round($orig_h * $width / $orig_w);
3552
+					$size_h = round($orig_h*$width/$orig_w);
3553 3553
 					$size_w = $width;
3554 3554
 				} else {
3555
-					$size_w = round($orig_w * $height / $orig_h);
3555
+					$size_w = round($orig_w*$height/$orig_h);
3556 3556
 					$size_h = $height;
3557 3557
 				}
3558 3558
 			} else {
3559 3559
 				if ($orig_w > $orig_h) {
3560
-					$size_w = round($orig_w * $height / $orig_h);
3560
+					$size_w = round($orig_w*$height/$orig_h);
3561 3561
 					$size_h = $height;
3562 3562
 				} else {
3563
-					$size_h = round($orig_h * $width / $orig_w);
3563
+					$size_h = round($orig_h*$width/$orig_w);
3564 3564
 					$size_w = $width;
3565 3565
 				}
3566 3566
 			}
@@ -3578,7 +3578,7 @@  discard block
 block discarded – undo
3578 3578
 				// Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb
3579 3579
 				// resize bench: http://app-mgng.rhcloud.com/9
3580 3580
 				// resize sample: http://www.dylanbeattie.net/magick/filters/result.html
3581
-				$filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3581
+				$filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3582 3582
 				
3583 3583
 				$ani = ($img->getNumberImages() > 1);
3584 3584
 				if ($ani && is_null($destformat)) {
@@ -3603,11 +3603,11 @@  discard block
 block discarded – undo
3603 3603
 				break;
3604 3604
 
3605 3605
 			case 'gd':
3606
-				$img = self::gdImageCreate($path,$s['mime']);
3606
+				$img = self::gdImageCreate($path, $s['mime']);
3607 3607
 
3608
-				if ($img &&  false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3608
+				if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3609 3609
 				
3610
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3610
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3611 3611
 					
3612 3612
 					if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) {
3613 3613
 						return false;
@@ -3683,11 +3683,11 @@  discard block
 block discarded – undo
3683 3683
 				break;
3684 3684
 
3685 3685
 			case 'gd':
3686
-				$img = self::gdImageCreate($path,$s['mime']);
3686
+				$img = self::gdImageCreate($path, $s['mime']);
3687 3687
 
3688
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3688
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3689 3689
 					
3690
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3690
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3691 3691
 
3692 3692
 					$size_w = $width;
3693 3693
 					$size_h = $height;
@@ -3737,8 +3737,8 @@  discard block
 block discarded – undo
3737 3737
 		$result = false;
3738 3738
 
3739 3739
 		/* Coordinates for image over square aligning */
3740
-		$y = ceil(abs($height - $s[1]) / 2); 
3741
-		$x = ceil(abs($width - $s[0]) / 2);
3740
+		$y = ceil(abs($height - $s[1])/2); 
3741
+		$x = ceil(abs($width - $s[0])/2);
3742 3742
 
3743 3743
 		switch ($this->imgLib) {
3744 3744
 			case 'imagick':
@@ -3758,7 +3758,7 @@  discard block
 block discarded – undo
3758 3758
 						$gif->newImage($width, $height, new ImagickPixel($bgcolor));
3759 3759
 						$gif->setImageColorspace($img->getImageColorspace());
3760 3760
 						$gif->setImageFormat('gif');
3761
-						$gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3761
+						$gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3762 3762
 						$gif->setImageDelay($img->getImageDelay());
3763 3763
 						$gif->setImageIterations($img->getImageIterations());
3764 3764
 						$img1->addImage($gif);
@@ -3774,7 +3774,7 @@  discard block
 block discarded – undo
3774 3774
 					$img1->newImage($width, $height, new ImagickPixel($bgcolor));
3775 3775
 					$img1->setImageColorspace($img->getImageColorspace());
3776 3776
 					$img1->setImageFormat($destformat != null ? $destformat : $img->getFormat());
3777
-					$img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3777
+					$img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3778 3778
 					$result = $img1->writeImage($path);
3779 3779
 				}
3780 3780
 				
@@ -3785,11 +3785,11 @@  discard block
 block discarded – undo
3785 3785
 				break;
3786 3786
 
3787 3787
 			case 'gd':
3788
-				$img = self::gdImageCreate($path,$s['mime']);
3788
+				$img = self::gdImageCreate($path, $s['mime']);
3789 3789
 
3790
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3790
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3791 3791
 
3792
-					self::gdImageBackground($tmp,$bgcolor);
3792
+					self::gdImageBackground($tmp, $bgcolor);
3793 3793
 
3794 3794
 					if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) {
3795 3795
 						return false;
@@ -3820,15 +3820,15 @@  discard block
 block discarded – undo
3820 3820
 	 * @author Troex Nevelin
3821 3821
 	 **/
3822 3822
 	protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null) {
3823
-		if (($s = @getimagesize($path)) == false || $degree % 360 === 0) {
3823
+		if (($s = @getimagesize($path)) == false || $degree%360 === 0) {
3824 3824
 			return false;
3825 3825
 		}
3826 3826
 
3827 3827
 		$result = false;
3828 3828
 
3829 3829
 		// try lossless rotate
3830
-		if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3831
-			$count = ($degree / 90) % 4;
3830
+		if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3831
+			$count = ($degree/90)%4;
3832 3832
 			$exiftran = array(
3833 3833
 				1 => '-9',
3834 3834
 				2 => '-1',
@@ -3844,7 +3844,7 @@  discard block
 block discarded – undo
3844 3844
 				'exiftran -i '.$exiftran[$count].' '.$path,
3845 3845
 				'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath
3846 3846
 			);
3847
-			foreach($cmds as $cmd) {
3847
+			foreach ($cmds as $cmd) {
3848 3848
 				if ($this->procExec($cmd) === 0) {
3849 3849
 					$result = true;
3850 3850
 					break;
@@ -3880,12 +3880,12 @@  discard block
 block discarded – undo
3880 3880
 				break;
3881 3881
 
3882 3882
 			case 'gd':
3883
-				$img = self::gdImageCreate($path,$s['mime']);
3883
+				$img = self::gdImageCreate($path, $s['mime']);
3884 3884
 
3885 3885
 				$degree = 360 - $degree;
3886 3886
 				list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
3887 3887
 				$bgcolor = imagecolorallocate($img, $r, $g, $b);
3888
-				$tmp = imageRotate($img, $degree, (int)$bgcolor);
3888
+				$tmp = imageRotate($img, $degree, (int) $bgcolor);
3889 3889
 
3890 3890
 				$result = self::gdImage($tmp, $path, $destformat, $s['mime']);
3891 3891
 
@@ -3910,11 +3910,11 @@  discard block
 block discarded – undo
3910 3910
 	 * @return int     exit code
3911 3911
 	 * @author Alexey Sukhotin
3912 3912
 	 **/
3913
-	protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) {
3913
+	protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) {
3914 3914
 
3915 3915
 		$descriptorspec = array(
3916
-			0 => array("pipe", "r"),  // stdin
3917
-			1 => array("pipe", "w"),  // stdout
3916
+			0 => array("pipe", "r"), // stdin
3917
+			1 => array("pipe", "w"), // stdout
3918 3918
 			2 => array("pipe", "w")   // stderr
3919 3919
 		);
3920 3920
 
@@ -3971,8 +3971,8 @@  discard block
 block discarded – undo
3971 3971
 	 * @param string $mime
3972 3972
 	 * @return gd image resource identifier
3973 3973
 	 */
3974
-	protected function gdImageCreate($path,$mime){
3975
-		switch($mime){
3974
+	protected function gdImageCreate($path, $mime) {
3975
+		switch ($mime) {
3976 3976
 			case 'image/jpeg':
3977 3977
 			return imagecreatefromjpeg($path);
3978 3978
 
@@ -3996,7 +3996,7 @@  discard block
 block discarded – undo
3996 3996
 	 * @param string $destformat The Image type to use for $filename
3997 3997
 	 * @param string $mime The original image mime type
3998 3998
 	 */
3999
-	protected function gdImage($image, $filename, $destformat, $mime ){
3999
+	protected function gdImage($image, $filename, $destformat, $mime) {
4000 4000
 
4001 4001
 		if ($destformat == 'jpg' || ($destformat == null && $mime == 'image/jpeg')) {
4002 4002
 			return imagejpeg($image, $filename, 100);
@@ -4015,13 +4015,13 @@  discard block
 block discarded – undo
4015 4015
 	 * @param resource $image gd image resource
4016 4016
 	 * @param string $bgcolor background color in #rrggbb format
4017 4017
 	 */
4018
-	protected function gdImageBackground($image, $bgcolor){
4018
+	protected function gdImageBackground($image, $bgcolor) {
4019 4019
 
4020
-		if( $bgcolor == 'transparent' ){
4021
-			imagesavealpha($image,true);
4020
+		if ($bgcolor == 'transparent') {
4021
+			imagesavealpha($image, true);
4022 4022
 			$bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127);
4023 4023
 
4024
-		}else{
4024
+		} else {
4025 4025
 			list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4026 4026
 			$bgcolor1 = imagecolorallocate($image, $r, $g, $b);
4027 4027
 		}
@@ -4059,13 +4059,13 @@  discard block
 block discarded – undo
4059 4059
 	* @return int|bool
4060 4060
 	* @author Alexey Sukhotin
4061 4061
 	**/
4062
-	protected function stripos($haystack , $needle , $offset = 0) {
4062
+	protected function stripos($haystack, $needle, $offset = 0) {
4063 4063
 		if (function_exists('mb_stripos')) {
4064
-			return mb_stripos($haystack , $needle , $offset);
4064
+			return mb_stripos($haystack, $needle, $offset);
4065 4065
 		} else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) {
4066 4066
 			return mb_strpos(mb_strtolower($haystack), mb_strtolower($needle), $offset);
4067 4067
 		} 
4068
-		return stripos($haystack , $needle , $offset);
4068
+		return stripos($haystack, $needle, $offset);
4069 4069
 	}
4070 4070
 
4071 4071
 	/**
@@ -4115,22 +4115,22 @@  discard block
 block discarded – undo
4115 4115
 			unset($o);
4116 4116
 			$this->procExec('zip -v', $o, $c);
4117 4117
 			if ($c == 0) {
4118
-				$arcs['create']['application/zip']  = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4118
+				$arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4119 4119
 			}
4120 4120
 			unset($o);
4121 4121
 			$this->procExec('unzip --help', $o, $c);
4122 4122
 			if ($c == 0) {
4123
-				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '',  'ext' => 'zip');
4123
+				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip');
4124 4124
 			}
4125 4125
 			unset($o);
4126 4126
 			$this->procExec('rar --version', $o, $c);
4127 4127
 			if ($c == 0 || $c == 7) {
4128 4128
 				$arcs['create']['application/x-rar']  = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar');
4129
-				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y',    'ext' => 'rar');
4129
+				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar');
4130 4130
 			} else {
4131 4131
 				unset($o);
4132 4132
 				$test = $this->procExec('unrar', $o, $c);
4133
-				if ($c==0 || $c == 7) {
4133
+				if ($c == 0 || $c == 7) {
4134 4134
 					$arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar');
4135 4135
 				}
4136 4136
 			}
@@ -4152,7 +4152,7 @@  discard block
 block discarded – undo
4152 4152
 				if (empty($arcs['extract']['application/x-tar'])) {
4153 4153
 					$arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar');
4154 4154
 				}
4155
-			} else if (substr(PHP_OS,0,3) === 'WIN') {
4155
+			} else if (substr(PHP_OS, 0, 3) === 'WIN') {
4156 4156
 				// check `7z` for Windows server.
4157 4157
 				unset($o);
4158 4158
 				$this->procExec('7z', $o, $c);
@@ -4206,22 +4206,22 @@  discard block
 block discarded – undo
4206 4206
 
4207 4207
 		// normalize `/../`
4208 4208
 		$normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#';
4209
-		while(preg_match($normreg, $path)) {
4209
+		while (preg_match($normreg, $path)) {
4210 4210
 			$path = preg_replace($normreg, '$1', $path);
4211 4211
 		}
4212 4212
 		
4213 4213
 		// 'Here'
4214
-		if ($path === '' || $path === '.' . $separator) return $base;
4214
+		if ($path === '' || $path === '.'.$separator) return $base;
4215 4215
 		
4216 4216
 		// Absolute path
4217 4217
 		if ($path[0] === $separator || strpos($path, $systemroot) === 0) {
4218 4218
 			return $path;
4219 4219
 		}
4220 4220
 		
4221
-		$preg_separator = '#' . $sepquoted . '#';
4221
+		$preg_separator = '#'.$sepquoted.'#';
4222 4222
 		
4223 4223
 		// Relative path from 'Here'
4224
-		if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) {
4224
+		if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) {
4225 4225
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4226 4226
 			if ($arrn[0] !== '.') {
4227 4227
 				array_unshift($arrn, '.');
@@ -4235,12 +4235,11 @@  discard block
 block discarded – undo
4235 4235
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4236 4236
 			$arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY);
4237 4237
 		
4238
-			while (! empty($arrn) && $arrn[0] === '..') {
4238
+			while (!empty($arrn) && $arrn[0] === '..') {
4239 4239
 				array_shift($arrn);
4240 4240
 				array_pop($arrp);
4241 4241
 			}
4242
-			$path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) :
4243
-				(! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot);
4242
+			$path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot);
4244 4243
 		}
4245 4244
 		
4246 4245
 		return $path;
@@ -4258,7 +4257,7 @@  discard block
 block discarded – undo
4258 4257
 			@chmod($dir, 0777);
4259 4258
 			foreach (array_diff(scandir($dir), array('.', '..')) as $file) {
4260 4259
 				@set_time_limit(30);
4261
-				$path = $dir . DIRECTORY_SEPARATOR . $file;
4260
+				$path = $dir.DIRECTORY_SEPARATOR.$file;
4262 4261
 				if (!is_link($dir) && is_dir($path)) {
4263 4262
 					$this->rmdirRecursive($path);
4264 4263
 				} else {
@@ -4345,22 +4344,22 @@  discard block
 block discarded – undo
4345 4344
 		try {
4346 4345
 			if ($start = is_string($zipPath)) {
4347 4346
 				$zip = new ZipArchive();
4348
-				if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) {
4347
+				if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) {
4349 4348
 					$zip = false;
4350 4349
 				}
4351 4350
 			} else {
4352 4351
 				$zip = $zipPath;
4353 4352
 			}
4354 4353
 			if ($zip) {
4355
-				foreach($files as $file) {
4356
-					$path = $dir . DIRECTORY_SEPARATOR . $file;
4354
+				foreach ($files as $file) {
4355
+					$path = $dir.DIRECTORY_SEPARATOR.$file;
4357 4356
 					if (is_dir($path)) {
4358 4357
 						$zip->addEmptyDir($file);
4359 4358
 						$_files = array();
4360 4359
 						if ($handle = opendir($path)) {
4361 4360
 							while (false !== ($entry = readdir($handle))) {
4362 4361
 								if ($entry !== "." && $entry !== "..") {
4363
-									$_files[] = $file . DIRECTORY_SEPARATOR . $entry;
4362
+									$_files[] = $file.DIRECTORY_SEPARATOR.$entry;
4364 4363
 								}
4365 4364
 							}
4366 4365
 							closedir($handle);
@@ -4545,7 +4544,7 @@  discard block
 block discarded – undo
4545 4544
 	 * @return resource|false
4546 4545
 	 * @author Dmitry (dio) Levashov
4547 4546
 	 **/
4548
-	abstract protected function _fopen($path, $mode="rb");
4547
+	abstract protected function _fopen($path, $mode = "rb");
4549 4548
 	
4550 4549
 	/**
4551 4550
 	 * Close opened file
@@ -4555,7 +4554,7 @@  discard block
 block discarded – undo
4555 4554
 	 * @return bool
4556 4555
 	 * @author Dmitry (dio) Levashov
4557 4556
 	 **/
4558
-	abstract protected function _fclose($fp, $path='');
4557
+	abstract protected function _fclose($fp, $path = '');
4559 4558
 	
4560 4559
 	/********************  file/dir manipulations *************************/
4561 4560
 	
Please login to merge, or discard this patch.
php/elFinderVolumeDropbox.class.php 1 patch
Spacing   +62 added lines, -63 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		
138 138
 		if ($options['user'] === 'init') {
139 139
 
140
-			if (! $this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO')) {
140
+			if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO')) {
141 141
 				return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}');
142 142
 			}
143 143
 			
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 				if (class_exists('OAuth')) {
148 148
 					$this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']);
149 149
 				} else {
150
-					if (! class_exists('HTTP_OAuth_Consumer')) {
150
+					if (!class_exists('HTTP_OAuth_Consumer')) {
151 151
 						// We're going to try to load in manually
152 152
 						include 'HTTP/OAuth/Consumer.php';
153 153
 					}
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 				}
158 158
 			}
159 159
 			
160
-			if (! $this->oauth) {
160
+			if (!$this->oauth) {
161 161
 				return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}');
162 162
 			}
163 163
 
@@ -178,24 +178,24 @@  discard block
 block discarded – undo
178 178
 						unset($_SESSION['elFinderDropboxTokens']);
179 179
 					}
180 180
 				}
181
-				if (! $html) {
181
+				if (!$html) {
182 182
 					// get customdata
183 183
 					$cdata = '';
184 184
 					$innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user');
185
-					foreach($this->ARGS as $k => $v) {
186
-						if (! in_array($k, $innerKeys)) {
187
-							$cdata .= '&' . $k . '=' . rawurlencode($v);
185
+					foreach ($this->ARGS as $k => $v) {
186
+						if (!in_array($k, $innerKeys)) {
187
+							$cdata .= '&'.$k.'='.rawurlencode($v);
188 188
 						}
189 189
 					}
190
-					if (strpos($options['url'], 'http') !== 0 ) {
190
+					if (strpos($options['url'], 'http') !== 0) {
191 191
 						$options['url'] = $this->getConnectorUrl();
192 192
 					}
193
-					$callback  = $options['url']
193
+					$callback = $options['url']
194 194
 					           . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata;
195 195
 					
196 196
 					try {
197 197
 						$tokens = $this->oauth->getRequestToken();
198
-						$url= $this->oauth->getAuthorizeUrl(rawurlencode($callback));
198
+						$url = $this->oauth->getAuthorizeUrl(rawurlencode($callback));
199 199
 					} catch (Dropbox_Exception $e) {
200 200
 						return array('exit' => true, 'body' => '{msg:errAccess}');
201 201
 					}
@@ -242,14 +242,14 @@  discard block
 block discarded – undo
242 242
 		if (isset($netVolumes[$key])) {
243 243
 			$dropboxUid = $netVolumes[$key]['dropboxUid'];
244 244
 		}
245
-		foreach($netVolumes as $volume) {
245
+		foreach ($netVolumes as $volume) {
246 246
 			if (@$volume['host'] === 'dropbox' && @$volume['dropboxUid'] === $dropboxUid) {
247 247
 				$count++;
248 248
 			}
249 249
 		}
250 250
 		if ($count === 1) {
251 251
 			$this->DB->exec('drop table '.$this->DB_TableName);
252
-			foreach(glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) {
252
+			foreach (glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) {
253 253
 				unlink($tmb);
254 254
 			}
255 255
 		}
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 	 * @author Naoki Sawada
264 264
 	 */
265 265
 	private function getConnectorUrl() {
266
-		$url  = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://')
266
+		$url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://')
267 267
 		       . $_SERVER['SERVER_NAME']                                              // host
268
-		      . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT'])  // port
269
-		       . $_SERVER['REQUEST_URI'];                                             // path & query
268
+		      . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT'])  // port
269
+		       . $_SERVER['REQUEST_URI']; // path & query
270 270
 		list($url) = explode('?', $url);
271 271
 		return $url;
272 272
 	}
@@ -302,14 +302,14 @@  discard block
 block discarded – undo
302 302
 		// make net mount key
303 303
 		$this->netMountKey = md5(join('-', array('dropbox', $this->options['path'])));
304 304
 
305
-		if (! $this->oauth) {
305
+		if (!$this->oauth) {
306 306
 			if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) {
307 307
 				$this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']);
308 308
 			} else {
309 309
 				if (class_exists('OAuth')) {
310 310
 					$this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']);
311 311
 				} else {
312
-					if (! class_exists('HTTP_OAuth_Consumer')) {
312
+					if (!class_exists('HTTP_OAuth_Consumer')) {
313 313
 						// We're going to try to load in manually
314 314
 						include 'HTTP/OAuth/Consumer.php';
315 315
 					}
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 			}
321 321
 		}
322 322
 		
323
-		if (! $this->oauth) {
323
+		if (!$this->oauth) {
324 324
 			return $this->setError('OAuth extension not loaded.');
325 325
 		}
326 326
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		$this->root = $this->options['path'] = $this->_normpath($this->options['path']);
329 329
 
330 330
 		if (empty($this->options['alias'])) {
331
-			$this->options['alias'] = ($this->options['path'] === '/')? 'Dropbox.com'  : 'Dropbox'.$this->options['path'];
331
+			$this->options['alias'] = ($this->options['path'] === '/') ? 'Dropbox.com' : 'Dropbox'.$this->options['path'];
332 332
 		}
333 333
 
334 334
 		$this->rootName = $this->options['alias'];
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		}
385 385
 		
386 386
 		// setup PDO
387
-		if (! $this->options['PDO_DSN']) {
387
+		if (!$this->options['PDO_DSN']) {
388 388
 			$this->options['PDO_DSN'] = 'sqlite:'.$this->metaCache.DIRECTORY_SEPARATOR.'.elFinder_dropbox_db_'.md5($this->dropboxUid.$this->options['consumerSecret']);
389 389
 		}
390 390
 		// DataBase table name
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 		// DataBase check or make table
393 393
 		try {
394 394
 			$this->DB = new PDO($this->options['PDO_DSN'], $this->options['PDO_User'], $this->options['PDO_Pass'], $this->options['PDO_Options']);
395
-			if (! $this->checkDB()) {
395
+			if (!$this->checkDB()) {
396 396
 				return $this->setError('Can not make DB table');
397 397
 			}
398 398
 		} catch (PDOException $e) {
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 				$res = false;
444 444
 			}
445 445
 		}
446
-		if (! $res) {
446
+		if (!$res) {
447 447
 			try {
448 448
 				$this->DB->exec('CREATE TABLE '.$this->DB_TableName.'(path text, fname text, dat blob, isdir integer);');
449 449
 				$this->DB->exec('CREATE UNIQUE INDEX nameidx ON '.$this->DB_TableName.'(path, fname)');
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 	 */
494 494
 	private function updateDBdat($path, $dat) {
495 495
 		return $this->query('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($dat))
496
-				. ', isdir=' . ($dat['is_dir']? 1 : 0)
496
+				. ', isdir='.($dat['is_dir'] ? 1 : 0)
497 497
 				. ' where path='.$this->DB->quote(strtolower(dirname($path))).' and fname='.$this->DB->quote(strtolower(basename($path))));
498 498
 	}
499 499
 	/*********************************************************************/
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 	 */
519 519
 	protected function deltaCheck($refresh = true) {
520 520
 		$chk = false;
521
-		if (! $refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) {
521
+		if (!$refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) {
522 522
 			$chk = unserialize($chk[0]);
523 523
 		}
524 524
 		if ($chk && ($chk['mtime'] + $this->options['metaCacheTime']) > $_SERVER['REQUEST_TIME']) {
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 			do {
541 541
 				@ ini_set('max_execution_time', 120);
542 542
 				$_info = $this->dropbox->delta($cursor);
543
-				if (! empty($_info['reset'])) {
543
+				if (!empty($_info['reset'])) {
544 544
 					$this->DB->exec('TRUNCATE table '.$this->DB_TableName);
545 545
 					$this->DB->exec('insert into '.$this->DB_TableName.' values(\'\', \'\', \''.serialize(array('cursor' => '', 'mtime' => 0)).'\', 0);');
546 546
 					$this->DB->exec('insert into '.$this->DB_TableName.' values(\'/\', \'\', \''.serialize(array(
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 				}
554 554
 				$cursor = $_info['cursor'];
555 555
 				
556
-				foreach($_info['entries'] as $entry) {
556
+				foreach ($_info['entries'] as $entry) {
557 557
 					$key = strtolower($entry[0]);
558 558
 					$pkey = strtolower(dirname($key));
559 559
 					
@@ -563,27 +563,27 @@  discard block
 block discarded – undo
563 563
 					
564 564
 					if (empty($entry[1])) {
565 565
 						$this->DB->exec('delete from '.$this->DB_TableName.' '.$where);
566
-						! $delete && $delete = true;
566
+						!$delete && $delete = true;
567 567
 						continue;
568 568
 					}
569 569
 
570 570
 					$sql = 'select path from '.$this->DB_TableName.' '.$where.' limit 1';
571
-					if (! $reset && $this->query($sql)) {
572
-						$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir']? 1 : 0).' ' .$where);
571
+					if (!$reset && $this->query($sql)) {
572
+						$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir'] ? 1 : 0).' '.$where);
573 573
 					} else {
574
-						$this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int)$entry[1]['is_dir'].')');
574
+						$this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int) $entry[1]['is_dir'].')');
575 575
 					}
576 576
 				}
577
-			} while (! empty($_info['has_more']));
577
+			} while (!empty($_info['has_more']));
578 578
 			$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize(array('cursor'=>$cursor, 'mtime'=>$_SERVER['REQUEST_TIME']))).' where path=\'\' and fname=\'\'');
579
-			if (! $this->DB->commit()) {
579
+			if (!$this->DB->commit()) {
580 580
 				$e = $this->DB->errorInfo();
581 581
 				return $e[2];
582 582
 			}
583 583
 			if ($delete) {
584 584
 				$this->DB->exec('vacuum');
585 585
 			}
586
-		} catch(Dropbox_Exception $e) {
586
+		} catch (Dropbox_Exception $e) {
587 587
 			return $e->getMessage();
588 588
 		}
589 589
 		return true;
@@ -599,15 +599,14 @@  discard block
 block discarded – undo
599 599
 	protected function parseRaw($raw) {
600 600
 		$stat = array();
601 601
 
602
-		$stat['rev']   = isset($raw['rev'])? $raw['rev'] : 'root';
602
+		$stat['rev']   = isset($raw['rev']) ? $raw['rev'] : 'root';
603 603
 		$stat['name']  = basename($raw['path']);
604
-		$stat['mime']  = $raw['is_dir']? 'directory' : $raw['mime_type'];
604
+		$stat['mime']  = $raw['is_dir'] ? 'directory' : $raw['mime_type'];
605 605
 		$stat['size']  = $stat['mime'] == 'directory' ? 0 : $raw['bytes'];
606
-		$stat['ts']    = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) :
607
-		                (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']);
606
+		$stat['ts']    = isset($raw['client_mtime']) ? strtotime($raw['client_mtime']) : (isset($raw['modified']) ? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']);
608 607
 		$stat['dirs'] = 0;
609 608
 		if ($raw['is_dir']) {
610
-			$stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path'])));
609
+			$stat['dirs'] = (int) (bool) $this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path'])));
611 610
 		}
612 611
 		
613 612
 		if (!empty($raw['url'])) {
@@ -633,7 +632,7 @@  discard block
 block discarded – undo
633 632
 		$res = $this->query('select dat from '.$this->DB_TableName.' where path='.$this->DB->quote(strtolower($path)));
634 633
 		
635 634
 		if ($res) {
636
-			foreach($res as $raw) {
635
+			foreach ($res as $raw) {
637 636
 				$raw = unserialize($raw);
638 637
 				if ($stat = $this->parseRaw($raw)) {
639 638
 					$stat = $this->updateCache($raw['path'], $stat);
@@ -658,10 +657,10 @@  discard block
 block discarded – undo
658 657
 	protected function doSearch($path, $q, $mimes) {
659 658
 		$result = array();
660 659
 		$sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?');
661
-		$sth->execute(array('%'.(($path === '/')? '' : strtolower($path)), '%'.strtolower($q).'%'));
660
+		$sth->execute(array('%'.(($path === '/') ? '' : strtolower($path)), '%'.strtolower($q).'%'));
662 661
 		$res = $sth->fetchAll(PDO::FETCH_COLUMN);
663 662
 		if ($res) {
664
-			foreach($res as $raw) {
663
+			foreach ($res as $raw) {
665 664
 				$raw = unserialize($raw);
666 665
 				if ($stat = $this->parseRaw($raw)) {
667 666
 					if (!isset($this->cache[$raw['path']])) {
@@ -752,10 +751,10 @@  discard block
 block discarded – undo
752 751
 		$tmb  = $this->tmbPath.DIRECTORY_SEPARATOR.$name;
753 752
 	
754 753
 		// copy image into tmbPath so some drivers does not store files on local fs
755
-		if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) {
754
+		if (!$data = $this->getThumbnail($path, $this->options['getTmbSize'])) {
756 755
 			return false;
757 756
 		}
758
-		if (! file_put_contents($tmb, $data)) {
757
+		if (!file_put_contents($tmb, $data)) {
759 758
 			return false;
760 759
 		}
761 760
 	
@@ -768,15 +767,15 @@  discard block
 block discarded – undo
768 767
 		}
769 768
 	
770 769
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
771
-		if ($s[0] <= $tmbSize && $s[1]  <= $tmbSize) {
772
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
770
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
771
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
773 772
 	
774 773
 		} else {
775 774
 	
776 775
 			if ($this->options['tmbCrop']) {
777 776
 	
778 777
 				/* Resize and crop if image bigger than thumbnail */
779
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
778
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
780 779
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
781 780
 				}
782 781
 	
@@ -790,7 +789,7 @@  discard block
 block discarded – undo
790 789
 				$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png');
791 790
 			}
792 791
 		
793
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
792
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
794 793
 		}
795 794
 		
796 795
 		if (!$result) {
@@ -847,7 +846,7 @@  discard block
 block discarded – undo
847 846
 					}
848 847
 				}
849 848
 			}
850
-			if (! $url) {
849
+			if (!$url) {
851 850
 				try {
852 851
 					$res = $this->dropbox->share($path, null, false);
853 852
 					$url = $res['url'];
@@ -859,7 +858,7 @@  discard block
 block discarded – undo
859 858
 					}
860 859
 					list($url) = explode('?', $url);
861 860
 					$url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url);
862
-					if (! isset($cache['share']) || $cache['share'] !== $url) {
861
+					if (!isset($cache['share']) || $cache['share'] !== $url) {
863 862
 						$cache['share'] = $url;
864 863
 						$this->updateDBdat($path, $cache);
865 864
 					}
@@ -883,12 +882,12 @@  discard block
 block discarded – undo
883 882
 		if (function_exists('curl_exec')) {
884 883
 
885 884
 			$c = curl_init();
886
-			curl_setopt( $c, CURLOPT_RETURNTRANSFER, true );
887
-			curl_setopt( $c, CURLOPT_CUSTOMREQUEST, 'HEAD' );
888
-			curl_setopt( $c, CURLOPT_HEADER, 1 );
889
-			curl_setopt( $c, CURLOPT_NOBODY, true );
890
-			curl_setopt( $c, CURLOPT_URL, $url );
891
-			$res = curl_exec( $c );
885
+			curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
886
+			curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD');
887
+			curl_setopt($c, CURLOPT_HEADER, 1);
888
+			curl_setopt($c, CURLOPT_NOBODY, true);
889
+			curl_setopt($c, CURLOPT_URL, $url);
890
+			$res = curl_exec($c);
892 891
 			
893 892
 		} else {
894 893
 			
@@ -904,13 +903,13 @@  discard block
 block discarded – undo
904 903
 				$result = $request2->send();
905 904
 				$res = array();
906 905
 				$res[] = 'HTTP/'.$result->getVersion().' '.$result->getStatus().' '.$result->getReasonPhrase();
907
-				foreach($result->getHeader() as $key => $val) {
908
-					$res[] = $key . ': ' . $val;
906
+				foreach ($result->getHeader() as $key => $val) {
907
+					$res[] = $key.': '.$val;
909 908
 				}
910 909
 				$res = join("\r\n", $res);
911
-			} catch( HTTP_Request2_Exception $e ){
910
+			} catch (HTTP_Request2_Exception $e) {
912 911
 				$res = '';
913
-			} catch (Exception $e){
912
+			} catch (Exception $e) {
914 913
 				$res = '';
915 914
 			}
916 915
 		
@@ -963,7 +962,7 @@  discard block
 block discarded – undo
963 962
 	 **/
964 963
 	protected function _normpath($path) {
965 964
 		$path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
966
-		$path = '/' . ltrim($path, '/');
965
+		$path = '/'.ltrim($path, '/');
967 966
 		return $path;
968 967
 	}
969 968
 
@@ -1102,7 +1101,7 @@  discard block
 block discarded – undo
1102 1101
 	 * @return resource|false
1103 1102
 	 * @author Dmitry (dio) Levashov
1104 1103
 	 **/
1105
-	protected function _fopen($path, $mode='rb') {
1104
+	protected function _fopen($path, $mode = 'rb') {
1106 1105
 
1107 1106
 		if (($mode == 'rb' || $mode == 'r')) {
1108 1107
 			try {
@@ -1112,7 +1111,7 @@  discard block
 block discarded – undo
1112 1111
  				fputs($fp, "GET {$url['path']} HTTP/1.0\r\n");
1113 1112
  				fputs($fp, "Host: {$url['host']}\r\n");
1114 1113
  				fputs($fp, "\r\n");
1115
- 				while(trim(fgets($fp)) !== ''){};
1114
+ 				while (trim(fgets($fp)) !== '') {};
1116 1115
  				return $fp;
1117 1116
 			} catch (Dropbox_Exception $e) {
1118 1117
 				return false;
@@ -1143,7 +1142,7 @@  discard block
 block discarded – undo
1143 1142
 	 * @return bool
1144 1143
 	 * @author Dmitry (dio) Levashov
1145 1144
 	 **/
1146
-	protected function _fclose($fp, $path='') {
1145
+	protected function _fclose($fp, $path = '') {
1147 1146
 		@fclose($fp);
1148 1147
 		if ($path) {
1149 1148
 			@unlink($this->getTempFile($path));
Please login to merge, or discard this patch.