Completed
Push — 2.x ( 03af2a...1b6e15 )
by Naoki
07:15
created
php/elFinder.class.php 1 patch
Spacing   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -203,14 +203,14 @@  discard block
 block discarded – undo
203 203
 	const ERROR_INV_PARAMS        = 'errCmdParams';
204 204
 	const ERROR_OPEN              = 'errOpen';
205 205
 	const ERROR_DIR_NOT_FOUND     = 'errFolderNotFound';
206
-	const ERROR_FILE_NOT_FOUND    = 'errFileNotFound';     // 'File not found.'
206
+	const ERROR_FILE_NOT_FOUND    = 'errFileNotFound'; // 'File not found.'
207 207
 	const ERROR_TRGDIR_NOT_FOUND  = 'errTrgFolderNotFound'; // 'Target folder "$1" not found.'
208 208
 	const ERROR_NOT_DIR           = 'errNotFolder';
209 209
 	const ERROR_NOT_FILE          = 'errNotFile';
210 210
 	const ERROR_PERM_DENIED       = 'errPerm';
211
-	const ERROR_LOCKED            = 'errLocked';        // '"$1" is locked and can not be renamed, moved or removed.'
212
-	const ERROR_EXISTS            = 'errExists';        // 'File named "$1" already exists.'
213
-	const ERROR_INVALID_NAME      = 'errInvName';       // 'Invalid file name.'
211
+	const ERROR_LOCKED            = 'errLocked'; // '"$1" is locked and can not be renamed, moved or removed.'
212
+	const ERROR_EXISTS            = 'errExists'; // 'File named "$1" already exists.'
213
+	const ERROR_INVALID_NAME      = 'errInvName'; // 'Invalid file name.'
214 214
 	const ERROR_MKDIR             = 'errMkdir';
215 215
 	const ERROR_MKFILE            = 'errMkfile';
216 216
 	const ERROR_RENAME            = 'errRename';
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
 	const ERROR_COPY_FROM         = 'errCopyFrom';
220 220
 	const ERROR_COPY_TO           = 'errCopyTo';
221 221
 	const ERROR_COPY_ITSELF       = 'errCopyInItself';
222
-	const ERROR_REPLACE           = 'errReplace';          // 'Unable to replace "$1".'
223
-	const ERROR_RM                = 'errRm';               // 'Unable to remove "$1".'
224
-	const ERROR_RM_SRC            = 'errRmSrc';            // 'Unable remove source file(s)'
225
-	const ERROR_MKOUTLINK         = 'errMkOutLink';        // 'Unable to create a link to outside the volume root.'
226
-	const ERROR_UPLOAD            = 'errUpload';           // 'Upload error.'
227
-	const ERROR_UPLOAD_FILE       = 'errUploadFile';       // 'Unable to upload "$1".'
228
-	const ERROR_UPLOAD_NO_FILES   = 'errUploadNoFiles';    // 'No files found for upload.'
229
-	const ERROR_UPLOAD_TOTAL_SIZE = 'errUploadTotalSize';  // 'Data exceeds the maximum allowed size.'
230
-	const ERROR_UPLOAD_FILE_SIZE  = 'errUploadFileSize';   // 'File exceeds maximum allowed size.'
231
-	const ERROR_UPLOAD_FILE_MIME  = 'errUploadMime';       // 'File type not allowed.'
232
-	const ERROR_UPLOAD_TRANSFER   = 'errUploadTransfer';   // '"$1" transfer error.'
233
-	const ERROR_UPLOAD_TEMP       = 'errUploadTemp';       // 'Unable to make temporary file for upload.'
222
+	const ERROR_REPLACE           = 'errReplace'; // 'Unable to replace "$1".'
223
+	const ERROR_RM                = 'errRm'; // 'Unable to remove "$1".'
224
+	const ERROR_RM_SRC            = 'errRmSrc'; // 'Unable remove source file(s)'
225
+	const ERROR_MKOUTLINK         = 'errMkOutLink'; // 'Unable to create a link to outside the volume root.'
226
+	const ERROR_UPLOAD            = 'errUpload'; // 'Upload error.'
227
+	const ERROR_UPLOAD_FILE       = 'errUploadFile'; // 'Unable to upload "$1".'
228
+	const ERROR_UPLOAD_NO_FILES   = 'errUploadNoFiles'; // 'No files found for upload.'
229
+	const ERROR_UPLOAD_TOTAL_SIZE = 'errUploadTotalSize'; // 'Data exceeds the maximum allowed size.'
230
+	const ERROR_UPLOAD_FILE_SIZE  = 'errUploadFileSize'; // 'File exceeds maximum allowed size.'
231
+	const ERROR_UPLOAD_FILE_MIME  = 'errUploadMime'; // 'File type not allowed.'
232
+	const ERROR_UPLOAD_TRANSFER   = 'errUploadTransfer'; // '"$1" transfer error.'
233
+	const ERROR_UPLOAD_TEMP       = 'errUploadTemp'; // 'Unable to make temporary file for upload.'
234 234
 	// const ERROR_ACCESS_DENIED     = 'errAccess';
235
-	const ERROR_NOT_REPLACE       = 'errNotReplace';       // Object "$1" already exists at this location and can not be replaced with object of another type.
235
+	const ERROR_NOT_REPLACE       = 'errNotReplace'; // Object "$1" already exists at this location and can not be replaced with object of another type.
236 236
 	const ERROR_SAVE              = 'errSave';
237 237
 	const ERROR_EXTRACT           = 'errExtract';
238 238
 	const ERROR_ARCHIVE           = 'errArchive';
@@ -247,17 +247,17 @@  discard block
 block discarded – undo
247 247
 	const ERROR_NETMOUNT          = 'errNetMount';
248 248
 	const ERROR_NETUNMOUNT        = 'errNetUnMount';
249 249
 	const ERROR_NETMOUNT_NO_DRIVER = 'errNetMountNoDriver';
250
-	const ERROR_NETMOUNT_FAILED       = 'errNetMountFailed';
250
+	const ERROR_NETMOUNT_FAILED = 'errNetMountFailed';
251 251
 
252
-	const ERROR_SESSION_EXPIRES 	= 'errSessionExpires';
252
+	const ERROR_SESSION_EXPIRES = 'errSessionExpires';
253 253
 
254 254
 	const ERROR_CREATING_TEMP_DIR 	= 'errCreatingTempDir';
255 255
 	const ERROR_FTP_DOWNLOAD_FILE 	= 'errFtpDownloadFile';
256
-	const ERROR_FTP_UPLOAD_FILE 	= 'errFtpUploadFile';
257
-	const ERROR_FTP_MKDIR 		= 'errFtpMkdir';
256
+	const ERROR_FTP_UPLOAD_FILE = 'errFtpUploadFile';
257
+	const ERROR_FTP_MKDIR = 'errFtpMkdir';
258 258
 	const ERROR_ARCHIVE_EXEC 	= 'errArchiveExec';
259 259
 	const ERROR_EXTRACT_EXEC 	= 'errExtractExec';
260
-	const ERROR_SEARCH_TIMEOUT    = 'errSearchTimeout';    // 'Timed out while searching "$1". Search result is partial.'
260
+	const ERROR_SEARCH_TIMEOUT = 'errSearchTimeout'; // 'Timed out while searching "$1". Search result is partial.'
261 261
 
262 262
 	/**
263 263
 	 * Constructor
@@ -284,17 +284,17 @@  discard block
 block discarded – undo
284 284
 		
285 285
 		$this->time  = $this->utime();
286 286
 		$this->debug = (isset($opts['debug']) && $opts['debug'] ? true : false);
287
-		$this->sessionCloseEarlier = isset($opts['sessionCloseEarlier'])? (bool)$opts['sessionCloseEarlier'] : true;
287
+		$this->sessionCloseEarlier = isset($opts['sessionCloseEarlier']) ? (bool) $opts['sessionCloseEarlier'] : true;
288 288
 		$this->sessionUseCmds = array_flip($sessionUseCmds);
289 289
 		$this->timeout = (isset($opts['timeout']) ? $opts['timeout'] : 0);
290 290
 		$this->uploadTempPath = (isset($opts['uploadTempPath']) ? $opts['uploadTempPath'] : '');
291
-		$this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey'])? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
291
+		$this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey']) ? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
292 292
 		$this->callbackWindowURL = (isset($opts['callbackWindowURL']) ? $opts['callbackWindowURL'] : '');
293 293
 		self::$sessionCacheKey = !empty($opts['sessionCacheKey']) ? $opts['sessionCacheKey'] : 'elFinderCaches';
294 294
 		
295 295
 		// check session cache
296 296
 		$_optsMD5 = md5(json_encode($opts['roots']));
297
-		if (! isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) {
297
+		if (!isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) {
298 298
 			$_SESSION[self::$sessionCacheKey] = array(
299 299
 				'_optsMD5' => $_optsMD5
300 300
 			);
@@ -313,20 +313,20 @@  discard block
 block discarded – undo
313 313
 			$_reqCmd = isset($_req['cmd']) ? $_req['cmd'] : '';
314 314
 			foreach ($opts['bind'] as $cmd => $handlers) {
315 315
 				$doRegist = (strpos($cmd, '*') !== false);
316
-				if (! $doRegist) {
316
+				if (!$doRegist) {
317 317
 					$_getcmd = create_function('$cmd', 'list($ret) = explode(\'.\', $cmd);return trim($ret);');
318 318
 					$doRegist = ($_reqCmd && in_array($_reqCmd, array_map($_getcmd, explode(' ', $cmd))));
319 319
 				}
320 320
 				if ($doRegist) {
321
-					if (! is_array($handlers) || is_object($handlers[0])) {
321
+					if (!is_array($handlers) || is_object($handlers[0])) {
322 322
 						$handlers = array($handlers);
323 323
 					}
324
-					foreach($handlers as $handler) {
324
+					foreach ($handlers as $handler) {
325 325
 						if ($handler) {
326 326
 							if (is_string($handler) && strpos($handler, '.')) {
327 327
 								list($_domain, $_name, $_method) = array_pad(explode('.', $handler), 3, '');
328 328
 								if (strcasecmp($_domain, 'plugin') === 0) {
329
-									if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name])? $opts['plugin'][$_name] : array())
329
+									if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name]) ? $opts['plugin'][$_name] : array())
330 330
 											and method_exists($plugin, $_method)) {
331 331
 										$this->bind($cmd, array($plugin, $_method));
332 332
 									}
@@ -413,13 +413,13 @@  discard block
 block discarded – undo
413 413
 	public function bind($cmd, $handler) {
414 414
 		$allCmds = array_keys($this->commands);
415 415
 		$cmds = array();
416
-		foreach(explode(' ', $cmd) as $_cmd) {
416
+		foreach (explode(' ', $cmd) as $_cmd) {
417 417
 			if ($_cmd !== '') {
418 418
 				if ($all = strpos($_cmd, '*') !== false) {
419 419
 					list(, $sub) = array_pad(explode('.', $_cmd), 2, '');
420 420
 					if ($sub) {
421 421
 						$sub = str_replace('\'', '\\\'', $sub);
422
-						$addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\'' . $sub . '\');');
422
+						$addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\''.$sub.'\');');
423 423
 						$cmds = array_merge($cmds, array_map($addSub, $allCmds));
424 424
 					} else {
425 425
 						$cmds = array_merge($cmds, $allCmds);
@@ -499,16 +499,16 @@  discard block
 block discarded – undo
499 499
 
500 500
 	private function session_expires() {
501 501
 		
502
-		if (!isset($_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'])) {
503
-			$_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time();
502
+		if (!isset($_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'])) {
503
+			$_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time();
504 504
 			return false;
505 505
 		}
506 506
 
507
-		if ( ($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] > $this->timeout) ) {
507
+		if (($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] > $this->timeout)) {
508 508
 			return true;
509 509
 		}
510 510
 
511
-		$_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time();
511
+		$_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time();
512 512
 		return false;	
513 513
 	}
514 514
 	
@@ -541,9 +541,9 @@  discard block
 block discarded – undo
541 541
 		}
542 542
 
543 543
 		// call pre handlers for this command
544
-		$args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd])? false : $this->sessionCloseEarlier;
544
+		$args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd]) ? false : $this->sessionCloseEarlier;
545 545
 		if (!empty($this->listeners[$cmd.'.pre'])) {
546
-			$volume = isset($args['target'])? $this->volume($args['target']) : false;
546
+			$volume = isset($args['target']) ? $this->volume($args['target']) : false;
547 547
 			foreach ($this->listeners[$cmd.'.pre'] as $handler) {
548 548
 				call_user_func_array($handler, array($cmd, &$args, $this, $volume));
549 549
 			}
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 		// unlock session data for multiple access
553 553
 		$this->sessionCloseEarlier && $args['sessionCloseEarlier'] && session_id() && session_write_close();
554 554
 		
555
-		if (substr(PHP_OS,0,3) === 'WIN') {
555
+		if (substr(PHP_OS, 0, 3) === 'WIN') {
556 556
 			// set time out
557 557
 			if (($_max_execution_time = ini_get('max_execution_time')) && $_max_execution_time < 300) {
558 558
 				@set_time_limit(300);
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 		// call handlers for this command
572 572
 		if (!empty($this->listeners[$cmd])) {
573 573
 			foreach ($this->listeners[$cmd] as $handler) {
574
-				if (call_user_func_array($handler,array($cmd,&$result,$args,$this))) {
574
+				if (call_user_func_array($handler, array($cmd, &$result, $args, $this))) {
575 575
 					// handler return true to force sync client after command completed
576 576
 					$result['sync'] = true;
577 577
 				}
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 	 * @return string
631 631
 	 * @author Dmitry (dio) Levashov
632 632
 	 **/
633
-	public function realpath($hash)	{
633
+	public function realpath($hash) {
634 634
 		if (($volume = $this->volume($hash)) == false) {
635 635
 			return false;
636 636
 		}
@@ -686,11 +686,11 @@  discard block
 block discarded – undo
686 686
 	 */
687 687
 	protected function getPluginInstance($name, $opts = array()) {
688 688
 		$key = strtolower($name);
689
-		if (! isset($this->plugins[$key])) {
690
-			$p_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'plugin.php';
689
+		if (!isset($this->plugins[$key])) {
690
+			$p_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.'plugin.php';
691 691
 			if (is_file($p_file)) {
692 692
 				require_once $p_file;
693
-				$class = 'elFinderPlugin' . $name;
693
+				$class = 'elFinderPlugin'.$name;
694 694
 				$this->plugins[$key] = new $class($opts);
695 695
 			} else {
696 696
 				$this->plugins[$key] = false;
@@ -787,8 +787,8 @@  discard block
 block discarded – undo
787 787
 		
788 788
 		$netVolumes = $this->getNetVolumes();
789 789
 		if ($volume->mount($options)) {
790
-			if (! $key = @ $volume->netMountKey) {
791
-				$key = md5($protocol . '-' . join('-', $options));
790
+			if (!$key = @ $volume->netMountKey) {
791
+				$key = md5($protocol.'-'.join('-', $options));
792 792
 			}
793 793
 			$options['driver'] = $driver;
794 794
 			$options['netkey'] = $key;
@@ -857,14 +857,14 @@  discard block
 block discarded – undo
857 857
 		}
858 858
 		// long polling mode
859 859
 		if ($args['compare']) {
860
-			$sleep = max(1, (int)$volume->getOption('lsPlSleep'));
861
-			$limit = max(1, (int)$volume->getOption('plStandby') / $sleep) + 1;
860
+			$sleep = max(1, (int) $volume->getOption('lsPlSleep'));
861
+			$limit = max(1, (int) $volume->getOption('plStandby')/$sleep) + 1;
862 862
 			$timelimit = ini_get('max_execution_time');
863 863
 			$compare = $args['compare'];
864 864
 			do {
865 865
 				$timelimit && @ set_time_limit($timelimit + $sleep);
866 866
 				$_mtime = 0;
867
-				foreach($ls as $_f) {
867
+				foreach ($ls as $_f) {
868 868
 					$_mtime = max($_mtime, $_f['ts']);
869 869
 				}
870 870
 				$compare = strval(count($ls)).':'.strval($_mtime);
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 						break;
879 879
 					}
880 880
 				}
881
-			} while($limit);
881
+			} while ($limit);
882 882
 			if ($ls === false) {
883 883
 				return array('error' => $this->error(self::ERROR_OPEN, $cwd['name'], $volume->error()));
884 884
 			}
@@ -1021,24 +1021,24 @@  discard block
 block discarded – undo
1021 1021
 		}
1022 1022
 
1023 1023
 		// allow change MIME type by 'file.pre' callback functions
1024
-		$mime = isset($args['mime'])? $args['mime'] : $file['mime'];
1024
+		$mime = isset($args['mime']) ? $args['mime'] : $file['mime'];
1025 1025
 		if ($download) {
1026 1026
 			$disp = 'attachment';
1027 1027
 		} else {
1028 1028
 			$dispInlineRegex = $volume->getOption('dispInlineRegex');
1029 1029
 			$inlineRegex = false;
1030 1030
 			if ($dispInlineRegex) {
1031
-				$inlineRegex = '#' . str_replace('#', '\\#', $dispInlineRegex) . '#';
1031
+				$inlineRegex = '#'.str_replace('#', '\\#', $dispInlineRegex).'#';
1032 1032
 				try {
1033 1033
 					preg_match($inlineRegex, '');
1034
-				} catch(Exception $e) {
1034
+				} catch (Exception $e) {
1035 1035
 					$inlineRegex = false;
1036 1036
 				}
1037 1037
 			}
1038 1038
 			if (!$inlineRegex) {
1039 1039
 				$inlineRegex = '#^(?:(?:image|text)|application/x-shockwave-flash$)#';
1040 1040
 			}
1041
-			$disp  = preg_match($inlineRegex, $mime)? 'inline' : 'attachment';
1041
+			$disp = preg_match($inlineRegex, $mime) ? 'inline' : 'attachment';
1042 1042
 		}
1043 1043
 		
1044 1044
 		$filenameEncoded = rawurlencode($file['name']);
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 		$name   = $args['name'];
1148 1148
 		
1149 1149
 		if (($volume = $this->volume($target)) == false
1150
-		||  ($rm  = $volume->file($target)) == false) {
1150
+		||  ($rm = $volume->file($target)) == false) {
1151 1151
 			return array('error' => $this->error(self::ERROR_RENAME, '#'.$target, self::ERROR_FILE_NOT_FOUND));
1152 1152
 		}
1153 1153
 		$rm['realpath'] = $volume->realpath($target);
@@ -1225,9 +1225,9 @@  discard block
 block discarded – undo
1225 1225
 	* @retval false  error
1226 1226
 	* @author Naoki Sawada
1227 1227
 	**/
1228
-	protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) {
1229
-		$method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; 
1230
-		return $this->$method( $url, $timeout, $redirect_max, $ua, $fp );
1228
+	protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) {
1229
+		$method = (function_exists('curl_exec') && !ini_get('safe_mode')) ? 'curl_get_contents' : 'fsock_get_contents'; 
1230
+		return $this->$method($url, $timeout, $redirect_max, $ua, $fp);
1231 1231
 	}
1232 1232
 	
1233 1233
 	/**
@@ -1243,26 +1243,26 @@  discard block
 block discarded – undo
1243 1243
 	 * @retval false  error
1244 1244
 	 * @author Naoki Sawada
1245 1245
 	 **/
1246
-	 protected function curl_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ){
1246
+	 protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1247 1247
 		$ch = curl_init();
1248
-		curl_setopt( $ch, CURLOPT_URL, $url );
1249
-		curl_setopt( $ch, CURLOPT_HEADER, false );
1248
+		curl_setopt($ch, CURLOPT_URL, $url);
1249
+		curl_setopt($ch, CURLOPT_HEADER, false);
1250 1250
 		if ($outfp) {
1251
-			curl_setopt( $ch, CURLOPT_FILE, $outfp );
1251
+			curl_setopt($ch, CURLOPT_FILE, $outfp);
1252 1252
 		} else {
1253
-			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
1254
-			curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true );
1255
-		}
1256
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 );
1257
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_TIME, $timeout );
1258
-		curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
1259
-		curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
1260
-		curl_setopt( $ch, CURLOPT_MAXREDIRS, $redirect_max);
1261
-		curl_setopt( $ch, CURLOPT_USERAGENT, $ua);
1262
-		$result = curl_exec( $ch );
1253
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1254
+			curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
1255
+		}
1256
+		curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1);
1257
+		curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout);
1258
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1259
+		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
1260
+		curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max);
1261
+		curl_setopt($ch, CURLOPT_USERAGENT, $ua);
1262
+		$result = curl_exec($ch);
1263 1263
 		$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
1264
-		curl_close( $ch );
1265
-		return $outfp? $outfp : $result;
1264
+		curl_close($ch);
1265
+		return $outfp ? $outfp : $result;
1266 1266
 	}
1267 1267
 	
1268 1268
 	/**
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 	 * @retval false  error
1279 1279
 	 * @author Naoki Sawada
1280 1280
 	 */
1281
-	protected function fsock_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ) {
1281
+	protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1282 1282
 
1283 1283
 		$connect_timeout = 3;
1284 1284
 		$connect_try = 3;
@@ -1289,7 +1289,7 @@  discard block
 block discarded – undo
1289 1289
 		$headers = '';
1290 1290
 		
1291 1291
 		$arr = parse_url($url);
1292
-		if (!$arr){
1292
+		if (!$arr) {
1293 1293
 			// Bad request
1294 1294
 			return false;
1295 1295
 		}
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 		// query
1298 1298
 		$arr['query'] = isset($arr['query']) ? '?'.$arr['query'] : '';
1299 1299
 		// port
1300
-		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https'])? 443 : 80);
1300
+		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https']) ? 443 : 80);
1301 1301
 		
1302 1302
 		$url_base = $arr['scheme'].'://'.$arr['host'].':'.$arr['port'];
1303 1303
 		$url_path = isset($arr['path']) ? $arr['path'] : '/';
@@ -1306,21 +1306,21 @@  discard block
 block discarded – undo
1306 1306
 		$query = $method.' '.$uri." HTTP/1.0\r\n";
1307 1307
 		$query .= "Host: ".$arr['host']."\r\n";
1308 1308
 		if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n";
1309
-		if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n";
1309
+		if (!is_null($getSize)) $query .= 'Range: bytes=0-'.($getSize - 1)."\r\n";
1310 1310
 		
1311 1311
 		$query .= $headers;
1312 1312
 
1313 1313
 		$query .= "\r\n";
1314 1314
 
1315 1315
 		$fp = $connect_try_count = 0;
1316
-		while( !$fp && $connect_try_count < $connect_try ) {
1316
+		while (!$fp && $connect_try_count < $connect_try) {
1317 1317
 	
1318 1318
 			$errno = 0;
1319 1319
 			$errstr = "";
1320 1320
 			$fp = @ fsockopen(
1321 1321
 			$arr['https'].$arr['host'],
1322 1322
 			$arr['port'],
1323
-			$errno,$errstr,$connect_timeout);
1323
+			$errno, $errstr, $connect_timeout);
1324 1324
 			if ($fp) break;
1325 1325
 			$connect_try_count++;
1326 1326
 			if (connection_aborted()) {
@@ -1345,13 +1345,13 @@  discard block
 block discarded – undo
1345 1345
 		
1346 1346
 		$_response = '';
1347 1347
 		$header = '';
1348
-		while($_response !== "\r\n"){
1348
+		while ($_response !== "\r\n") {
1349 1349
 			$_response = fgets($fp, $readsize);
1350 1350
 			$header .= $_response;
1351 1351
 		};
1352 1352
 		
1353
-		$rccd = array_pad(explode(' ',$header,3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1354
-		$rc = (int)$rccd[1];
1353
+		$rccd = array_pad(explode(' ', $header, 3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1354
+		$rc = (int) $rccd[1];
1355 1355
 		
1356 1356
 		// Redirect
1357 1357
 		switch ($rc) {
@@ -1360,19 +1360,19 @@  discard block
 block discarded – undo
1360 1360
 			case 302: // Moved Temporarily
1361 1361
 			case 301: // Moved Permanently
1362 1362
 				$matches = array();
1363
-				if (preg_match('/^Location: (.+?)(#.+)?$/im',$header,$matches) && --$redirect_max > 0) {
1363
+				if (preg_match('/^Location: (.+?)(#.+)?$/im', $header, $matches) && --$redirect_max > 0) {
1364 1364
 					$url = trim($matches[1]);
1365
-					$hash = isset($matches[2])? trim($matches[2]) : '';
1366
-					if (!preg_match('/^https?:\//',$url)) { // no scheme
1365
+					$hash = isset($matches[2]) ? trim($matches[2]) : '';
1366
+					if (!preg_match('/^https?:\//', $url)) { // no scheme
1367 1367
 						if ($url{0} != '/') { // Relative path
1368 1368
 							// to Absolute path
1369
-							$url = substr($url_path,0,strrpos($url_path,'/')).'/'.$url;
1369
+							$url = substr($url_path, 0, strrpos($url_path, '/')).'/'.$url;
1370 1370
 						}
1371 1371
 						// add sheme,host
1372 1372
 						$url = $url_base.$url;
1373 1373
 					}
1374 1374
 					fclose($fp);
1375
-					return $this->fsock_get_contents( $url, $timeout, $redirect_max, $ua, $outfp );
1375
+					return $this->fsock_get_contents($url, $timeout, $redirect_max, $ua, $outfp);
1376 1376
 				}
1377 1377
 		}
1378 1378
 		
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 			$outfp = fopen('php://temp', 'rwb');
1382 1382
 			$body = true;
1383 1383
 		}
1384
-		while(fwrite($outfp, fread($fp, $readsize))) {
1384
+		while (fwrite($outfp, fread($fp, $readsize))) {
1385 1385
 			if ($timeout) {
1386 1386
 				$_status = socket_get_status($fp);
1387 1387
 				if ($_status['timed_out']) {
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 		
1401 1401
 		fclose($fp);
1402 1402
 		
1403
-		return $outfp? $outfp : $body; // Data
1403
+		return $outfp ? $outfp : $body; // Data
1404 1404
 	}
1405 1405
 	
1406 1406
 	/**
@@ -1411,13 +1411,13 @@  discard block
 block discarded – undo
1411 1411
 	 * @return array
1412 1412
 	 * @author Naoki Sawada
1413 1413
 	 */
1414
-	protected function parse_data_scheme( $str, $extTable ) {
1414
+	protected function parse_data_scheme($str, $extTable) {
1415 1415
 		$data = $name = '';
1416 1416
 		if ($fp = fopen('data://'.substr($str, 5), 'rb')) {
1417 1417
 			if ($data = stream_get_contents($fp)) {
1418 1418
 				$meta = stream_get_meta_data($fp);
1419
-				$ext = isset($extTable[$meta['mediatype']])? '.' . $extTable[$meta['mediatype']] : '';
1420
-				$name = substr(md5($data), 0, 8) . $ext;
1419
+				$ext = isset($extTable[$meta['mediatype']]) ? '.'.$extTable[$meta['mediatype']] : '';
1420
+				$name = substr(md5($data), 0, 8).$ext;
1421 1421
 			}
1422 1422
 			fclose($fp);
1423 1423
 		}
@@ -1481,7 +1481,7 @@  discard block
 block discarded – undo
1481 1481
 			}
1482 1482
 		}
1483 1483
 		
1484
-		return ($mime && isset($extTable[$mime]))? ('.' . $extTable[$mime]) : '';
1484
+		return ($mime && isset($extTable[$mime])) ? ('.'.$extTable[$mime]) : '';
1485 1485
 	}
1486 1486
 	
1487 1487
 	/**
@@ -1503,12 +1503,12 @@  discard block
 block discarded – undo
1503 1503
 			$testDirs[] = sys_get_temp_dir();
1504 1504
 		}
1505 1505
 		$tempDir = '';
1506
-		foreach($testDirs as $testDir) {
1506
+		foreach ($testDirs as $testDir) {
1507 1507
 			if (!$testDir || !is_dir($testDir)) continue;
1508 1508
 			if (is_writable($testDir)) {
1509 1509
 				$tempDir = $testDir;
1510 1510
 				$gc = time() - 3600;
1511
-				foreach(glob($tempDir . DIRECTORY_SEPARATOR .'ELF*') as $cf) {
1511
+				foreach (glob($tempDir.DIRECTORY_SEPARATOR.'ELF*') as $cf) {
1512 1512
 					if (filemtime($cf) < $gc) {
1513 1513
 						@unlink($cf);
1514 1514
 					}
@@ -1528,7 +1528,7 @@  discard block
 block discarded – undo
1528 1528
 	 **/
1529 1529
 	protected function chmod($args) {
1530 1530
 		$targets = $args['targets'];
1531
-		$mode    = intval((string)$args['mode'], 8);
1531
+		$mode    = intval((string) $args['mode'], 8);
1532 1532
 
1533 1533
 		if (!is_array($targets)) {
1534 1534
 			$targets = array($targets);
@@ -1543,10 +1543,10 @@  discard block
 block discarded – undo
1543 1543
 
1544 1544
 		$files = array();
1545 1545
 		$errors = array();
1546
-		foreach($targets as $target) {
1546
+		foreach ($targets as $target) {
1547 1547
 			$file = $volume->chmod($target, $mode);
1548 1548
 			if ($file) {
1549
-				$files = array_merge($files, is_array($file)? $file : array($file));
1549
+				$files = array_merge($files, is_array($file) ? $file : array($file));
1550 1550
 			} else {
1551 1551
 				$errors = array_merge($errors, $volume->error());
1552 1552
 			}
@@ -1577,26 +1577,26 @@  discard block
 block discarded – undo
1577 1577
 	private function checkChunkedFile($tmpname, $chunk, $cid, $tempDir, $volume = null) {
1578 1578
 		if (preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m)) {
1579 1579
 			$fname = $m[1];
1580
-			$encname = md5($cid . '_' . $fname);
1581
-			$base = $tempDir . DIRECTORY_SEPARATOR . 'ELF' . $encname;
1580
+			$encname = md5($cid.'_'.$fname);
1581
+			$base = $tempDir.DIRECTORY_SEPARATOR.'ELF'.$encname;
1582 1582
 			$clast = intval($m[3]);
1583 1583
 			if (is_null($tmpname)) {
1584 1584
 				ignore_user_abort(true);
1585 1585
 				sleep(10); // wait 10 sec
1586 1586
 				// chunked file upload fail
1587
-				foreach(glob($base . '*') as $cf) {
1587
+				foreach (glob($base.'*') as $cf) {
1588 1588
 					@unlink($cf);
1589 1589
 				}
1590 1590
 				ignore_user_abort(false);
1591 1591
 				return;
1592 1592
 			}
1593 1593
 			
1594
-			$range = isset($_POST['range'])? trim($_POST['range']) : '';
1594
+			$range = isset($_POST['range']) ? trim($_POST['range']) : '';
1595 1595
 			if ($range && preg_match('/^(\d+),(\d+),(\d+)$/', $range, $ranges)) {
1596 1596
 				$start = $ranges[1];
1597 1597
 				$len   = $ranges[2];
1598 1598
 				$size  = $ranges[3];
1599
-				$tmp = $base . '.part';
1599
+				$tmp = $base.'.part';
1600 1600
 				$csize = filesize($tmpname);
1601 1601
 				
1602 1602
 				$tmpExists = is_file($tmp);
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
 				} else {
1623 1623
 					// wait until makeing temp file (for anothor session)
1624 1624
 					$cnt = 1200; // Time limit 120 sec
1625
-					while(!is_file($base) && --$cnt) {
1625
+					while (!is_file($base) && --$cnt) {
1626 1626
 						usleep(100000); // wait 100ms
1627 1627
 					}
1628 1628
 					if (!$cnt) {
@@ -1657,13 +1657,13 @@  discard block
 block discarded – undo
1657 1657
 				}
1658 1658
 			} else {
1659 1659
 				// old way
1660
-				$part = $base . $m[2];
1660
+				$part = $base.$m[2];
1661 1661
 				if (move_uploaded_file($tmpname, $part)) {
1662 1662
 					@chmod($part, 0600);
1663
-					if ($clast < count(glob($base . '*'))) {
1663
+					if ($clast < count(glob($base.'*'))) {
1664 1664
 						$parts = array();
1665 1665
 						for ($i = 0; $i <= $clast; $i++) {
1666
-							$name = $base . '.' . $i . '_' . $clast;
1666
+							$name = $base.'.'.$i.'_'.$clast;
1667 1667
 							if (is_readable($name)) {
1668 1668
 								$parts[] = $name;
1669 1669
 							} else {
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
 								touch($base);
1677 1677
 								if ($resfile = tempnam($tempDir, 'ELF')) {
1678 1678
 									$target = fopen($resfile, 'wb');
1679
-									foreach($parts as $f) {
1679
+									foreach ($parts as $f) {
1680 1680
 										$fp = fopen($f, 'rb');
1681 1681
 										while (!feof($fp)) {
1682 1682
 											fwrite($target, fread($fp, 8192));
@@ -1712,15 +1712,15 @@  discard block
 block discarded – undo
1712 1712
 		$files  = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array();
1713 1713
 		$header = empty($args['html']) ? array() : array('header' => 'Content-Type: text/html; charset=utf-8');
1714 1714
 		$result = array_merge(array('added' => array()), $header);
1715
-		$paths  = $args['upload_path']? $args['upload_path'] : array();
1716
-		$chunk  = $args['chunk']? $args['chunk'] : '';
1717
-		$cid    = $args['cid']? (int)$args['cid'] : '';
1715
+		$paths  = $args['upload_path'] ? $args['upload_path'] : array();
1716
+		$chunk  = $args['chunk'] ? $args['chunk'] : '';
1717
+		$cid    = $args['cid'] ? (int) $args['cid'] : '';
1718 1718
 		
1719
-		$renames= array();
1719
+		$renames = array();
1720 1720
 		$suffix = '~';
1721 1721
 		if ($args['renames'] && is_array($args['renames'])) {
1722 1722
 			$renames = array_flip($args['renames']);
1723
-			if (is_string($args['suffix']) && ! preg_match($ngReg, $args['suffix'])) {
1723
+			if (is_string($args['suffix']) && !preg_match($ngReg, $args['suffix'])) {
1724 1724
 				$suffix = $args['suffix'];
1725 1725
 			}
1726 1726
 		}
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 			if (!$args['upload'] && $args['name'] && is_array($args['name'])) {
1754 1754
 				$error = '';
1755 1755
 				$result['name'] = array();
1756
-				foreach($args['name'] as $_i => $_name) {
1756
+				foreach ($args['name'] as $_i => $_name) {
1757 1757
 					if (!$volume->isUploadableByName($_name)) {
1758 1758
 						$error = $this->error(self::ERROR_UPLOAD_FILE, $_name, self::ERROR_UPLOAD_FILE_MIME);
1759 1759
 						break;
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 			}
1775 1775
 			if (isset($args['upload']) && is_array($args['upload']) && ($tempDir = $this->getTempDir($volume->getTempPath()))) {
1776 1776
 				$names = array();
1777
-				foreach($args['upload'] as $i => $url) {
1777
+				foreach ($args['upload'] as $i => $url) {
1778 1778
 					// check chunked file upload commit
1779 1779
 					if ($args['chunk']) {
1780 1780
 						if ($url === 'chunkfail' && $args['mimes'] === 'chunkfail') {
@@ -1784,7 +1784,7 @@  discard block
 block discarded – undo
1784 1784
 							}
1785 1785
 							return $result;
1786 1786
 						} else {
1787
-							$tmpfname = $tempDir . '/' . $args['chunk'];
1787
+							$tmpfname = $tempDir.'/'.$args['chunk'];
1788 1788
 							$files['tmp_name'][$i] = $tmpfname;
1789 1789
 							$files['name'][$i] = $url;
1790 1790
 							$files['error'][$i] = 0;
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
 						}
1794 1794
 					}
1795 1795
 					
1796
-					$tmpfname = $tempDir . DIRECTORY_SEPARATOR . 'ELF_FATCH_' . md5($url.microtime(true));
1796
+					$tmpfname = $tempDir.DIRECTORY_SEPARATOR.'ELF_FATCH_'.md5($url.microtime(true));
1797 1797
 					
1798 1798
 					$_name = '';
1799 1799
 					// check is data:
@@ -1829,8 +1829,8 @@  discard block
 block discarded – undo
1829 1829
 								list($_a, $_b) = array_pad(explode('.', $_name, 2), 2, '');
1830 1830
 								if ($_b === '') {
1831 1831
 									if ($_ext) {
1832
-										rename($tmpfname, $tmpfname . $_ext);
1833
-										$tmpfname = $tmpfname . $_ext;
1832
+										rename($tmpfname, $tmpfname.$_ext);
1833
+										$tmpfname = $tmpfname.$_ext;
1834 1834
 									}
1835 1835
 									$_b = $this->detectFileExtension($tmpfname);
1836 1836
 									$_name = $_a.$_b;
@@ -1865,7 +1865,7 @@  discard block
 block discarded – undo
1865 1865
 			}
1866 1866
 			
1867 1867
 			$tmpname = $files['tmp_name'][$i];
1868
-			$path = ($paths && !empty($paths[$i]))? $paths[$i] : '';
1868
+			$path = ($paths && !empty($paths[$i])) ? $paths[$i] : '';
1869 1869
 			if ($name === 'blob') {
1870 1870
 				if ($chunk) {
1871 1871
 					if ($tempDir = $this->getTempDir($volume->getTempPath())) {
@@ -1875,7 +1875,7 @@  discard block
 block discarded – undo
1875 1875
 								preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m);
1876 1876
 								$result['error'] = $this->error(self::ERROR_UPLOAD_FILE, $m[1], $tmpname);
1877 1877
 								$result['_chunkfailure'] = true;
1878
-								$this->uploadDebug = 'Upload error: ' . $tmpname;
1878
+								$this->uploadDebug = 'Upload error: '.$tmpname;
1879 1879
 							} else if ($name) {
1880 1880
 								$result['_chunkmerged'] = basename($tmpname);
1881 1881
 								$result['_name'] = $name;
@@ -1889,14 +1889,14 @@  discard block
 block discarded – undo
1889 1889
 				} else {
1890 1890
 					// for form clipboard with Google Chrome
1891 1891
 					$type = $files['type'][$i];
1892
-					$ext = isset($extTable[$type])? '.' . $extTable[$type] : '';
1893
-					$name = substr(md5(basename($tmpname)), 0, 8) . $ext;
1892
+					$ext = isset($extTable[$type]) ? '.'.$extTable[$type] : '';
1893
+					$name = substr(md5(basename($tmpname)), 0, 8).$ext;
1894 1894
 				}
1895 1895
 			}
1896 1896
 			
1897 1897
 			// do hook function 'upload.presave'
1898
-			if (! empty($this->listeners['upload.presave'])) {
1899
-				foreach($this->listeners['upload.presave'] as $handler) {
1898
+			if (!empty($this->listeners['upload.presave'])) {
1899
+				foreach ($this->listeners['upload.presave'] as $handler) {
1900 1900
 					call_user_func_array($handler, array(&$path, &$name, $tmpname, $this, $volume));
1901 1901
 				}
1902 1902
 			}
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
 			if (($fp = fopen($tmpname, 'rb')) == false) {
1905 1905
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER);
1906 1906
 				$this->uploadDebug = 'Upload error: unable open tmp file';
1907
-				if (! is_uploaded_file($tmpname)) {
1907
+				if (!is_uploaded_file($tmpname)) {
1908 1908
 					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]);
1909 1909
 					continue;
1910 1910
 				}
@@ -1926,18 +1926,18 @@  discard block
 block discarded – undo
1926 1926
 					}
1927 1927
 				}
1928 1928
 			}
1929
-			if (! $_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1929
+			if (!$_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1930 1930
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error());
1931 1931
 				fclose($fp);
1932
-				if (! is_uploaded_file($tmpname)) {
1933
-					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);;
1932
+				if (!is_uploaded_file($tmpname)) {
1933
+					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]); ;
1934 1934
 					continue;
1935 1935
 				}
1936 1936
 				break;
1937 1937
 			}
1938 1938
 			
1939 1939
 			is_resource($fp) && fclose($fp);
1940
-			if (! is_uploaded_file($tmpname)){
1940
+			if (!is_uploaded_file($tmpname)) {
1941 1941
 				clearstatcache();
1942 1942
 				if (!is_file($tmpname) || @ unlink($tmpname)) {
1943 1943
 					unset($GLOBALS['elFinderTempFiles'][$tmpname]);
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
 			}
1950 1950
 		}
1951 1951
 		if ($GLOBALS['elFinderTempFiles']) {
1952
-			foreach(array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1952
+			foreach (array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1953 1953
 				@ unlink($_temp);
1954 1954
 			}
1955 1955
 		}
@@ -1986,7 +1986,7 @@  discard block
 block discarded – undo
1986 1986
 		$suffix = '~';
1987 1987
 		if (!empty($args['renames'])) {
1988 1988
 			$renames = array_flip($args['renames']);
1989
-			if (is_string($args['suffix']) && ! preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1989
+			if (is_string($args['suffix']) && !preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1990 1990
 				$suffix = $args['suffix'];
1991 1991
 			}
1992 1992
 		}
@@ -2044,9 +2044,9 @@  discard block
 block discarded – undo
2044 2044
 		}
2045 2045
 		
2046 2046
 		if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
2047
-			$mime = isset($file['mime'])? $file['mime'] : '';
2047
+			$mime = isset($file['mime']) ? $file['mime'] : '';
2048 2048
 			if ($mime && strtolower(substr($mime, 0, 4)) === 'text') {
2049
-				if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) {
2049
+				if ($enc = mb_detect_encoding($content, mb_detect_order(), true)) {
2050 2050
 					if (strtolower($enc) !== 'utf-8') {
2051 2051
 						$content = mb_convert_encoding($content, 'UTF-8', $enc);
2052 2052
 					}
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
 
2059 2059
 		if ($json === false || strlen($json) < strlen($content)) {
2060 2060
 			if ($args['conv']) {
2061
-				return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
2061
+				return array('error' => $this->error(self::ERROR_CONV_UTF8, self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
2062 2062
 			} else {
2063 2063
 				return array('doconv' => true);
2064 2064
 			}
@@ -2100,7 +2100,7 @@  discard block
 block discarded – undo
2100 2100
 		$target = $args['target'];
2101 2101
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2102 2102
 		$error  = array(self::ERROR_EXTRACT, '#'.$target);
2103
-		$makedir = isset($args['makedir'])? (bool)$args['makedir'] : null;
2103
+		$makedir = isset($args['makedir']) ? (bool) $args['makedir'] : null;
2104 2104
 
2105 2105
 		if (($volume = $this->volume($target)) == false
2106 2106
 		|| ($file = $volume->file($target)) == false) {
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
 		}  
2109 2109
 
2110 2110
 		return ($file = $volume->extract($target, $makedir))
2111
-			? array('added' => isset($file['read'])? array($file) : $file)
2111
+			? array('added' => isset($file['read']) ? array($file) : $file)
2112 2112
 			: array('error' => $this->error(self::ERROR_EXTRACT, $volume->path($target), $volume->error()));
2113 2113
 	}
2114 2114
 	
@@ -2123,7 +2123,7 @@  discard block
 block discarded – undo
2123 2123
 	protected function archive($args) {
2124 2124
 		$type    = $args['type'];
2125 2125
 		$targets = isset($args['targets']) && is_array($args['targets']) ? $args['targets'] : array();
2126
-		$name    = isset($args['name'])? $args['name'] : '';
2126
+		$name    = isset($args['name']) ? $args['name'] : '';
2127 2127
 	
2128 2128
 		if (($volume = $this->volume($targets[0])) == false) {
2129 2129
 			return $this->error(self::ERROR_ARCHIVE, self::ERROR_TRGDIR_NOT_FOUND);
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
 	protected function search($args) {
2145 2145
 		$q      = trim($args['q']);
2146 2146
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2147
-		$target = !empty($args['target'])? $args['target'] : null;
2147
+		$target = !empty($args['target']) ? $args['target'] : null;
2148 2148
 		$result = array();
2149 2149
 		$errors = array();
2150 2150
 
@@ -2183,7 +2183,7 @@  discard block
 block discarded – undo
2183 2183
 			$compare = intval($args['compare']);
2184 2184
 			$hash = $args['targets'][0];
2185 2185
 			if ($volume = $this->volume($hash)) {
2186
-				$standby = (int)$volume->getOption('plStandby');
2186
+				$standby = (int) $volume->getOption('plStandby');
2187 2187
 				$_compare = false;
2188 2188
 				if (($syncCheckFunc = $volume->getOption('syncCheckFunc')) && is_callable($syncCheckFunc)) {
2189 2189
 					$_compare = call_user_func_array($syncCheckFunc, array($volume->realpath($hash), $standby, $compare, $volume, $this));
@@ -2191,8 +2191,8 @@  discard block
 block discarded – undo
2191 2191
 				if ($_compare !== false) {
2192 2192
 					$compare = $_compare;
2193 2193
 				} else {
2194
-					$sleep = max(1, (int)$volume->getOption('tsPlSleep'));
2195
-					$limit = max(1, $standby / $sleep) + 1;
2194
+					$sleep = max(1, (int) $volume->getOption('tsPlSleep'));
2195
+					$limit = max(1, $standby/$sleep) + 1;
2196 2196
 					$timelimit = ini_get('max_execution_time');
2197 2197
 					do {
2198 2198
 						$timelimit && @ set_time_limit($timelimit + $sleep);
@@ -2209,7 +2209,7 @@  discard block
 block discarded – undo
2209 2209
 						if (--$limit) {
2210 2210
 							sleep($sleep);
2211 2211
 						}
2212
-					} while($limit);
2212
+					} while ($limit);
2213 2213
 				}
2214 2214
 			}
2215 2215
 		} else {
@@ -2257,12 +2257,12 @@  discard block
 block discarded – undo
2257 2257
 		$target = $args['target'];
2258 2258
 		$width  = $args['width'];
2259 2259
 		$height = $args['height'];
2260
-		$x      = (int)$args['x'];
2261
-		$y      = (int)$args['y'];
2260
+		$x      = (int) $args['x'];
2261
+		$y      = (int) $args['y'];
2262 2262
 		$mode   = $args['mode'];
2263 2263
 		$bg     = null;
2264
-		$degree = (int)$args['degree'];
2265
-		$quality= (int)$args['quality'];
2264
+		$degree = (int) $args['degree'];
2265
+		$quality = (int) $args['quality'];
2266 2266
 		
2267 2267
 		if (($volume = $this->volume($target)) == false
2268 2268
 		|| ($file = $volume->file($target)) == false) {
@@ -2283,7 +2283,7 @@  discard block
 block discarded – undo
2283 2283
 	**/
2284 2284
 	protected function url($args) {
2285 2285
 		$target = $args['target'];
2286
-		$options = isset($args['options'])? $args['options'] : array();
2286
+		$options = isset($args['options']) ? $args['options'] : array();
2287 2287
 		if (($volume = $this->volume($target)) != false) {
2288 2288
 			$url = $volume->getContentUrl($target, $options);
2289 2289
 			return $url ? array('url' => $url) : array();
@@ -2300,18 +2300,18 @@  discard block
 block discarded – undo
2300 2300
 	 */
2301 2301
 	protected function callback($args) {
2302 2302
 		$checkReg = '/[^a-zA-Z0-9;._-]/';
2303
-		$node = (isset($args['node']) && !preg_match($checkReg, $args['node']))? $args['node'] : '';
2304
-		$json = (isset($args['json']) && @json_decode($args['json']))? $args['json'] : '{}';
2305
-		$bind  = (isset($args['bind']) && !preg_match($checkReg, $args['bind']))? $args['bind'] : '';
2303
+		$node = (isset($args['node']) && !preg_match($checkReg, $args['node'])) ? $args['node'] : '';
2304
+		$json = (isset($args['json']) && @json_decode($args['json'])) ? $args['json'] : '{}';
2305
+		$bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind'])) ? $args['bind'] : '';
2306 2306
 		$done = (!empty($args['done']));
2307 2307
 		
2308
-		while( ob_get_level() ) {
2309
-			if (! ob_end_clean()) {
2308
+		while (ob_get_level()) {
2309
+			if (!ob_end_clean()) {
2310 2310
 				break;
2311 2311
 			}
2312 2312
 		}
2313 2313
 		
2314
-		if ($done || ! $this->callbackWindowURL) {
2314
+		if ($done || !$this->callbackWindowURL) {
2315 2315
 			$script = '';
2316 2316
 			if ($node) {
2317 2317
 				$script .= '
@@ -2353,13 +2353,13 @@  discard block
 block discarded – undo
2353 2353
 			
2354 2354
 		} else {
2355 2355
 			$url = $this->callbackWindowURL;
2356
-			$url .= ((strpos($url, '?') === false)? '?' : '&')
2357
-				 . '&node=' . rawurlencode($node)
2358
-				 . (($json !== '{}')? ('&json=' . rawurlencode($json)) : '')
2359
-				 . ($bind? ('&bind=' .  rawurlencode($bind)) : '')
2356
+			$url .= ((strpos($url, '?') === false) ? '?' : '&')
2357
+				 . '&node='.rawurlencode($node)
2358
+				 . (($json !== '{}') ? ('&json='.rawurlencode($json)) : '')
2359
+				 . ($bind ? ('&bind='.rawurlencode($bind)) : '')
2360 2360
 				 . '&done=1';
2361 2361
 			
2362
-			header('Location: ' . $url);
2362
+			header('Location: '.$url);
2363 2363
 			
2364 2364
 		}
2365 2365
 		exit();
@@ -2429,7 +2429,7 @@  discard block
 block discarded – undo
2429 2429
 	
2430 2430
 	protected function utime() {
2431 2431
 		$time = explode(" ", microtime());
2432
-		return (double)$time[1] + (double)$time[0];
2432
+		return (double) $time[1] + (double) $time[0];
2433 2433
 	}
2434 2434
 	
2435 2435
 	
@@ -2455,7 +2455,7 @@  discard block
 block discarded – undo
2455 2455
 		$imgcnt = 0;
2456 2456
 		$fp = fopen($path, 'rb');
2457 2457
 		@fread($fp, 4);
2458
-		$c = @fread($fp,1);
2458
+		$c = @fread($fp, 1);
2459 2459
 		if (ord($c) != 0x39) {  // GIF89a
2460 2460
 			return false;
2461 2461
 		}
@@ -2463,13 +2463,13 @@  discard block
 block discarded – undo
2463 2463
 		while (!feof($fp)) {
2464 2464
 			do {
2465 2465
 				$c = fread($fp, 1);
2466
-			} while(ord($c) != 0x21 && !feof($fp));
2466
+			} while (ord($c) != 0x21 && !feof($fp));
2467 2467
 	
2468 2468
 			if (feof($fp)) {
2469 2469
 				break;
2470 2470
 			}
2471 2471
 	
2472
-			$c2 = fread($fp,2);
2472
+			$c2 = fread($fp, 2);
2473 2473
 			if (bin2hex($c2) == "f904") {
2474 2474
 				$imgcnt++;
2475 2475
 			}
Please login to merge, or discard this patch.
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.