Completed
Push — 2.x ( 6997ec...69ba55 )
by Naoki
03:38
created
php/elFinder.class.php 1 patch
Spacing   +153 added lines, -153 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,14 +247,14 @@  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 260
 
@@ -281,17 +281,17 @@  discard block
 block discarded – undo
281 281
 		
282 282
 		$this->time  = $this->utime();
283 283
 		$this->debug = (isset($opts['debug']) && $opts['debug'] ? true : false);
284
-		$this->sessionCloseEarlier = isset($opts['sessionCloseEarlier'])? (bool)$opts['sessionCloseEarlier'] : true;
284
+		$this->sessionCloseEarlier = isset($opts['sessionCloseEarlier']) ? (bool) $opts['sessionCloseEarlier'] : true;
285 285
 		$this->sessionUseCmds = array_flip($sessionUseCmds);
286 286
 		$this->timeout = (isset($opts['timeout']) ? $opts['timeout'] : 0);
287 287
 		$this->uploadTempPath = (isset($opts['uploadTempPath']) ? $opts['uploadTempPath'] : '');
288
-		$this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey'])? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
288
+		$this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey']) ? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
289 289
 		$this->callbackWindowURL = (isset($opts['callbackWindowURL']) ? $opts['callbackWindowURL'] : '');
290 290
 		self::$sessionCacheKey = !empty($opts['sessionCacheKey']) ? $opts['sessionCacheKey'] : 'elFinderCaches';
291 291
 		
292 292
 		// check session cache
293 293
 		$_optsMD5 = md5(json_encode($opts['roots']));
294
-		if (! isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) {
294
+		if (!isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) {
295 295
 			$_SESSION[self::$sessionCacheKey] = array(
296 296
 				'_optsMD5' => $_optsMD5
297 297
 			);
@@ -310,20 +310,20 @@  discard block
 block discarded – undo
310 310
 			$_reqCmd = isset($_req['cmd']) ? $_req['cmd'] : '';
311 311
 			foreach ($opts['bind'] as $cmd => $handlers) {
312 312
 				$doRegist = (strpos($cmd, '*') !== false);
313
-				if (! $doRegist) {
313
+				if (!$doRegist) {
314 314
 					$_getcmd = create_function('$cmd', 'list($ret) = explode(\'.\', $cmd);return trim($ret);');
315 315
 					$doRegist = ($_reqCmd && in_array($_reqCmd, array_map($_getcmd, explode(' ', $cmd))));
316 316
 				}
317 317
 				if ($doRegist) {
318
-					if (! is_array($handlers) || is_object($handlers[0])) {
318
+					if (!is_array($handlers) || is_object($handlers[0])) {
319 319
 						$handlers = array($handlers);
320 320
 					}
321
-					foreach($handlers as $handler) {
321
+					foreach ($handlers as $handler) {
322 322
 						if ($handler) {
323 323
 							if (is_string($handler) && strpos($handler, '.')) {
324 324
 								list($_domain, $_name, $_method) = array_pad(explode('.', $handler), 3, '');
325 325
 								if (strcasecmp($_domain, 'plugin') === 0) {
326
-									if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name])? $opts['plugin'][$_name] : array())
326
+									if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name]) ? $opts['plugin'][$_name] : array())
327 327
 											and method_exists($plugin, $_method)) {
328 328
 										$this->bind($cmd, array($plugin, $_method));
329 329
 									}
@@ -410,13 +410,13 @@  discard block
 block discarded – undo
410 410
 	public function bind($cmd, $handler) {
411 411
 		$allCmds = array_keys($this->commands);
412 412
 		$cmds = array();
413
-		foreach(explode(' ', $cmd) as $_cmd) {
413
+		foreach (explode(' ', $cmd) as $_cmd) {
414 414
 			if ($_cmd !== '') {
415 415
 				if ($all = strpos($_cmd, '*') !== false) {
416 416
 					list(, $sub) = array_pad(explode('.', $_cmd), 2, '');
417 417
 					if ($sub) {
418 418
 						$sub = str_replace('\'', '\\\'', $sub);
419
-						$addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\'' . $sub . '\');');
419
+						$addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\''.$sub.'\');');
420 420
 						$cmds = array_merge($cmds, array_map($addSub, $allCmds));
421 421
 					} else {
422 422
 						$cmds = array_merge($cmds, $allCmds);
@@ -496,16 +496,16 @@  discard block
 block discarded – undo
496 496
 
497 497
 	private function session_expires() {
498 498
 		
499
-		if (!isset($_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'])) {
500
-			$_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time();
499
+		if (!isset($_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'])) {
500
+			$_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time();
501 501
 			return false;
502 502
 		}
503 503
 
504
-		if ( ($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] > $this->timeout) ) {
504
+		if (($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] > $this->timeout)) {
505 505
 			return true;
506 506
 		}
507 507
 
508
-		$_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time();
508
+		$_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time();
509 509
 		return false;	
510 510
 	}
511 511
 	
@@ -538,9 +538,9 @@  discard block
 block discarded – undo
538 538
 		}
539 539
 
540 540
 		// call pre handlers for this command
541
-		$args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd])? false : $this->sessionCloseEarlier;
541
+		$args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd]) ? false : $this->sessionCloseEarlier;
542 542
 		if (!empty($this->listeners[$cmd.'.pre'])) {
543
-			$volume = isset($args['target'])? $this->volume($args['target']) : false;
543
+			$volume = isset($args['target']) ? $this->volume($args['target']) : false;
544 544
 			foreach ($this->listeners[$cmd.'.pre'] as $handler) {
545 545
 				call_user_func_array($handler, array($cmd, &$args, $this, $volume));
546 546
 			}
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 		// call handlers for this command
563 563
 		if (!empty($this->listeners[$cmd])) {
564 564
 			foreach ($this->listeners[$cmd] as $handler) {
565
-				if (call_user_func_array($handler,array($cmd,&$result,$args,$this))) {
565
+				if (call_user_func_array($handler, array($cmd, &$result, $args, $this))) {
566 566
 					// handler return true to force sync client after command completed
567 567
 					$result['sync'] = true;
568 568
 				}
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 	 * @return string
622 622
 	 * @author Dmitry (dio) Levashov
623 623
 	 **/
624
-	public function realpath($hash)	{
624
+	public function realpath($hash) {
625 625
 		if (($volume = $this->volume($hash)) == false) {
626 626
 			return false;
627 627
 		}
@@ -677,11 +677,11 @@  discard block
 block discarded – undo
677 677
 	 */
678 678
 	protected function getPluginInstance($name, $opts = array()) {
679 679
 		$key = strtolower($name);
680
-		if (! isset($this->plugins[$key])) {
681
-			$p_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'plugin.php';
680
+		if (!isset($this->plugins[$key])) {
681
+			$p_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.'plugin.php';
682 682
 			if (is_file($p_file)) {
683 683
 				require_once $p_file;
684
-				$class = 'elFinderPlugin' . $name;
684
+				$class = 'elFinderPlugin'.$name;
685 685
 				$this->plugins[$key] = new $class($opts);
686 686
 			} else {
687 687
 				$this->plugins[$key] = false;
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
 		
774 774
 		$netVolumes = $this->getNetVolumes();
775 775
 		if ($volume->mount($options)) {
776
-			if (! $key = @ $volume->netMountKey) {
777
-				$key = md5($protocol . '-' . join('-', $options));
776
+			if (!$key = @ $volume->netMountKey) {
777
+				$key = md5($protocol.'-'.join('-', $options));
778 778
 			}
779 779
 			$options['driver'] = $driver;
780 780
 			$options['netkey'] = $key;
@@ -973,24 +973,24 @@  discard block
 block discarded – undo
973 973
 		}
974 974
 
975 975
 		// allow change MIME type by 'file.pre' callback functions
976
-		$mime = isset($args['mime'])? $args['mime'] : $file['mime'];
976
+		$mime = isset($args['mime']) ? $args['mime'] : $file['mime'];
977 977
 		if ($download) {
978 978
 			$disp = 'attachment';
979 979
 		} else {
980 980
 			$dispInlineRegex = $volume->getOption('dispInlineRegex');
981 981
 			$inlineRegex = false;
982 982
 			if ($dispInlineRegex) {
983
-				$inlineRegex = '#' . str_replace('#', '\\#', $dispInlineRegex) . '#';
983
+				$inlineRegex = '#'.str_replace('#', '\\#', $dispInlineRegex).'#';
984 984
 				try {
985 985
 					preg_match($inlineRegex, '');
986
-				} catch(Exception $e) {
986
+				} catch (Exception $e) {
987 987
 					$inlineRegex = false;
988 988
 				}
989 989
 			}
990 990
 			if (!$inlineRegex) {
991 991
 				$inlineRegex = '#^(?:(?:image|text)|application/x-shockwave-flash$)#';
992 992
 			}
993
-			$disp  = preg_match($inlineRegex, $mime)? 'inline' : 'attachment';
993
+			$disp = preg_match($inlineRegex, $mime) ? 'inline' : 'attachment';
994 994
 		}
995 995
 		
996 996
 		$filenameEncoded = rawurlencode($file['name']);
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 		$name   = $args['name'];
1100 1100
 		
1101 1101
 		if (($volume = $this->volume($target)) == false
1102
-		||  ($rm  = $volume->file($target)) == false) {
1102
+		||  ($rm = $volume->file($target)) == false) {
1103 1103
 			return array('error' => $this->error(self::ERROR_RENAME, '#'.$target, self::ERROR_FILE_NOT_FOUND));
1104 1104
 		}
1105 1105
 		$rm['realpath'] = $volume->realpath($target);
@@ -1177,9 +1177,9 @@  discard block
 block discarded – undo
1177 1177
 	* @retval false  error
1178 1178
 	* @author Naoki Sawada
1179 1179
 	**/
1180
-	protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) {
1181
-		$method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; 
1182
-		return $this->$method( $url, $timeout, $redirect_max, $ua, $fp );
1180
+	protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) {
1181
+		$method = (function_exists('curl_exec') && !ini_get('safe_mode')) ? 'curl_get_contents' : 'fsock_get_contents'; 
1182
+		return $this->$method($url, $timeout, $redirect_max, $ua, $fp);
1183 1183
 	}
1184 1184
 	
1185 1185
 	/**
@@ -1195,26 +1195,26 @@  discard block
 block discarded – undo
1195 1195
 	 * @retval false  error
1196 1196
 	 * @author Naoki Sawada
1197 1197
 	 **/
1198
-	 protected function curl_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ){
1198
+	 protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1199 1199
 		$ch = curl_init();
1200
-		curl_setopt( $ch, CURLOPT_URL, $url );
1201
-		curl_setopt( $ch, CURLOPT_HEADER, false );
1200
+		curl_setopt($ch, CURLOPT_URL, $url);
1201
+		curl_setopt($ch, CURLOPT_HEADER, false);
1202 1202
 		if ($outfp) {
1203
-			curl_setopt( $ch, CURLOPT_FILE, $outfp );
1203
+			curl_setopt($ch, CURLOPT_FILE, $outfp);
1204 1204
 		} else {
1205
-			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
1206
-			curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true );
1207
-		}
1208
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 );
1209
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_TIME, $timeout );
1210
-		curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
1211
-		curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
1212
-		curl_setopt( $ch, CURLOPT_MAXREDIRS, $redirect_max);
1213
-		curl_setopt( $ch, CURLOPT_USERAGENT, $ua);
1214
-		$result = curl_exec( $ch );
1205
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1206
+			curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
1207
+		}
1208
+		curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1);
1209
+		curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout);
1210
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1211
+		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
1212
+		curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max);
1213
+		curl_setopt($ch, CURLOPT_USERAGENT, $ua);
1214
+		$result = curl_exec($ch);
1215 1215
 		$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
1216
-		curl_close( $ch );
1217
-		return $outfp? $outfp : $result;
1216
+		curl_close($ch);
1217
+		return $outfp ? $outfp : $result;
1218 1218
 	}
1219 1219
 	
1220 1220
 	/**
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 	 * @retval false  error
1231 1231
 	 * @author Naoki Sawada
1232 1232
 	 */
1233
-	protected function fsock_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ) {
1233
+	protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1234 1234
 
1235 1235
 		$connect_timeout = 3;
1236 1236
 		$connect_try = 3;
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 		$headers = '';
1242 1242
 		
1243 1243
 		$arr = parse_url($url);
1244
-		if (!$arr){
1244
+		if (!$arr) {
1245 1245
 			// Bad request
1246 1246
 			return false;
1247 1247
 		}
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 		// query
1250 1250
 		$arr['query'] = isset($arr['query']) ? '?'.$arr['query'] : '';
1251 1251
 		// port
1252
-		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https'])? 443 : 80);
1252
+		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https']) ? 443 : 80);
1253 1253
 		
1254 1254
 		$url_base = $arr['scheme'].'://'.$arr['host'].':'.$arr['port'];
1255 1255
 		$url_path = isset($arr['path']) ? $arr['path'] : '/';
@@ -1258,21 +1258,21 @@  discard block
 block discarded – undo
1258 1258
 		$query = $method.' '.$uri." HTTP/1.0\r\n";
1259 1259
 		$query .= "Host: ".$arr['host']."\r\n";
1260 1260
 		if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n";
1261
-		if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n";
1261
+		if (!is_null($getSize)) $query .= 'Range: bytes=0-'.($getSize - 1)."\r\n";
1262 1262
 		
1263 1263
 		$query .= $headers;
1264 1264
 
1265 1265
 		$query .= "\r\n";
1266 1266
 
1267 1267
 		$fp = $connect_try_count = 0;
1268
-		while( !$fp && $connect_try_count < $connect_try ) {
1268
+		while (!$fp && $connect_try_count < $connect_try) {
1269 1269
 	
1270 1270
 			$errno = 0;
1271 1271
 			$errstr = "";
1272 1272
 			$fp = @ fsockopen(
1273 1273
 			$arr['https'].$arr['host'],
1274 1274
 			$arr['port'],
1275
-			$errno,$errstr,$connect_timeout);
1275
+			$errno, $errstr, $connect_timeout);
1276 1276
 			if ($fp) break;
1277 1277
 			$connect_try_count++;
1278 1278
 			if (connection_aborted()) {
@@ -1297,13 +1297,13 @@  discard block
 block discarded – undo
1297 1297
 		
1298 1298
 		$_response = '';
1299 1299
 		$header = '';
1300
-		while($_response !== "\r\n"){
1300
+		while ($_response !== "\r\n") {
1301 1301
 			$_response = fgets($fp, $readsize);
1302 1302
 			$header .= $_response;
1303 1303
 		};
1304 1304
 		
1305
-		$rccd = array_pad(explode(' ',$header,3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1306
-		$rc = (int)$rccd[1];
1305
+		$rccd = array_pad(explode(' ', $header, 3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1306
+		$rc = (int) $rccd[1];
1307 1307
 		
1308 1308
 		// Redirect
1309 1309
 		switch ($rc) {
@@ -1312,19 +1312,19 @@  discard block
 block discarded – undo
1312 1312
 			case 302: // Moved Temporarily
1313 1313
 			case 301: // Moved Permanently
1314 1314
 				$matches = array();
1315
-				if (preg_match('/^Location: (.+?)(#.+)?$/im',$header,$matches) && --$redirect_max > 0) {
1315
+				if (preg_match('/^Location: (.+?)(#.+)?$/im', $header, $matches) && --$redirect_max > 0) {
1316 1316
 					$url = trim($matches[1]);
1317
-					$hash = isset($matches[2])? trim($matches[2]) : '';
1318
-					if (!preg_match('/^https?:\//',$url)) { // no scheme
1317
+					$hash = isset($matches[2]) ? trim($matches[2]) : '';
1318
+					if (!preg_match('/^https?:\//', $url)) { // no scheme
1319 1319
 						if ($url{0} != '/') { // Relative path
1320 1320
 							// to Absolute path
1321
-							$url = substr($url_path,0,strrpos($url_path,'/')).'/'.$url;
1321
+							$url = substr($url_path, 0, strrpos($url_path, '/')).'/'.$url;
1322 1322
 						}
1323 1323
 						// add sheme,host
1324 1324
 						$url = $url_base.$url;
1325 1325
 					}
1326 1326
 					fclose($fp);
1327
-					return $this->fsock_get_contents( $url, $timeout, $redirect_max, $ua, $outfp );
1327
+					return $this->fsock_get_contents($url, $timeout, $redirect_max, $ua, $outfp);
1328 1328
 				}
1329 1329
 		}
1330 1330
 		
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
 			$outfp = fopen('php://temp', 'rwb');
1334 1334
 			$body = true;
1335 1335
 		}
1336
-		while(fwrite($outfp, fread($fp, $readsize))) {
1336
+		while (fwrite($outfp, fread($fp, $readsize))) {
1337 1337
 			if ($timeout) {
1338 1338
 				$_status = socket_get_status($fp);
1339 1339
 				if ($_status['timed_out']) {
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
 		
1353 1353
 		fclose($fp);
1354 1354
 		
1355
-		return $outfp? $outfp : $body; // Data
1355
+		return $outfp ? $outfp : $body; // Data
1356 1356
 	}
1357 1357
 	
1358 1358
 	/**
@@ -1363,13 +1363,13 @@  discard block
 block discarded – undo
1363 1363
 	 * @return array
1364 1364
 	 * @author Naoki Sawada
1365 1365
 	 */
1366
-	protected function parse_data_scheme( $str, $extTable ) {
1366
+	protected function parse_data_scheme($str, $extTable) {
1367 1367
 		$data = $name = '';
1368 1368
 		if ($fp = fopen('data://'.substr($str, 5), 'rb')) {
1369 1369
 			if ($data = stream_get_contents($fp)) {
1370 1370
 				$meta = stream_get_meta_data($fp);
1371
-				$ext = isset($extTable[$meta['mediatype']])? '.' . $extTable[$meta['mediatype']] : '';
1372
-				$name = substr(md5($data), 0, 8) . $ext;
1371
+				$ext = isset($extTable[$meta['mediatype']]) ? '.'.$extTable[$meta['mediatype']] : '';
1372
+				$name = substr(md5($data), 0, 8).$ext;
1373 1373
 			}
1374 1374
 			fclose($fp);
1375 1375
 		}
@@ -1433,7 +1433,7 @@  discard block
 block discarded – undo
1433 1433
 			}
1434 1434
 		}
1435 1435
 		
1436
-		return ($mime && isset($extTable[$mime]))? ('.' . $extTable[$mime]) : '';
1436
+		return ($mime && isset($extTable[$mime])) ? ('.'.$extTable[$mime]) : '';
1437 1437
 	}
1438 1438
 	
1439 1439
 	/**
@@ -1449,26 +1449,26 @@  discard block
 block discarded – undo
1449 1449
 	private function checkChunkedFile($tmpname, $chunk, $cid, $tempDir, $volume = null) {
1450 1450
 		if (preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m)) {
1451 1451
 			$fname = $m[1];
1452
-			$encname = md5($cid . '_' . $fname);
1453
-			$base = $tempDir . DIRECTORY_SEPARATOR . 'ELF' . $encname;
1452
+			$encname = md5($cid.'_'.$fname);
1453
+			$base = $tempDir.DIRECTORY_SEPARATOR.'ELF'.$encname;
1454 1454
 			$clast = intval($m[3]);
1455 1455
 			if (is_null($tmpname)) {
1456 1456
 				ignore_user_abort(true);
1457 1457
 				sleep(10); // wait 10 sec
1458 1458
 				// chunked file upload fail
1459
-				foreach(glob($base . '*') as $cf) {
1459
+				foreach (glob($base.'*') as $cf) {
1460 1460
 					@unlink($cf);
1461 1461
 				}
1462 1462
 				ignore_user_abort(false);
1463 1463
 				return;
1464 1464
 			}
1465 1465
 			
1466
-			$range = isset($_POST['range'])? trim($_POST['range']) : '';
1466
+			$range = isset($_POST['range']) ? trim($_POST['range']) : '';
1467 1467
 			if ($range && preg_match('/^(\d+),(\d+),(\d+)$/', $range, $ranges)) {
1468 1468
 				$start = $ranges[1];
1469 1469
 				$len   = $ranges[2];
1470 1470
 				$size  = $ranges[3];
1471
-				$tmp = $base . '.part';
1471
+				$tmp = $base.'.part';
1472 1472
 				$csize = filesize($tmpname);
1473 1473
 				
1474 1474
 				$tmpExists = is_file($tmp);
@@ -1493,7 +1493,7 @@  discard block
 block discarded – undo
1493 1493
 				} else {
1494 1494
 					// wait until makeing temp file (for anothor session)
1495 1495
 					$cnt = 100; // Time limit 10 sec
1496
-					while(!is_file($base) && --$cnt) {
1496
+					while (!is_file($base) && --$cnt) {
1497 1497
 						usleep(100000); // wait 100ms
1498 1498
 					}
1499 1499
 					if (!$cnt) {
@@ -1528,13 +1528,13 @@  discard block
 block discarded – undo
1528 1528
 				}
1529 1529
 			} else {
1530 1530
 				// old way
1531
-				$part = $base . $m[2];
1531
+				$part = $base.$m[2];
1532 1532
 				if (move_uploaded_file($tmpname, $part)) {
1533 1533
 					@chmod($part, 0600);
1534
-					if ($clast < count(glob($base . '*'))) {
1534
+					if ($clast < count(glob($base.'*'))) {
1535 1535
 						$parts = array();
1536 1536
 						for ($i = 0; $i <= $clast; $i++) {
1537
-							$name = $base . '.' . $i . '_' . $clast;
1537
+							$name = $base.'.'.$i.'_'.$clast;
1538 1538
 							if (is_readable($name)) {
1539 1539
 								$parts[] = $name;
1540 1540
 							} else {
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
 								touch($base);
1548 1548
 								if ($resfile = tempnam($tempDir, 'ELF')) {
1549 1549
 									$target = fopen($resfile, 'wb');
1550
-									foreach($parts as $f) {
1550
+									foreach ($parts as $f) {
1551 1551
 										$fp = fopen($f, 'rb');
1552 1552
 										while (!feof($fp)) {
1553 1553
 											fwrite($target, fread($fp, 8192));
@@ -1588,15 +1588,15 @@  discard block
 block discarded – undo
1588 1588
 			$testDirs[] = rtrim(realpath($volumeTempPath), DIRECTORY_SEPARATOR);
1589 1589
 		}
1590 1590
 		$tempDir = '';
1591
-		$test = DIRECTORY_SEPARATOR . microtime(true);
1592
-		foreach($testDirs as $testDir) {
1591
+		$test = DIRECTORY_SEPARATOR.microtime(true);
1592
+		foreach ($testDirs as $testDir) {
1593 1593
 			if (!$testDir || !is_dir($testDir)) continue;
1594 1594
 			$testFile = $testDir.$test;
1595 1595
 			if (touch($testFile)) {
1596 1596
 				unlink($testFile);
1597 1597
 				$tempDir = $testDir;
1598 1598
 				$gc = time() - 3600;
1599
-				foreach(glob($tempDir . '/ELF*') as $cf) {
1599
+				foreach (glob($tempDir.'/ELF*') as $cf) {
1600 1600
 					if (filemtime($cf) < $gc) {
1601 1601
 						@unlink($cf);
1602 1602
 					}
@@ -1616,7 +1616,7 @@  discard block
 block discarded – undo
1616 1616
 	 **/
1617 1617
 	protected function chmod($args) {
1618 1618
 		$targets = $args['targets'];
1619
-		$mode    = intval((string)$args['mode'], 8);
1619
+		$mode    = intval((string) $args['mode'], 8);
1620 1620
 
1621 1621
 		if (!is_array($targets)) {
1622 1622
 			$targets = array($targets);
@@ -1631,10 +1631,10 @@  discard block
 block discarded – undo
1631 1631
 
1632 1632
 		$files = array();
1633 1633
 		$errors = array();
1634
-		foreach($targets as $target) {
1634
+		foreach ($targets as $target) {
1635 1635
 			$file = $volume->chmod($target, $mode);
1636 1636
 			if ($file) {
1637
-				$files = array_merge($files, is_array($file)? $file : array($file));
1637
+				$files = array_merge($files, is_array($file) ? $file : array($file));
1638 1638
 			} else {
1639 1639
 				$errors = array_merge($errors, $volume->error());
1640 1640
 			}
@@ -1666,15 +1666,15 @@  discard block
 block discarded – undo
1666 1666
 		$files  = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array();
1667 1667
 		$header = empty($args['html']) ? array() : array('header' => 'Content-Type: text/html; charset=utf-8');
1668 1668
 		$result = array_merge(array('added' => array()), $header);
1669
-		$paths  = $args['upload_path']? $args['upload_path'] : array();
1670
-		$chunk  = $args['chunk']? $args['chunk'] : '';
1671
-		$cid    = $args['cid']? (int)$args['cid'] : '';
1669
+		$paths  = $args['upload_path'] ? $args['upload_path'] : array();
1670
+		$chunk  = $args['chunk'] ? $args['chunk'] : '';
1671
+		$cid    = $args['cid'] ? (int) $args['cid'] : '';
1672 1672
 		
1673
-		$renames= array();
1673
+		$renames = array();
1674 1674
 		$suffix = '~';
1675 1675
 		if ($args['renames'] && is_array($args['renames'])) {
1676 1676
 			$renames = array_flip($args['renames']);
1677
-			if (is_string($args['suffix']) && ! preg_match($ngReg, $args['suffix'])) {
1677
+			if (is_string($args['suffix']) && !preg_match($ngReg, $args['suffix'])) {
1678 1678
 				$suffix = $args['suffix'];
1679 1679
 			}
1680 1680
 		}
@@ -1707,7 +1707,7 @@  discard block
 block discarded – undo
1707 1707
 			if (!$args['upload'] && $args['name'] && is_array($args['name'])) {
1708 1708
 				$error = '';
1709 1709
 				$result['name'] = array();
1710
-				foreach($args['name'] as $_i => $_name) {
1710
+				foreach ($args['name'] as $_i => $_name) {
1711 1711
 					if (!$volume->isUploadableByName($_name)) {
1712 1712
 						$error = $this->error(self::ERROR_UPLOAD_FILE, $_name, self::ERROR_UPLOAD_FILE_MIME);
1713 1713
 						break;
@@ -1728,7 +1728,7 @@  discard block
 block discarded – undo
1728 1728
 			}
1729 1729
 			if (isset($args['upload']) && is_array($args['upload']) && ($tempDir = $this->getTempDir($volume->getTempPath()))) {
1730 1730
 				$names = array();
1731
-				foreach($args['upload'] as $i => $url) {
1731
+				foreach ($args['upload'] as $i => $url) {
1732 1732
 					// check chunked file upload commit
1733 1733
 					if ($args['chunk']) {
1734 1734
 						if ($url === 'chunkfail' && $args['mimes'] === 'chunkfail') {
@@ -1738,7 +1738,7 @@  discard block
 block discarded – undo
1738 1738
 							}
1739 1739
 							return $result;
1740 1740
 						} else {
1741
-							$tmpfname = $tempDir . '/' . $args['chunk'];
1741
+							$tmpfname = $tempDir.'/'.$args['chunk'];
1742 1742
 							$files['tmp_name'][$i] = $tmpfname;
1743 1743
 							$files['name'][$i] = $url;
1744 1744
 							$files['error'][$i] = 0;
@@ -1747,7 +1747,7 @@  discard block
 block discarded – undo
1747 1747
 						}
1748 1748
 					}
1749 1749
 					
1750
-					$tmpfname = $tempDir . DIRECTORY_SEPARATOR . 'ELF_FATCH_' . md5($url.microtime(true));
1750
+					$tmpfname = $tempDir.DIRECTORY_SEPARATOR.'ELF_FATCH_'.md5($url.microtime(true));
1751 1751
 					
1752 1752
 					$_name = '';
1753 1753
 					// check is data:
@@ -1783,8 +1783,8 @@  discard block
 block discarded – undo
1783 1783
 								list($_a, $_b) = array_pad(explode('.', $_name, 2), 2, '');
1784 1784
 								if ($_b === '') {
1785 1785
 									if ($_ext) {
1786
-										rename($tmpfname, $tmpfname . $_ext);
1787
-										$tmpfname = $tmpfname . $_ext;
1786
+										rename($tmpfname, $tmpfname.$_ext);
1787
+										$tmpfname = $tmpfname.$_ext;
1788 1788
 									}
1789 1789
 									$_b = $this->detectFileExtension($tmpfname);
1790 1790
 									$_name = $_a.$_b;
@@ -1819,7 +1819,7 @@  discard block
 block discarded – undo
1819 1819
 			}
1820 1820
 			
1821 1821
 			$tmpname = $files['tmp_name'][$i];
1822
-			$path = ($paths && !empty($paths[$i]))? $paths[$i] : '';
1822
+			$path = ($paths && !empty($paths[$i])) ? $paths[$i] : '';
1823 1823
 			if ($name === 'blob') {
1824 1824
 				if ($chunk) {
1825 1825
 					if ($tempDir = $this->getTempDir($volume->getTempPath())) {
@@ -1829,7 +1829,7 @@  discard block
 block discarded – undo
1829 1829
 								preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m);
1830 1830
 								$result['error'] = $this->error(self::ERROR_UPLOAD_FILE, $m[1], $tmpname);
1831 1831
 								$result['_chunkfailure'] = true;
1832
-								$this->uploadDebug = 'Upload error: ' . $tmpname;
1832
+								$this->uploadDebug = 'Upload error: '.$tmpname;
1833 1833
 							} else if ($name) {
1834 1834
 								$result['_chunkmerged'] = basename($tmpname);
1835 1835
 								$result['_name'] = $name;
@@ -1843,14 +1843,14 @@  discard block
 block discarded – undo
1843 1843
 				} else {
1844 1844
 					// for form clipboard with Google Chrome
1845 1845
 					$type = $files['type'][$i];
1846
-					$ext = isset($extTable[$type])? '.' . $extTable[$type] : '';
1847
-					$name = substr(md5(basename($tmpname)), 0, 8) . $ext;
1846
+					$ext = isset($extTable[$type]) ? '.'.$extTable[$type] : '';
1847
+					$name = substr(md5(basename($tmpname)), 0, 8).$ext;
1848 1848
 				}
1849 1849
 			}
1850 1850
 			
1851 1851
 			// do hook function 'upload.presave'
1852
-			if (! empty($this->listeners['upload.presave'])) {
1853
-				foreach($this->listeners['upload.presave'] as $handler) {
1852
+			if (!empty($this->listeners['upload.presave'])) {
1853
+				foreach ($this->listeners['upload.presave'] as $handler) {
1854 1854
 					call_user_func_array($handler, array(&$path, &$name, $tmpname, $this, $volume));
1855 1855
 				}
1856 1856
 			}
@@ -1858,7 +1858,7 @@  discard block
 block discarded – undo
1858 1858
 			if (($fp = fopen($tmpname, 'rb')) == false) {
1859 1859
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER);
1860 1860
 				$this->uploadDebug = 'Upload error: unable open tmp file';
1861
-				if (! is_uploaded_file($tmpname)) {
1861
+				if (!is_uploaded_file($tmpname)) {
1862 1862
 					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]);
1863 1863
 					continue;
1864 1864
 				}
@@ -1880,18 +1880,18 @@  discard block
 block discarded – undo
1880 1880
 					}
1881 1881
 				}
1882 1882
 			}
1883
-			if (! $_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1883
+			if (!$_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1884 1884
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error());
1885 1885
 				fclose($fp);
1886
-				if (! is_uploaded_file($tmpname)) {
1887
-					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);;
1886
+				if (!is_uploaded_file($tmpname)) {
1887
+					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]); ;
1888 1888
 					continue;
1889 1889
 				}
1890 1890
 				break;
1891 1891
 			}
1892 1892
 			
1893 1893
 			is_resource($fp) && fclose($fp);
1894
-			if (! is_uploaded_file($tmpname)){
1894
+			if (!is_uploaded_file($tmpname)) {
1895 1895
 				clearstatcache();
1896 1896
 				if (!is_file($tmpname) || @ unlink($tmpname)) {
1897 1897
 					unset($GLOBALS['elFinderTempFiles'][$tmpname]);
@@ -1903,7 +1903,7 @@  discard block
 block discarded – undo
1903 1903
 			}
1904 1904
 		}
1905 1905
 		if ($GLOBALS['elFinderTempFiles']) {
1906
-			foreach(array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1906
+			foreach (array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1907 1907
 				@ unlink($_temp);
1908 1908
 			}
1909 1909
 		}
@@ -1940,7 +1940,7 @@  discard block
 block discarded – undo
1940 1940
 		$suffix = '~';
1941 1941
 		if (!empty($args['renames'])) {
1942 1942
 			$renames = array_flip($args['renames']);
1943
-			if (is_string($args['suffix']) && ! preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1943
+			if (is_string($args['suffix']) && !preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1944 1944
 				$suffix = $args['suffix'];
1945 1945
 			}
1946 1946
 		}
@@ -1998,9 +1998,9 @@  discard block
 block discarded – undo
1998 1998
 		}
1999 1999
 		
2000 2000
 		if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
2001
-			$mime = isset($file['mime'])? $file['mime'] : '';
2001
+			$mime = isset($file['mime']) ? $file['mime'] : '';
2002 2002
 			if ($mime && strtolower(substr($mime, 0, 4)) === 'text') {
2003
-				if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) {
2003
+				if ($enc = mb_detect_encoding($content, mb_detect_order(), true)) {
2004 2004
 					if (strtolower($enc) !== 'utf-8') {
2005 2005
 						$content = mb_convert_encoding($content, 'UTF-8', $enc);
2006 2006
 					}
@@ -2012,7 +2012,7 @@  discard block
 block discarded – undo
2012 2012
 
2013 2013
 		if ($json === false || strlen($json) < strlen($content)) {
2014 2014
 			if ($args['conv']) {
2015
-				return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
2015
+				return array('error' => $this->error(self::ERROR_CONV_UTF8, self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
2016 2016
 			} else {
2017 2017
 				return array('doconv' => true);
2018 2018
 			}
@@ -2054,7 +2054,7 @@  discard block
 block discarded – undo
2054 2054
 		$target = $args['target'];
2055 2055
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2056 2056
 		$error  = array(self::ERROR_EXTRACT, '#'.$target);
2057
-		$makedir = isset($args['makedir'])? (bool)$args['makedir'] : null;
2057
+		$makedir = isset($args['makedir']) ? (bool) $args['makedir'] : null;
2058 2058
 
2059 2059
 		if (($volume = $this->volume($target)) == false
2060 2060
 		|| ($file = $volume->file($target)) == false) {
@@ -2062,7 +2062,7 @@  discard block
 block discarded – undo
2062 2062
 		}  
2063 2063
 
2064 2064
 		return ($file = $volume->extract($target, $makedir))
2065
-			? array('added' => isset($file['read'])? array($file) : $file)
2065
+			? array('added' => isset($file['read']) ? array($file) : $file)
2066 2066
 			: array('error' => $this->error(self::ERROR_EXTRACT, $volume->path($target), $volume->error()));
2067 2067
 	}
2068 2068
 	
@@ -2077,7 +2077,7 @@  discard block
 block discarded – undo
2077 2077
 	protected function archive($args) {
2078 2078
 		$type    = $args['type'];
2079 2079
 		$targets = isset($args['targets']) && is_array($args['targets']) ? $args['targets'] : array();
2080
-		$name    = isset($args['name'])? $args['name'] : '';
2080
+		$name    = isset($args['name']) ? $args['name'] : '';
2081 2081
 	
2082 2082
 		if (($volume = $this->volume($targets[0])) == false) {
2083 2083
 			return $this->error(self::ERROR_ARCHIVE, self::ERROR_TRGDIR_NOT_FOUND);
@@ -2098,7 +2098,7 @@  discard block
 block discarded – undo
2098 2098
 	protected function search($args) {
2099 2099
 		$q      = trim($args['q']);
2100 2100
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2101
-		$target = !empty($args['target'])? $args['target'] : null;
2101
+		$target = !empty($args['target']) ? $args['target'] : null;
2102 2102
 		$result = array();
2103 2103
 
2104 2104
 		if (!is_null($target)) {
@@ -2162,11 +2162,11 @@  discard block
 block discarded – undo
2162 2162
 		$target = $args['target'];
2163 2163
 		$width  = $args['width'];
2164 2164
 		$height = $args['height'];
2165
-		$x      = (int)$args['x'];
2166
-		$y      = (int)$args['y'];
2165
+		$x      = (int) $args['x'];
2166
+		$y      = (int) $args['y'];
2167 2167
 		$mode   = $args['mode'];
2168 2168
 		$bg     = null;
2169
-		$degree = (int)$args['degree'];
2169
+		$degree = (int) $args['degree'];
2170 2170
 		
2171 2171
 		if (($volume = $this->volume($target)) == false
2172 2172
 		|| ($file = $volume->file($target)) == false) {
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
 	**/
2188 2188
 	protected function url($args) {
2189 2189
 		$target = $args['target'];
2190
-		$options = isset($args['options'])? $args['options'] : array();
2190
+		$options = isset($args['options']) ? $args['options'] : array();
2191 2191
 		if (($volume = $this->volume($target)) != false) {
2192 2192
 			$url = $volume->getContentUrl($target, $options);
2193 2193
 			return $url ? array('url' => $url) : array();
@@ -2204,18 +2204,18 @@  discard block
 block discarded – undo
2204 2204
 	 */
2205 2205
 	protected function callback($args) {
2206 2206
 		$checkReg = '/[^a-zA-Z0-9;._-]/';
2207
-		$node = (isset($args['node']) && !preg_match($checkReg, $args['node']))? $args['node'] : '';
2208
-		$json = (isset($args['json']) && @json_decode($args['json']))? $args['json'] : '{}';
2209
-		$bind  = (isset($args['bind']) && !preg_match($checkReg, $args['bind']))? $args['bind'] : '';
2207
+		$node = (isset($args['node']) && !preg_match($checkReg, $args['node'])) ? $args['node'] : '';
2208
+		$json = (isset($args['json']) && @json_decode($args['json'])) ? $args['json'] : '{}';
2209
+		$bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind'])) ? $args['bind'] : '';
2210 2210
 		$done = (!empty($args['done']));
2211 2211
 		
2212
-		while( ob_get_level() ) {
2213
-			if (! ob_end_clean()) {
2212
+		while (ob_get_level()) {
2213
+			if (!ob_end_clean()) {
2214 2214
 				break;
2215 2215
 			}
2216 2216
 		}
2217 2217
 		
2218
-		if ($done || ! $this->callbackWindowURL) {
2218
+		if ($done || !$this->callbackWindowURL) {
2219 2219
 			$script = '';
2220 2220
 			if ($node) {
2221 2221
 				$script .= '
@@ -2257,13 +2257,13 @@  discard block
 block discarded – undo
2257 2257
 			
2258 2258
 		} else {
2259 2259
 			$url = $this->callbackWindowURL;
2260
-			$url .= ((strpos($url, '?') === false)? '?' : '&')
2261
-				 . '&node=' . rawurlencode($node)
2262
-				 . (($json !== '{}')? ('&json=' . rawurlencode($json)) : '')
2263
-				 . ($bind? ('&bind=' .  rawurlencode($bind)) : '')
2260
+			$url .= ((strpos($url, '?') === false) ? '?' : '&')
2261
+				 . '&node='.rawurlencode($node)
2262
+				 . (($json !== '{}') ? ('&json='.rawurlencode($json)) : '')
2263
+				 . ($bind ? ('&bind='.rawurlencode($bind)) : '')
2264 2264
 				 . '&done=1';
2265 2265
 			
2266
-			header('Location: ' . $url);
2266
+			header('Location: '.$url);
2267 2267
 			
2268 2268
 		}
2269 2269
 		exit();
@@ -2333,7 +2333,7 @@  discard block
 block discarded – undo
2333 2333
 	
2334 2334
 	protected function utime() {
2335 2335
 		$time = explode(" ", microtime());
2336
-		return (double)$time[1] + (double)$time[0];
2336
+		return (double) $time[1] + (double) $time[0];
2337 2337
 	}
2338 2338
 	
2339 2339
 	
@@ -2359,7 +2359,7 @@  discard block
 block discarded – undo
2359 2359
 		$imgcnt = 0;
2360 2360
 		$fp = fopen($path, 'rb');
2361 2361
 		@fread($fp, 4);
2362
-		$c = @fread($fp,1);
2362
+		$c = @fread($fp, 1);
2363 2363
 		if (ord($c) != 0x39) {  // GIF89a
2364 2364
 			return false;
2365 2365
 		}
@@ -2367,13 +2367,13 @@  discard block
 block discarded – undo
2367 2367
 		while (!feof($fp)) {
2368 2368
 			do {
2369 2369
 				$c = fread($fp, 1);
2370
-			} while(ord($c) != 0x21 && !feof($fp));
2370
+			} while (ord($c) != 0x21 && !feof($fp));
2371 2371
 	
2372 2372
 			if (feof($fp)) {
2373 2373
 				break;
2374 2374
 			}
2375 2375
 	
2376
-			$c2 = fread($fp,2);
2376
+			$c2 = fread($fp, 2);
2377 2377
 			if (bin2hex($c2) == "f904") {
2378 2378
 				$imgcnt++;
2379 2379
 			}
Please login to merge, or discard this patch.
php/elFinderVolumeDriver.class.php 1 patch
Spacing   +132 added lines, -133 removed lines patch added patch discarded remove patch
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		'utf8fix'      => false,
279 279
 		 //                           й                 ё              Й               Ё              Ø         Å
280 280
 		'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"),
281
-		'utf8replace'  => array("\u0439",        "\u0451",       "\u0419",       "\u0401",       "\u00d8", "\u00c5")
281
+		'utf8replace'  => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5")
282 282
 	);
283 283
 
284 284
 	/**
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 	 **/
574 574
 	protected function configure() {
575 575
 		// set ARGS
576
-		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET;
576
+		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
577 577
 		// set thumbnails path
578 578
 		$path = $this->options['tmbPath'];
579 579
 		if ($path) {
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 		
605 605
 		// check 'statOwner' for command `chmod`
606 606
 		if (empty($this->options['statOwner'])) {
607
-			$this->disabled[] ='chmod';
607
+			$this->disabled[] = 'chmod';
608 608
 		}
609 609
 		
610 610
 		// check 'mimeMap'
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 	 **/
711 711
 	public function mount(array $opts) {
712 712
 		if (!isset($opts['path']) || $opts['path'] === '') {
713
-			return $this->setError('Path undefined.');;
713
+			return $this->setError('Path undefined.'); ;
714 714
 		}
715 715
 		
716 716
 		$this->options = array_merge($this->options, $opts);
@@ -729,14 +729,14 @@  discard block
 block discarded – undo
729 729
 		$argInit = !empty($this->ARGS['init']);
730 730
 		
731 731
 		// session cache
732
-		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
732
+		if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
733 733
 			$_SESSION[elFinder::$sessionCacheKey][$this->id] = array();
734 734
 		}
735 735
 		$this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id];
736 736
 		
737 737
 		// default file attribute
738 738
 		$this->defaults = array(
739
-			'read'    => isset($this->options['defaults']['read'])  ? !!$this->options['defaults']['read']  : true,
739
+			'read'    => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true,
740 740
 			'write'   => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true,
741 741
 			'locked'  => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false,
742 742
 			'hidden'  => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false
@@ -763,8 +763,8 @@  discard block
 block discarded – undo
763 763
 			$this->access = $this->options['accessControl'];
764 764
 		}
765 765
 		
766
-		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y'));
767
-		$this->yesterday = $this->today-86400;
766
+		$this->today     = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
767
+		$this->yesterday = $this->today - 86400;
768 768
 		
769 769
 		// debug($this->attributes);
770 770
 		if (!$this->init()) {
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 				foreach ($mimecf as $line_num => $line) {
864 864
 					if (!preg_match('/^\s*#/', $line)) {
865 865
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
866
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
866
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
867 867
 							if (!isset(self::$mimetypes[$mime[$i]])) {
868 868
 								self::$mimetypes[$mime[$i]] = $mime[0];
869 869
 							}
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 		
893 893
 		if ($root['read']) {
894 894
 			// check startPath - path to open by default instead of root
895
-			$startPath = $this->options['startPath']? $this->normpathCE($this->options['startPath']) : '';
895
+			$startPath = $this->options['startPath'] ? $this->normpathCE($this->options['startPath']) : '';
896 896
 			if ($startPath) {
897 897
 				$start = $this->stat($startPath);
898 898
 				if (!empty($start)
@@ -916,8 +916,8 @@  discard block
 block discarded – undo
916 916
 				'read'    => false
917 917
 			));
918 918
 		}
919
-		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1;
920
-		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48;
919
+		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1;
920
+		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48;
921 921
 		$this->URL      = $this->options['URL'];
922 922
 		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) {
923 923
 			$this->URL .= '/';
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 	public function options($hash) {
1072 1072
 		$create = $createext = array();
1073 1073
 		if (isset($this->archivers['create']) && is_array($this->archivers['create'])) {
1074
-			foreach($this->archivers['create'] as $m => $v) {
1074
+			foreach ($this->archivers['create'] as $m => $v) {
1075 1075
 				$create[] = $m;
1076 1076
 				$createext[$m] = $v['ext'];
1077 1077
 			}
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 				'extract'   => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(),
1092 1092
 				'createext' => $createext
1093 1093
 			),
1094
-			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array()
1094
+			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array()
1095 1095
 		);
1096 1096
 	}
1097 1097
 	
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 	 * @author Naoki Sawada
1104 1104
 	 */
1105 1105
 	public function getOption($name) {
1106
-		return isset($this->options[$name])? $this->options[$name] : null;
1106
+		return isset($this->options[$name]) ? $this->options[$name] : null;
1107 1107
 	}
1108 1108
 	
1109 1109
 	/**
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 	 */
1116 1116
 	public function getOptionsPlugin($name = '') {
1117 1117
 		if ($name) {
1118
-			return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array();
1118
+			return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array();
1119 1119
 		} else {
1120 1120
 			return $this->options['plugin'];
1121 1121
 		}
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 		$file = $this->stat($path);
1246 1246
 		
1247 1247
 		if ($hash === $this->root()) {
1248
-			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array();
1248
+			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array();
1249 1249
 			$file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON
1250 1250
 		}
1251 1251
 		
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
 	 * @return array|false
1261 1261
 	 * @author Dmitry (dio) Levashov
1262 1262
 	 **/
1263
-	public function dir($hash, $resolveLink=false) {
1263
+	public function dir($hash, $resolveLink = false) {
1264 1264
 		if (($dir = $this->file($hash)) == false) {
1265 1265
 			return $this->setError(elFinder::ERROR_DIR_NOT_FOUND);
1266 1266
 		}
@@ -1324,14 +1324,14 @@  discard block
 block discarded – undo
1324 1324
 	 * @return array|false
1325 1325
 	 * @author Dmitry (dio) Levashov
1326 1326
 	 **/
1327
-	public function tree($hash='', $deep=0, $exclude='') {
1327
+	public function tree($hash = '', $deep = 0, $exclude = '') {
1328 1328
 		$path = $hash ? $this->decode($hash) : $this->root;
1329 1329
 		
1330 1330
 		if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') {
1331 1331
 			return false;
1332 1332
 		}
1333 1333
 		
1334
-		$dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null);
1334
+		$dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null);
1335 1335
 		array_unshift($dirs, $dir);
1336 1336
 		return $dirs;
1337 1337
 	}
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
 	 * @return array|false
1562 1562
 	 * @author Dmitry (dio) Levashov
1563 1563
 	 **/
1564
-	public function duplicate($hash, $suffix='copy') {
1564
+	public function duplicate($hash, $suffix = 'copy') {
1565 1565
 		if ($this->commandDisabled('duplicate')) {
1566 1566
 			return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED);
1567 1567
 		}
@@ -1637,7 +1637,7 @@  discard block
 block discarded – undo
1637 1637
 		
1638 1638
 		if ($file) { // file exists
1639 1639
 			// check POST data `overwrite` for 3rd party uploader
1640
-			$overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite'];
1640
+			$overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite'];
1641 1641
 			if ($overwrite) {
1642 1642
 				if (!$file['write']) {
1643 1643
 					return $this->setError(elFinder::ERROR_PERM_DENIED);
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
 		if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) {
1709 1709
 			return $rmSrc
1710 1710
 				? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test))
1711
-				: $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1711
+				: $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1712 1712
 		}
1713 1713
 
1714 1714
 		$test = $this->joinPathCE($destination, $name);
@@ -1871,7 +1871,7 @@  discard block
 block discarded – undo
1871 1871
 			return $this->setError(elFinder::ERROR_PERM_DENIED);
1872 1872
 		}
1873 1873
 		$this->clearcache();
1874
-		$this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir;
1874
+		$this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir;
1875 1875
 		
1876 1876
 		if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) {
1877 1877
 			if (is_array($path)) {
@@ -1929,9 +1929,9 @@  discard block
 block discarded – undo
1929 1929
 		if ($name === '') {
1930 1930
 			$name = count($files) == 1 ? $files[0] : 'Archive';
1931 1931
 		} else {
1932
-			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name));
1932
+			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name));
1933 1933
 		}
1934
-		$name .='.' . $archiver['ext'];
1934
+		$name .= '.'.$archiver['ext'];
1935 1935
 		$name = $this->uniqueName($dir, $name, '');
1936 1936
 		$this->clearcache();
1937 1937
 		return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false;
@@ -1967,7 +1967,7 @@  discard block
 block discarded – undo
1967 1967
 		
1968 1968
 		$path = $this->decode($hash);
1969 1969
 		
1970
-		$work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path);
1970
+		$work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path);
1971 1971
 
1972 1972
 		if (!$work_path || !is_writable($work_path)) {
1973 1973
 			if ($work_path && $path !== $work_path && is_file($work_path)) {
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
 			}
1983 1983
 		}
1984 1984
 
1985
-		switch($mode) {
1985
+		switch ($mode) {
1986 1986
 			
1987 1987
 			case 'propresize':
1988 1988
 				$result = $this->imgResize($work_path, $width, $height, true, true);
@@ -2078,7 +2078,7 @@  discard block
 block discarded – undo
2078 2078
 		}
2079 2079
 		return ($q === '' || $this->commandDisabled('search'))
2080 2080
 			? array()
2081
-			: $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes);
2081
+			: $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes);
2082 2082
 	}
2083 2083
 	
2084 2084
 	/**
@@ -2147,9 +2147,9 @@  discard block
 block discarded – undo
2147 2147
 		$path = ltrim($path, $this->separator);
2148 2148
 		$dirs = explode($this->separator, $path);
2149 2149
 		array_pop($dirs);
2150
-		foreach($dirs as $dir) {
2150
+		foreach ($dirs as $dir) {
2151 2151
 			$targetPath = $this->joinPathCE($base, $dir);
2152
-			if (! $_realpath = $this->realpath($this->encode($targetPath))) {
2152
+			if (!$_realpath = $this->realpath($this->encode($targetPath))) {
2153 2153
 				if ($stat = $this->mkdir($targetHash, $dir)) {
2154 2154
 					$result['added'][] = $stat;
2155 2155
 					$targetHash = $stat['hash'];
@@ -2216,7 +2216,7 @@  discard block
 block discarded – undo
2216 2216
 	 * @author Naoki Sawada
2217 2217
 	 **/
2218 2218
 	protected function dirnameCE($path) {
2219
-		return (!$this->encoding)? $this->_dirname($path) :	$this->convEncOut($this->_dirname($this->convEncIn($path)));
2219
+		return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path)));
2220 2220
 	}
2221 2221
 	
2222 2222
 	/**
@@ -2227,7 +2227,7 @@  discard block
 block discarded – undo
2227 2227
 	 * @author Naoki Sawada
2228 2228
 	 **/
2229 2229
 	protected function basenameCE($path) {
2230
-		return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2230
+		return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2231 2231
 	}
2232 2232
 	
2233 2233
 	/**
@@ -2240,7 +2240,7 @@  discard block
 block discarded – undo
2240 2240
 	 * @author Naoki Sawada
2241 2241
 	 **/
2242 2242
 	protected function joinPathCE($dir, $name) {
2243
-		return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2243
+		return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2244 2244
 	}
2245 2245
 	
2246 2246
 	/**
@@ -2251,7 +2251,7 @@  discard block
 block discarded – undo
2251 2251
 	 * @author Naoki Sawada
2252 2252
 	 **/
2253 2253
 	protected function normpathCE($path) {
2254
-		return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2254
+		return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2255 2255
 	}
2256 2256
 	
2257 2257
 	/**
@@ -2262,7 +2262,7 @@  discard block
 block discarded – undo
2262 2262
 	 * @author Naoki Sawada
2263 2263
 	 **/
2264 2264
 	protected function relpathCE($path) {
2265
-		return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2265
+		return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2266 2266
 	}
2267 2267
 	
2268 2268
 	/**
@@ -2273,7 +2273,7 @@  discard block
 block discarded – undo
2273 2273
 	 * @author Naoki Sawada
2274 2274
 	 **/
2275 2275
 	protected function abspathCE($path) {
2276
-		return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path)));
2276
+		return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path)));
2277 2277
 	}
2278 2278
 	
2279 2279
 	/**
@@ -2285,7 +2285,7 @@  discard block
 block discarded – undo
2285 2285
 	 * @author Naoki Sawada
2286 2286
 	 **/
2287 2287
 	protected function inpathCE($path, $parent) {
2288
-		return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2288
+		return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2289 2289
 	}
2290 2290
 	
2291 2291
 	/**
@@ -2296,8 +2296,8 @@  discard block
 block discarded – undo
2296 2296
 	 * @return resource|false
2297 2297
 	 * @author Naoki Sawada
2298 2298
 	 **/
2299
-	protected function fopenCE($path, $mode='rb') {
2300
-		return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2299
+	protected function fopenCE($path, $mode = 'rb') {
2300
+		return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2301 2301
 	}
2302 2302
 	
2303 2303
 	/**
@@ -2308,8 +2308,8 @@  discard block
 block discarded – undo
2308 2308
 	 * @return bool
2309 2309
 	 * @author Naoki Sawada
2310 2310
 	 **/
2311
-	protected function fcloseCE($fp, $path='') {
2312
-		return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2311
+	protected function fcloseCE($fp, $path = '') {
2312
+		return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2313 2313
 	}
2314 2314
 	
2315 2315
 	/**
@@ -2324,7 +2324,7 @@  discard block
 block discarded – undo
2324 2324
 	 * @author Naoki Sawada
2325 2325
 	 **/
2326 2326
 	protected function saveCE($fp, $dir, $name, $stat) {
2327
-		return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2327
+		return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2328 2328
 	}
2329 2329
 	
2330 2330
 	/**
@@ -2336,7 +2336,7 @@  discard block
 block discarded – undo
2336 2336
 	 **/
2337 2337
 	protected function subdirsCE($path) {
2338 2338
 		if (!isset($this->subdirsCache[$path])) {
2339
-			$this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2339
+			$this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2340 2340
 		}
2341 2341
 		return $this->subdirsCache[$path];
2342 2342
 	}
@@ -2349,7 +2349,7 @@  discard block
 block discarded – undo
2349 2349
 	 * @author Naoki Sawada
2350 2350
 	 **/
2351 2351
 	protected function scandirCE($path) {
2352
-		return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2352
+		return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2353 2353
 	}
2354 2354
 	
2355 2355
 	/**
@@ -2362,7 +2362,7 @@  discard block
 block discarded – undo
2362 2362
 	 * @author Naoki Sawada
2363 2363
 	 **/
2364 2364
 	protected function symlinkCE($source, $targetDir, $name) {
2365
-		return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2365
+		return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2366 2366
 	}
2367 2367
 	
2368 2368
 	/***************** paths *******************/
@@ -2381,7 +2381,7 @@  discard block
 block discarded – undo
2381 2381
 			// cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root
2382 2382
 			$p = $this->relpathCE($path);
2383 2383
 			// if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt
2384
-			if ($p === '')	{
2384
+			if ($p === '') {
2385 2385
 				$p = DIRECTORY_SEPARATOR;
2386 2386
 			}
2387 2387
 
@@ -2414,7 +2414,7 @@  discard block
 block discarded – undo
2414 2414
 			// TODO uncrypt hash and return path
2415 2415
 			$path = $this->uncrypt($h); 
2416 2416
 			// append ROOT to path after it was cut in encode
2417
-			return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2417
+			return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2418 2418
 		}
2419 2419
 	}
2420 2420
 	
@@ -2474,21 +2474,21 @@  discard block
 block discarded – undo
2474 2474
 	 * @author Dmitry (dio) Levashov
2475 2475
 	 **/
2476 2476
 	public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) {
2477
-		$ext  = '';
2477
+		$ext = '';
2478 2478
 
2479 2479
 		if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
2480 2480
 			$ext  = '.'.$m[1];
2481
-			$name = substr($name, 0,  strlen($name)-strlen($m[0]));
2481
+			$name = substr($name, 0, strlen($name) - strlen($m[0]));
2482 2482
 		} 
2483 2483
 		
2484 2484
 		if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) {
2485
-			$i    = (int)$m[2];
2486
-			$name = substr($name, 0, strlen($name)-strlen($m[2]));
2485
+			$i    = (int) $m[2];
2486
+			$name = substr($name, 0, strlen($name) - strlen($m[2]));
2487 2487
 		} else {
2488 2488
 			$i     = $start;
2489 2489
 			$name .= $suffix;
2490 2490
 		}
2491
-		$max = $i+100000;
2491
+		$max = $i + 100000;
2492 2492
 
2493 2493
 		while ($i <= $max) {
2494 2494
 			$n = $name.($i > 0 ? $i : '').$ext;
@@ -2512,7 +2512,7 @@  discard block
 block discarded – undo
2512 2512
 	 * @author Naoki Sawada
2513 2513
 	 */
2514 2514
 	public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') {
2515
-		return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2515
+		return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2516 2516
 	}
2517 2517
 	
2518 2518
 	/**
@@ -2525,7 +2525,7 @@  discard block
 block discarded – undo
2525 2525
 	 * @author Naoki Sawada
2526 2526
 	 */
2527 2527
 	public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') {
2528
-		return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2528
+		return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2529 2529
 	}
2530 2530
 	
2531 2531
 	/**
@@ -2545,7 +2545,7 @@  discard block
 block discarded – undo
2545 2545
 			}
2546 2546
 			if (is_array($var)) {
2547 2547
 				$_ret = array();
2548
-				foreach($var as $_k => $_v) {
2548
+				foreach ($var as $_k => $_v) {
2549 2549
 					$_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_');
2550 2550
 				}
2551 2551
 				$var = $_ret;
@@ -2557,7 +2557,7 @@  discard block
 block discarded – undo
2557 2557
 						$_var = str_replace('?', $unknown, $_var);
2558 2558
 					}
2559 2559
 				}
2560
-				if  ($_var !== false) {
2560
+				if ($_var !== false) {
2561 2561
 					$var = $_var;
2562 2562
 				}
2563 2563
 			}
@@ -2584,7 +2584,7 @@  discard block
 block discarded – undo
2584 2584
 		
2585 2585
 		$key = '';
2586 2586
 		if ($path !== '') {
2587
-			$key = $this->id . '#' . $path;
2587
+			$key = $this->id.'#'.$path;
2588 2588
 			if (isset($cache[$key])) {
2589 2589
 				return $cache[$key];
2590 2590
 			}
@@ -2616,7 +2616,7 @@  discard block
 block discarded – undo
2616 2616
 		if ($work = $this->getTempFile()) {
2617 2617
 			if ($wfp = fopen($work, 'wb')) {
2618 2618
 				if ($fp = $this->_fopen($path)) {
2619
-					while(!feof($fp)) {
2619
+					while (!feof($fp)) {
2620 2620
 						fwrite($wfp, fread($fp, 8192));
2621 2621
 					}
2622 2622
 					$this->_fclose($fp, $path);
@@ -2660,7 +2660,7 @@  discard block
 block discarded – undo
2660 2660
 			@set_time_limit(30);
2661 2661
 			$stat = $this->stat($this->convEncOut($p));
2662 2662
 			$this->convEncIn();
2663
-			($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p);
2663
+			($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p);
2664 2664
 		}
2665 2665
 		return $this->_rmdir($localpath);
2666 2666
 	}
@@ -2677,7 +2677,7 @@  discard block
 block discarded – undo
2677 2677
 	 * @return bool
2678 2678
 	 * @author Dmitry (dio) Levashov
2679 2679
 	 **/
2680
-	protected function attr($path, $name, $val=null, $isDir=null) {
2680
+	protected function attr($path, $name, $val = null, $isDir = null) {
2681 2681
 		if (!isset($this->defaults[$name])) {
2682 2682
 			return false;
2683 2683
 		}
@@ -2709,7 +2709,7 @@  discard block
 block discarded – undo
2709 2709
 			} 
2710 2710
 		}
2711 2711
 		
2712
-		return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm;
2712
+		return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm;
2713 2713
 	}
2714 2714
 	
2715 2715
 	/**
@@ -2753,7 +2753,7 @@  discard block
 block discarded – undo
2753 2753
 	protected function allowPutMime($mime) {
2754 2754
 		// logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order
2755 2755
 		$allow  = $this->mimeAccepted($mime, $this->uploadAllow, null);
2756
-		$deny   = $this->mimeAccepted($mime, $this->uploadDeny,  null);
2756
+		$deny   = $this->mimeAccepted($mime, $this->uploadDeny, null);
2757 2757
 		$res = true; // default to allow
2758 2758
 		if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny'
2759 2759
 			$res = false; // default is deny
@@ -2826,10 +2826,10 @@  discard block
 block discarded – undo
2826 2826
 			if ($this->rootName) {
2827 2827
 				$stat['name'] = $this->rootName;
2828 2828
 			}
2829
-			if (! empty($this->options['icon'])) {
2829
+			if (!empty($this->options['icon'])) {
2830 2830
 				$stat['icon'] = $this->options['icon'];
2831 2831
 			}
2832
-			if (! empty($this->options['rootCssClass'])) {
2832
+			if (!empty($this->options['rootCssClass'])) {
2833 2833
 				$stat['csscls'] = $this->options['rootCssClass'];
2834 2834
 			}
2835 2835
 		} else {
@@ -2877,7 +2877,7 @@  discard block
 block discarded – undo
2877 2877
 			// lock when parent directory is not writable
2878 2878
 			if (!isset($stat['locked'])) {
2879 2879
 				$parent = $this->dirnameCE($path);
2880
-				$pstat = isset($this->cache[$parent])? $this->cache[$parent] : array();
2880
+				$pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array();
2881 2881
 				if (isset($pstat['write']) && !$pstat['write']) {
2882 2882
 					$stat['locked'] = true;
2883 2883
 				}
@@ -2935,7 +2935,7 @@  discard block
 block discarded – undo
2935 2935
 			}
2936 2936
 			if (!isset($stat['url']) && $this->URL && $this->encoding) {
2937 2937
 				$_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1));
2938
-				$stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN')? $_path : $this->convEncIn($_path, true)));
2938
+				$stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN') ? $_path : $this->convEncIn($_path, true)));
2939 2939
 			}
2940 2940
 		} else {
2941 2941
 			if ($isDir) {
@@ -3058,7 +3058,7 @@  discard block
 block discarded – undo
3058 3058
 				foreach ($mimecf as $line_num => $line) {
3059 3059
 					if (!preg_match('/^\s*#/', $line)) {
3060 3060
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
3061
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
3061
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
3062 3062
 							if (!isset(elFinderVolumeDriver::$mimetypes[$mime[$i]])) {
3063 3063
 								elFinderVolumeDriver::$mimetypes[$mime[$i]] = $mime[0];
3064 3064
 							}
@@ -3196,7 +3196,7 @@  discard block
 block discarded – undo
3196 3196
 	 * @return array
3197 3197
 	 * @author Dmitry (dio) Levashov
3198 3198
 	 **/
3199
-	protected function gettree($path, $deep, $exclude='') {
3199
+	protected function gettree($path, $deep, $exclude = '') {
3200 3200
 		$dirs = array();
3201 3201
 		
3202 3202
 		!isset($this->dirsCache[$path]) && $this->cacheDir($path);
@@ -3207,7 +3207,7 @@  discard block
 block discarded – undo
3207 3207
 			if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') {
3208 3208
 				$dirs[] = $stat;
3209 3209
 				if ($deep > 0 && !empty($stat['dirs'])) {
3210
-					$dirs = array_merge($dirs, $this->gettree($p, $deep-1));
3210
+					$dirs = array_merge($dirs, $this->gettree($p, $deep - 1));
3211 3211
 				}
3212 3212
 			}
3213 3213
 		}
@@ -3227,7 +3227,7 @@  discard block
 block discarded – undo
3227 3227
 	protected function doSearch($path, $q, $mimes) {
3228 3228
 		$result = array();
3229 3229
 
3230
-		foreach($this->scandirCE($path) as $p) {
3230
+		foreach ($this->scandirCE($path) as $p) {
3231 3231
 			@set_time_limit(30);
3232 3232
 			$stat = $this->stat($p);
3233 3233
 
@@ -3248,7 +3248,7 @@  discard block
 block discarded – undo
3248 3248
 					if ($this->encoding) {
3249 3249
 						$path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true)));
3250 3250
 					}
3251
-					$stat['url'] = $this->URL . $path;
3251
+					$stat['url'] = $this->URL.$path;
3252 3252
 				}
3253 3253
 				
3254 3254
 				$result[] = $stat;
@@ -3282,7 +3282,7 @@  discard block
 block discarded – undo
3282 3282
 			if (!$this->inpathCE($target, $this->root)) {
3283 3283
 				return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK);
3284 3284
 			}
3285
-			$stat   = $this->stat($target);
3285
+			$stat = $this->stat($target);
3286 3286
 			$this->clearcache();
3287 3287
 			return $stat && $this->symlinkCE($target, $dst, $name)
3288 3288
 				? $this->joinPathCE($dst, $name)
@@ -3563,15 +3563,15 @@  discard block
 block discarded – undo
3563 3563
 		}
3564 3564
 
3565 3565
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
3566
-		if ($s[0] <= $tmbSize && $s[1]	<= $tmbSize) {
3567
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3566
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
3567
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3568 3568
 		} else {
3569 3569
 		
3570 3570
 			if ($this->options['tmbCrop']) {
3571 3571
 		
3572 3572
 				$result = $tmb;
3573 3573
 				/* Resize and crop if image bigger than thumbnail */
3574
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3574
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3575 3575
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
3576 3576
 				}
3577 3577
 		
@@ -3588,7 +3588,7 @@  discard block
 block discarded – undo
3588 3588
 			}
3589 3589
 		
3590 3590
 			if ($result) {
3591
-				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3591
+				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3592 3592
 			}
3593 3593
 		}
3594 3594
 		
@@ -3629,18 +3629,18 @@  discard block
 block discarded – undo
3629 3629
 			/* Resizing by biggest side */
3630 3630
 			if ($resizeByBiggerSide) {
3631 3631
 				if ($orig_w > $orig_h) {
3632
-					$size_h = round($orig_h * $width / $orig_w);
3632
+					$size_h = round($orig_h*$width/$orig_w);
3633 3633
 					$size_w = $width;
3634 3634
 				} else {
3635
-					$size_w = round($orig_w * $height / $orig_h);
3635
+					$size_w = round($orig_w*$height/$orig_h);
3636 3636
 					$size_h = $height;
3637 3637
 				}
3638 3638
 			} else {
3639 3639
 				if ($orig_w > $orig_h) {
3640
-					$size_w = round($orig_w * $height / $orig_h);
3640
+					$size_w = round($orig_w*$height/$orig_h);
3641 3641
 					$size_h = $height;
3642 3642
 				} else {
3643
-					$size_h = round($orig_h * $width / $orig_w);
3643
+					$size_h = round($orig_h*$width/$orig_w);
3644 3644
 					$size_w = $width;
3645 3645
 				}
3646 3646
 			}
@@ -3658,7 +3658,7 @@  discard block
 block discarded – undo
3658 3658
 				// Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb
3659 3659
 				// resize bench: http://app-mgng.rhcloud.com/9
3660 3660
 				// resize sample: http://www.dylanbeattie.net/magick/filters/result.html
3661
-				$filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3661
+				$filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3662 3662
 				
3663 3663
 				$ani = ($img->getNumberImages() > 1);
3664 3664
 				if ($ani && is_null($destformat)) {
@@ -3683,11 +3683,11 @@  discard block
 block discarded – undo
3683 3683
 				break;
3684 3684
 
3685 3685
 			case 'gd':
3686
-				$img = self::gdImageCreate($path,$s['mime']);
3686
+				$img = self::gdImageCreate($path, $s['mime']);
3687 3687
 
3688
-				if ($img &&  false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3688
+				if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3689 3689
 				
3690
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3690
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3691 3691
 					
3692 3692
 					if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) {
3693 3693
 						return false;
@@ -3763,11 +3763,11 @@  discard block
 block discarded – undo
3763 3763
 				break;
3764 3764
 
3765 3765
 			case 'gd':
3766
-				$img = self::gdImageCreate($path,$s['mime']);
3766
+				$img = self::gdImageCreate($path, $s['mime']);
3767 3767
 
3768
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3768
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3769 3769
 					
3770
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3770
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3771 3771
 
3772 3772
 					$size_w = $width;
3773 3773
 					$size_h = $height;
@@ -3817,8 +3817,8 @@  discard block
 block discarded – undo
3817 3817
 		$result = false;
3818 3818
 
3819 3819
 		/* Coordinates for image over square aligning */
3820
-		$y = ceil(abs($height - $s[1]) / 2); 
3821
-		$x = ceil(abs($width - $s[0]) / 2);
3820
+		$y = ceil(abs($height - $s[1])/2); 
3821
+		$x = ceil(abs($width - $s[0])/2);
3822 3822
 
3823 3823
 		switch ($this->imgLib) {
3824 3824
 			case 'imagick':
@@ -3838,7 +3838,7 @@  discard block
 block discarded – undo
3838 3838
 						$gif->newImage($width, $height, new ImagickPixel($bgcolor));
3839 3839
 						$gif->setImageColorspace($img->getImageColorspace());
3840 3840
 						$gif->setImageFormat('gif');
3841
-						$gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3841
+						$gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3842 3842
 						$gif->setImageDelay($img->getImageDelay());
3843 3843
 						$gif->setImageIterations($img->getImageIterations());
3844 3844
 						$img1->addImage($gif);
@@ -3854,7 +3854,7 @@  discard block
 block discarded – undo
3854 3854
 					$img1->newImage($width, $height, new ImagickPixel($bgcolor));
3855 3855
 					$img1->setImageColorspace($img->getImageColorspace());
3856 3856
 					$img1->setImageFormat($destformat != null ? $destformat : $img->getFormat());
3857
-					$img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3857
+					$img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3858 3858
 					$result = $img1->writeImage($path);
3859 3859
 				}
3860 3860
 				
@@ -3865,11 +3865,11 @@  discard block
 block discarded – undo
3865 3865
 				break;
3866 3866
 
3867 3867
 			case 'gd':
3868
-				$img = self::gdImageCreate($path,$s['mime']);
3868
+				$img = self::gdImageCreate($path, $s['mime']);
3869 3869
 
3870
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3870
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3871 3871
 
3872
-					self::gdImageBackground($tmp,$bgcolor);
3872
+					self::gdImageBackground($tmp, $bgcolor);
3873 3873
 
3874 3874
 					if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) {
3875 3875
 						return false;
@@ -3900,15 +3900,15 @@  discard block
 block discarded – undo
3900 3900
 	 * @author Troex Nevelin
3901 3901
 	 **/
3902 3902
 	protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null) {
3903
-		if (($s = @getimagesize($path)) == false || $degree % 360 === 0) {
3903
+		if (($s = @getimagesize($path)) == false || $degree%360 === 0) {
3904 3904
 			return false;
3905 3905
 		}
3906 3906
 
3907 3907
 		$result = false;
3908 3908
 
3909 3909
 		// try lossless rotate
3910
-		if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3911
-			$count = ($degree / 90) % 4;
3910
+		if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3911
+			$count = ($degree/90)%4;
3912 3912
 			$exiftran = array(
3913 3913
 				1 => '-9',
3914 3914
 				2 => '-1',
@@ -3924,7 +3924,7 @@  discard block
 block discarded – undo
3924 3924
 				'exiftran -i '.$exiftran[$count].' '.$path,
3925 3925
 				'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath
3926 3926
 			);
3927
-			foreach($cmds as $cmd) {
3927
+			foreach ($cmds as $cmd) {
3928 3928
 				if ($this->procExec($cmd) === 0) {
3929 3929
 					$result = true;
3930 3930
 					break;
@@ -3960,12 +3960,12 @@  discard block
 block discarded – undo
3960 3960
 				break;
3961 3961
 
3962 3962
 			case 'gd':
3963
-				$img = self::gdImageCreate($path,$s['mime']);
3963
+				$img = self::gdImageCreate($path, $s['mime']);
3964 3964
 
3965 3965
 				$degree = 360 - $degree;
3966 3966
 				list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
3967 3967
 				$bgcolor = imagecolorallocate($img, $r, $g, $b);
3968
-				$tmp = imageRotate($img, $degree, (int)$bgcolor);
3968
+				$tmp = imageRotate($img, $degree, (int) $bgcolor);
3969 3969
 
3970 3970
 				$result = self::gdImage($tmp, $path, $destformat, $s['mime']);
3971 3971
 
@@ -3990,11 +3990,11 @@  discard block
 block discarded – undo
3990 3990
 	 * @return int     exit code
3991 3991
 	 * @author Alexey Sukhotin
3992 3992
 	 **/
3993
-	protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) {
3993
+	protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) {
3994 3994
 
3995 3995
 		$descriptorspec = array(
3996
-			0 => array("pipe", "r"),  // stdin
3997
-			1 => array("pipe", "w"),  // stdout
3996
+			0 => array("pipe", "r"), // stdin
3997
+			1 => array("pipe", "w"), // stdout
3998 3998
 			2 => array("pipe", "w")   // stderr
3999 3999
 		);
4000 4000
 
@@ -4051,8 +4051,8 @@  discard block
 block discarded – undo
4051 4051
 	 * @param string $mime
4052 4052
 	 * @return gd image resource identifier
4053 4053
 	 */
4054
-	protected function gdImageCreate($path,$mime){
4055
-		switch($mime){
4054
+	protected function gdImageCreate($path, $mime) {
4055
+		switch ($mime) {
4056 4056
 			case 'image/jpeg':
4057 4057
 			return imagecreatefromjpeg($path);
4058 4058
 
@@ -4076,7 +4076,7 @@  discard block
 block discarded – undo
4076 4076
 	 * @param string $destformat The Image type to use for $filename
4077 4077
 	 * @param string $mime The original image mime type
4078 4078
 	 */
4079
-	protected function gdImage($image, $filename, $destformat, $mime ){
4079
+	protected function gdImage($image, $filename, $destformat, $mime) {
4080 4080
 
4081 4081
 		if ($destformat == 'jpg' || ($destformat == null && $mime == 'image/jpeg')) {
4082 4082
 			return imagejpeg($image, $filename, 100);
@@ -4095,13 +4095,13 @@  discard block
 block discarded – undo
4095 4095
 	 * @param resource $image gd image resource
4096 4096
 	 * @param string $bgcolor background color in #rrggbb format
4097 4097
 	 */
4098
-	protected function gdImageBackground($image, $bgcolor){
4098
+	protected function gdImageBackground($image, $bgcolor) {
4099 4099
 
4100
-		if( $bgcolor == 'transparent' ){
4101
-			imagesavealpha($image,true);
4100
+		if ($bgcolor == 'transparent') {
4101
+			imagesavealpha($image, true);
4102 4102
 			$bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127);
4103 4103
 
4104
-		}else{
4104
+		} else {
4105 4105
 			list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4106 4106
 			$bgcolor1 = imagecolorallocate($image, $r, $g, $b);
4107 4107
 		}
@@ -4139,13 +4139,13 @@  discard block
 block discarded – undo
4139 4139
 	* @return int|bool
4140 4140
 	* @author Alexey Sukhotin
4141 4141
 	**/
4142
-	protected function stripos($haystack , $needle , $offset = 0) {
4142
+	protected function stripos($haystack, $needle, $offset = 0) {
4143 4143
 		if (function_exists('mb_stripos')) {
4144
-			return mb_stripos($haystack , $needle , $offset, 'UTF-8');
4144
+			return mb_stripos($haystack, $needle, $offset, 'UTF-8');
4145 4145
 		} else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) {
4146 4146
 			return mb_strpos(mb_strtolower($haystack, 'UTF-8'), mb_strtolower($needle, 'UTF-8'), $offset);
4147 4147
 		} 
4148
-		return stripos($haystack , $needle , $offset);
4148
+		return stripos($haystack, $needle, $offset);
4149 4149
 	}
4150 4150
 
4151 4151
 	/**
@@ -4195,22 +4195,22 @@  discard block
 block discarded – undo
4195 4195
 			unset($o);
4196 4196
 			$this->procExec('zip -v', $o, $c);
4197 4197
 			if ($c == 0) {
4198
-				$arcs['create']['application/zip']  = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4198
+				$arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4199 4199
 			}
4200 4200
 			unset($o);
4201 4201
 			$this->procExec('unzip --help', $o, $c);
4202 4202
 			if ($c == 0) {
4203
-				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '',  'ext' => 'zip');
4203
+				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip');
4204 4204
 			}
4205 4205
 			unset($o);
4206 4206
 			$this->procExec('rar --version', $o, $c);
4207 4207
 			if ($c == 0 || $c == 7) {
4208 4208
 				$arcs['create']['application/x-rar']  = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar');
4209
-				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y',    'ext' => 'rar');
4209
+				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar');
4210 4210
 			} else {
4211 4211
 				unset($o);
4212 4212
 				$test = $this->procExec('unrar', $o, $c);
4213
-				if ($c==0 || $c == 7) {
4213
+				if ($c == 0 || $c == 7) {
4214 4214
 					$arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar');
4215 4215
 				}
4216 4216
 			}
@@ -4232,7 +4232,7 @@  discard block
 block discarded – undo
4232 4232
 				if (empty($arcs['extract']['application/x-tar'])) {
4233 4233
 					$arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar');
4234 4234
 				}
4235
-			} else if (substr(PHP_OS,0,3) === 'WIN') {
4235
+			} else if (substr(PHP_OS, 0, 3) === 'WIN') {
4236 4236
 				// check `7z` for Windows server.
4237 4237
 				unset($o);
4238 4238
 				$this->procExec('7z', $o, $c);
@@ -4286,22 +4286,22 @@  discard block
 block discarded – undo
4286 4286
 
4287 4287
 		// normalize `/../`
4288 4288
 		$normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#';
4289
-		while(preg_match($normreg, $path)) {
4289
+		while (preg_match($normreg, $path)) {
4290 4290
 			$path = preg_replace($normreg, '$1', $path);
4291 4291
 		}
4292 4292
 		
4293 4293
 		// 'Here'
4294
-		if ($path === '' || $path === '.' . $separator) return $base;
4294
+		if ($path === '' || $path === '.'.$separator) return $base;
4295 4295
 		
4296 4296
 		// Absolute path
4297 4297
 		if ($path[0] === $separator || strpos($path, $systemroot) === 0) {
4298 4298
 			return $path;
4299 4299
 		}
4300 4300
 		
4301
-		$preg_separator = '#' . $sepquoted . '#';
4301
+		$preg_separator = '#'.$sepquoted.'#';
4302 4302
 		
4303 4303
 		// Relative path from 'Here'
4304
-		if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) {
4304
+		if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) {
4305 4305
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4306 4306
 			if ($arrn[0] !== '.') {
4307 4307
 				array_unshift($arrn, '.');
@@ -4315,12 +4315,11 @@  discard block
 block discarded – undo
4315 4315
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4316 4316
 			$arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY);
4317 4317
 		
4318
-			while (! empty($arrn) && $arrn[0] === '..') {
4318
+			while (!empty($arrn) && $arrn[0] === '..') {
4319 4319
 				array_shift($arrn);
4320 4320
 				array_pop($arrp);
4321 4321
 			}
4322
-			$path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) :
4323
-				(! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot);
4322
+			$path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot);
4324 4323
 		}
4325 4324
 		
4326 4325
 		return $path;
@@ -4338,7 +4337,7 @@  discard block
 block discarded – undo
4338 4337
 			@chmod($dir, 0777);
4339 4338
 			foreach (array_diff(scandir($dir), array('.', '..')) as $file) {
4340 4339
 				@set_time_limit(30);
4341
-				$path = $dir . DIRECTORY_SEPARATOR . $file;
4340
+				$path = $dir.DIRECTORY_SEPARATOR.$file;
4342 4341
 				if (!is_link($dir) && is_dir($path)) {
4343 4342
 					$this->rmdirRecursive($path);
4344 4343
 				} else {
@@ -4425,22 +4424,22 @@  discard block
 block discarded – undo
4425 4424
 		try {
4426 4425
 			if ($start = is_string($zipPath)) {
4427 4426
 				$zip = new ZipArchive();
4428
-				if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) {
4427
+				if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) {
4429 4428
 					$zip = false;
4430 4429
 				}
4431 4430
 			} else {
4432 4431
 				$zip = $zipPath;
4433 4432
 			}
4434 4433
 			if ($zip) {
4435
-				foreach($files as $file) {
4436
-					$path = $dir . DIRECTORY_SEPARATOR . $file;
4434
+				foreach ($files as $file) {
4435
+					$path = $dir.DIRECTORY_SEPARATOR.$file;
4437 4436
 					if (is_dir($path)) {
4438 4437
 						$zip->addEmptyDir($file);
4439 4438
 						$_files = array();
4440 4439
 						if ($handle = opendir($path)) {
4441 4440
 							while (false !== ($entry = readdir($handle))) {
4442 4441
 								if ($entry !== "." && $entry !== "..") {
4443
-									$_files[] = $file . DIRECTORY_SEPARATOR . $entry;
4442
+									$_files[] = $file.DIRECTORY_SEPARATOR.$entry;
4444 4443
 								}
4445 4444
 							}
4446 4445
 							closedir($handle);
@@ -4625,7 +4624,7 @@  discard block
 block discarded – undo
4625 4624
 	 * @return resource|false
4626 4625
 	 * @author Dmitry (dio) Levashov
4627 4626
 	 **/
4628
-	abstract protected function _fopen($path, $mode="rb");
4627
+	abstract protected function _fopen($path, $mode = "rb");
4629 4628
 	
4630 4629
 	/**
4631 4630
 	 * Close opened file
@@ -4635,7 +4634,7 @@  discard block
 block discarded – undo
4635 4634
 	 * @return bool
4636 4635
 	 * @author Dmitry (dio) Levashov
4637 4636
 	 **/
4638
-	abstract protected function _fclose($fp, $path='');
4637
+	abstract protected function _fclose($fp, $path = '');
4639 4638
 	
4640 4639
 	/********************  file/dir manipulations *************************/
4641 4640
 	
Please login to merge, or discard this patch.
php/elFinderVolumeLocalFileSystem.class.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 	 * @author Dmitry (dio) Levashov
33 33
 	 **/
34 34
 	public function __construct() {
35
-		$this->options['alias']    = '';              // alias to replace root dir name
36
-		$this->options['dirMode']  = 0755;            // new dirs mode
37
-		$this->options['fileMode'] = 0644;            // new files mode
38
-		$this->options['quarantine'] = '.quarantine';  // quarantine folder name - required to check archive (must be hidden)
39
-		$this->options['maxArcFilesSize'] = 0;        // max allowed archive files size (0 - no limit)
35
+		$this->options['alias']    = ''; // alias to replace root dir name
36
+		$this->options['dirMode']  = 0755; // new dirs mode
37
+		$this->options['fileMode'] = 0644; // new files mode
38
+		$this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden)
39
+		$this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit)
40 40
 		$this->options['rootCssClass'] = 'elfinder-navbar-root-local';
41 41
 	}
42 42
 	
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	protected function init() {
54 54
 		// Normalize directory separator for windows
55 55
 		if (DIRECTORY_SEPARATOR !== '/') {
56
-			foreach(array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) {
56
+			foreach (array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) {
57 57
 				if (!empty($this->options[$key])) {
58 58
 					$this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]);
59 59
 				}
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 		// if no thumbnails url - try detect it
103 103
 		if ($root['read'] && !$this->tmbURL && $this->URL) {
104 104
 			if (strpos($this->tmbPath, $this->root) === 0) {
105
-				$this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1));
105
+				$this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1));
106 106
 				if (preg_match("|[^/?&=]$|", $this->tmbURL)) {
107 107
 					$this->tmbURL .= '/';
108 108
 				}
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @author Dmitry (dio) Levashov
179 179
 	 **/
180 180
 	protected function _joinPath($dir, $name) {
181
-		return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name;
181
+		return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name;
182 182
 	}
183 183
 	
184 184
 	/**
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		$comps = $new_comps;
231 231
 		$path = implode('/', $comps);
232 232
 		if ($initial_slashes) {
233
-			$path = str_repeat('/', $initial_slashes) . $path;
233
+			$path = str_repeat('/', $initial_slashes).$path;
234 234
 		}
235 235
 		
236 236
 		if ($changeSep) {
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	 **/
302 302
 	protected function _inpath($path, $parent) {
303 303
 		$cwd = getcwd();
304
-		$real_path   = $this->getFullPath($path,   $cwd);
304
+		$real_path   = $this->getFullPath($path, $cwd);
305 305
 		$real_parent = $this->getFullPath($parent, $cwd);
306 306
 		if ($real_path && $real_parent) {
307 307
 			return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0;
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 					$stat = array();
361 361
 					return $stat;
362 362
 				} else {
363
-					$stat['mime']  = 'symlink-broken';
363
+					$stat['mime'] = 'symlink-broken';
364 364
 					$target = readlink($path);
365 365
 					$lstat = lstat($path);
366 366
 					$ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 			$fstat = stat($path);
377 377
 			$uid = $fstat['uid'];
378 378
 			$gid = $fstat['gid'];
379
-			$stat['perm'] = substr((string)decoct($fstat['mode']), -4);
379
+			$stat['perm'] = substr((string) decoct($fstat['mode']), -4);
380 380
 			$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
381 381
 		}
382 382
 		
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
 			$stat['mime'] = $dir ? 'directory' : $this->mimetype($path);
387 387
 		}
388 388
 		//logical rights first
389
-		$stat['read'] = ($linkreadable || is_readable($path))? null : false;
390
-		$stat['write'] = is_writable($path)? null : false;
389
+		$stat['read'] = ($linkreadable || is_readable($path)) ? null : false;
390
+		$stat['write'] = is_writable($path) ? null : false;
391 391
 
392 392
 		if (is_null($stat['read'])) {
393 393
 			$stat['size'] = $dir ? 0 : $size;
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 
458 458
 		if (is_dir($path)) {
459 459
 			$path = strtr($path, array('['  => '\\[', ']'  => '\\]', '*'  => '\\*', '?'  => '\\?'));
460
-			return (bool)glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR);
460
+			return (bool) glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR);
461 461
 		}
462 462
 		return false;
463 463
 	}
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 							$br = true;
539 539
 						} else {
540 540
 							$_path = $fpath;
541
-							$stat['mime']  = 'symlink-broken';
541
+							$stat['mime'] = 'symlink-broken';
542 542
 							$target = readlink($_path);
543 543
 							$lstat = lstat($_path);
544 544
 							$ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']);
@@ -563,13 +563,13 @@  discard block
 block discarded – undo
563 563
 					if ($statOwner && !$linkreadable) {
564 564
 						$uid = $file->getOwner();
565 565
 						$gid = $file->getGroup();
566
-						$stat['perm'] = substr((string)decoct($file->getPerms()), -4);
566
+						$stat['perm'] = substr((string) decoct($file->getPerms()), -4);
567 567
 						$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
568 568
 					}
569 569
 					
570 570
 					//logical rights first
571
-					$stat['read'] = ($linkreadable || $file->isReadable())? null : false;
572
-					$stat['write'] = $file->isWritable()? null : false;
571
+					$stat['read'] = ($linkreadable || $file->isReadable()) ? null : false;
572
+					$stat['write'] = $file->isWritable() ? null : false;
573 573
 					
574 574
 					if (is_null($stat['read'])) {
575 575
 						$stat['size'] = $dir ? 0 : $size;
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 		
586 586
 		if ($cache) {
587 587
 			$cache = $this->convEncOut($cache, false);
588
-			foreach($cache as $d) {
588
+			foreach ($cache as $d) {
589 589
 				$this->updateCache($d[0], $d[1]);
590 590
 			}
591 591
 		}
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	 * @return resource|false
602 602
 	 * @author Dmitry (dio) Levashov
603 603
 	 **/
604
-	protected function _fopen($path, $mode='rb') {
604
+	protected function _fopen($path, $mode = 'rb') {
605 605
 		return @fopen($path, $mode);
606 606
 	}
607 607
 	
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	 * @return bool
613 613
 	 * @author Dmitry (dio) Levashov
614 614
 	 **/
615
-	protected function _fclose($fp, $path='') {
615
+	protected function _fclose($fp, $path = '') {
616 616
 		return @fclose($fp);
617 617
 	}
618 618
 	
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 		$path = $this->_joinPath($dir, $name);
745 745
 
746 746
 		$meta = stream_get_meta_data($fp);
747
-		$uri = isset($meta['uri'])? $meta['uri'] : '';
747
+		$uri = isset($meta['uri']) ? $meta['uri'] : '';
748 748
 		if ($uri && @is_file($uri)) {
749 749
 			fclose($fp);
750 750
 			$isCmdPaste = ($this->ARGS['cmd'] === 'paste');
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 	 * @return bool
809 809
 	 **/
810 810
 	protected function _chmod($path, $mode) {
811
-		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode));
811
+		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode));
812 812
 		$ret = @chmod($path, $modeOct);
813 813
 		$ret && clearstatcache();
814 814
 		return  $ret;
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 				$src = $dir;
927 927
 				$name = basename($path);
928 928
 				if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
929
-					$name = substr($name, 0,  strlen($name)-strlen($m[0]));
929
+					$name = substr($name, 0, strlen($name) - strlen($m[0]));
930 930
 				}
931 931
 				$test = dirname($path).DIRECTORY_SEPARATOR.$name;
932 932
 				if (file_exists($test) || is_link($test)) {
@@ -935,9 +935,9 @@  discard block
 block discarded – undo
935 935
 			}
936 936
 			
937 937
 			if ($name !== '') {
938
-				$result  = dirname($path).DIRECTORY_SEPARATOR.$name;
938
+				$result = dirname($path).DIRECTORY_SEPARATOR.$name;
939 939
 
940
-				if (! @rename($src, $result)) {
940
+				if (!@rename($src, $result)) {
941 941
 					$this->delTree($dir);
942 942
 					return false;
943 943
 				}
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 				$dstDir = dirname($path);
946 946
 				$res = false;
947 947
 				$result = array();
948
-				foreach($ls as $name) {
948
+				foreach ($ls as $name) {
949 949
 					$target = $dstDir.DIRECTORY_SEPARATOR.$name;
950 950
 					if (is_dir($target)) {
951 951
 						$this->delTree($target);
@@ -1037,10 +1037,10 @@  discard block
 block discarded – undo
1037 1037
 		
1038 1038
 		$path = strtr($path, $escaper);
1039 1039
 		$_q = strtr($q, $escaper);
1040
-		$dirs = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR);
1041
-		$match = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'.$_q.'*', GLOB_NOSORT);
1040
+		$dirs = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR);
1041
+		$match = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'.$_q.'*', GLOB_NOSORT);
1042 1042
 		if ($match) {
1043
-			foreach($match as $p) {
1043
+			foreach ($match as $p) {
1044 1044
 				$stat = $this->stat($p);
1045 1045
 		
1046 1046
 				if (!$stat) { // invalid links
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
 					$stat['path'] = $this->path($stat['hash']);
1058 1058
 					if ($this->URL && !isset($stat['url'])) {
1059 1059
 						$path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1));
1060
-						$stat['url'] = $this->URL . $path;
1060
+						$stat['url'] = $this->URL.$path;
1061 1061
 					}
1062 1062
 		
1063 1063
 					$result[] = $stat;
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 			}
1066 1066
 		}
1067 1067
 		if ($dirs) {
1068
-			foreach($dirs as $dir) {
1068
+			foreach ($dirs as $dir) {
1069 1069
 				$stat = $this->stat($dir);
1070 1070
 				if ($stat['read'] && !isset($stat['alias'])) {
1071 1071
 					@set_time_limit(30);
Please login to merge, or discard this patch.