Completed
Push — 2.x ( 69ba55...9c0595 )
by Naoki
03:19
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
 			}
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 		$this->sessionCloseEarlier && $args['sessionCloseEarlier'] && session_id() && session_write_close();
551 551
 		unset($this->sessionCloseEarlier);
552 552
 		
553
-		if (substr(PHP_OS,0,3) === 'WIN') {
553
+		if (substr(PHP_OS, 0, 3) === 'WIN') {
554 554
 			// set time out
555 555
 			if (($_max_execution_time = ini_get('max_execution_time')) && $_max_execution_time < 300) {
556 556
 				@set_time_limit(300);
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 		// call handlers for this command
570 570
 		if (!empty($this->listeners[$cmd])) {
571 571
 			foreach ($this->listeners[$cmd] as $handler) {
572
-				if (call_user_func_array($handler,array($cmd,&$result,$args,$this))) {
572
+				if (call_user_func_array($handler, array($cmd, &$result, $args, $this))) {
573 573
 					// handler return true to force sync client after command completed
574 574
 					$result['sync'] = true;
575 575
 				}
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 	 * @return string
629 629
 	 * @author Dmitry (dio) Levashov
630 630
 	 **/
631
-	public function realpath($hash)	{
631
+	public function realpath($hash) {
632 632
 		if (($volume = $this->volume($hash)) == false) {
633 633
 			return false;
634 634
 		}
@@ -684,11 +684,11 @@  discard block
 block discarded – undo
684 684
 	 */
685 685
 	protected function getPluginInstance($name, $opts = array()) {
686 686
 		$key = strtolower($name);
687
-		if (! isset($this->plugins[$key])) {
688
-			$p_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'plugin.php';
687
+		if (!isset($this->plugins[$key])) {
688
+			$p_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.'plugin.php';
689 689
 			if (is_file($p_file)) {
690 690
 				require_once $p_file;
691
-				$class = 'elFinderPlugin' . $name;
691
+				$class = 'elFinderPlugin'.$name;
692 692
 				$this->plugins[$key] = new $class($opts);
693 693
 			} else {
694 694
 				$this->plugins[$key] = false;
@@ -780,8 +780,8 @@  discard block
 block discarded – undo
780 780
 		
781 781
 		$netVolumes = $this->getNetVolumes();
782 782
 		if ($volume->mount($options)) {
783
-			if (! $key = @ $volume->netMountKey) {
784
-				$key = md5($protocol . '-' . join('-', $options));
783
+			if (!$key = @ $volume->netMountKey) {
784
+				$key = md5($protocol.'-'.join('-', $options));
785 785
 			}
786 786
 			$options['driver'] = $driver;
787 787
 			$options['netkey'] = $key;
@@ -980,24 +980,24 @@  discard block
 block discarded – undo
980 980
 		}
981 981
 
982 982
 		// allow change MIME type by 'file.pre' callback functions
983
-		$mime = isset($args['mime'])? $args['mime'] : $file['mime'];
983
+		$mime = isset($args['mime']) ? $args['mime'] : $file['mime'];
984 984
 		if ($download) {
985 985
 			$disp = 'attachment';
986 986
 		} else {
987 987
 			$dispInlineRegex = $volume->getOption('dispInlineRegex');
988 988
 			$inlineRegex = false;
989 989
 			if ($dispInlineRegex) {
990
-				$inlineRegex = '#' . str_replace('#', '\\#', $dispInlineRegex) . '#';
990
+				$inlineRegex = '#'.str_replace('#', '\\#', $dispInlineRegex).'#';
991 991
 				try {
992 992
 					preg_match($inlineRegex, '');
993
-				} catch(Exception $e) {
993
+				} catch (Exception $e) {
994 994
 					$inlineRegex = false;
995 995
 				}
996 996
 			}
997 997
 			if (!$inlineRegex) {
998 998
 				$inlineRegex = '#^(?:(?:image|text)|application/x-shockwave-flash$)#';
999 999
 			}
1000
-			$disp  = preg_match($inlineRegex, $mime)? 'inline' : 'attachment';
1000
+			$disp = preg_match($inlineRegex, $mime) ? 'inline' : 'attachment';
1001 1001
 		}
1002 1002
 		
1003 1003
 		$filenameEncoded = rawurlencode($file['name']);
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 		$name   = $args['name'];
1107 1107
 		
1108 1108
 		if (($volume = $this->volume($target)) == false
1109
-		||  ($rm  = $volume->file($target)) == false) {
1109
+		||  ($rm = $volume->file($target)) == false) {
1110 1110
 			return array('error' => $this->error(self::ERROR_RENAME, '#'.$target, self::ERROR_FILE_NOT_FOUND));
1111 1111
 		}
1112 1112
 		$rm['realpath'] = $volume->realpath($target);
@@ -1184,9 +1184,9 @@  discard block
 block discarded – undo
1184 1184
 	* @retval false  error
1185 1185
 	* @author Naoki Sawada
1186 1186
 	**/
1187
-	protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) {
1188
-		$method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; 
1189
-		return $this->$method( $url, $timeout, $redirect_max, $ua, $fp );
1187
+	protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) {
1188
+		$method = (function_exists('curl_exec') && !ini_get('safe_mode')) ? 'curl_get_contents' : 'fsock_get_contents'; 
1189
+		return $this->$method($url, $timeout, $redirect_max, $ua, $fp);
1190 1190
 	}
1191 1191
 	
1192 1192
 	/**
@@ -1202,26 +1202,26 @@  discard block
 block discarded – undo
1202 1202
 	 * @retval false  error
1203 1203
 	 * @author Naoki Sawada
1204 1204
 	 **/
1205
-	 protected function curl_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ){
1205
+	 protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1206 1206
 		$ch = curl_init();
1207
-		curl_setopt( $ch, CURLOPT_URL, $url );
1208
-		curl_setopt( $ch, CURLOPT_HEADER, false );
1207
+		curl_setopt($ch, CURLOPT_URL, $url);
1208
+		curl_setopt($ch, CURLOPT_HEADER, false);
1209 1209
 		if ($outfp) {
1210
-			curl_setopt( $ch, CURLOPT_FILE, $outfp );
1210
+			curl_setopt($ch, CURLOPT_FILE, $outfp);
1211 1211
 		} else {
1212
-			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
1213
-			curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true );
1214
-		}
1215
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 );
1216
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_TIME, $timeout );
1217
-		curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
1218
-		curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
1219
-		curl_setopt( $ch, CURLOPT_MAXREDIRS, $redirect_max);
1220
-		curl_setopt( $ch, CURLOPT_USERAGENT, $ua);
1221
-		$result = curl_exec( $ch );
1212
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1213
+			curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
1214
+		}
1215
+		curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1);
1216
+		curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout);
1217
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1218
+		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
1219
+		curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max);
1220
+		curl_setopt($ch, CURLOPT_USERAGENT, $ua);
1221
+		$result = curl_exec($ch);
1222 1222
 		$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
1223
-		curl_close( $ch );
1224
-		return $outfp? $outfp : $result;
1223
+		curl_close($ch);
1224
+		return $outfp ? $outfp : $result;
1225 1225
 	}
1226 1226
 	
1227 1227
 	/**
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
 	 * @retval false  error
1238 1238
 	 * @author Naoki Sawada
1239 1239
 	 */
1240
-	protected function fsock_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ) {
1240
+	protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1241 1241
 
1242 1242
 		$connect_timeout = 3;
1243 1243
 		$connect_try = 3;
@@ -1248,7 +1248,7 @@  discard block
 block discarded – undo
1248 1248
 		$headers = '';
1249 1249
 		
1250 1250
 		$arr = parse_url($url);
1251
-		if (!$arr){
1251
+		if (!$arr) {
1252 1252
 			// Bad request
1253 1253
 			return false;
1254 1254
 		}
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
 		// query
1257 1257
 		$arr['query'] = isset($arr['query']) ? '?'.$arr['query'] : '';
1258 1258
 		// port
1259
-		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https'])? 443 : 80);
1259
+		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https']) ? 443 : 80);
1260 1260
 		
1261 1261
 		$url_base = $arr['scheme'].'://'.$arr['host'].':'.$arr['port'];
1262 1262
 		$url_path = isset($arr['path']) ? $arr['path'] : '/';
@@ -1265,21 +1265,21 @@  discard block
 block discarded – undo
1265 1265
 		$query = $method.' '.$uri." HTTP/1.0\r\n";
1266 1266
 		$query .= "Host: ".$arr['host']."\r\n";
1267 1267
 		if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n";
1268
-		if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n";
1268
+		if (!is_null($getSize)) $query .= 'Range: bytes=0-'.($getSize - 1)."\r\n";
1269 1269
 		
1270 1270
 		$query .= $headers;
1271 1271
 
1272 1272
 		$query .= "\r\n";
1273 1273
 
1274 1274
 		$fp = $connect_try_count = 0;
1275
-		while( !$fp && $connect_try_count < $connect_try ) {
1275
+		while (!$fp && $connect_try_count < $connect_try) {
1276 1276
 	
1277 1277
 			$errno = 0;
1278 1278
 			$errstr = "";
1279 1279
 			$fp = @ fsockopen(
1280 1280
 			$arr['https'].$arr['host'],
1281 1281
 			$arr['port'],
1282
-			$errno,$errstr,$connect_timeout);
1282
+			$errno, $errstr, $connect_timeout);
1283 1283
 			if ($fp) break;
1284 1284
 			$connect_try_count++;
1285 1285
 			if (connection_aborted()) {
@@ -1304,13 +1304,13 @@  discard block
 block discarded – undo
1304 1304
 		
1305 1305
 		$_response = '';
1306 1306
 		$header = '';
1307
-		while($_response !== "\r\n"){
1307
+		while ($_response !== "\r\n") {
1308 1308
 			$_response = fgets($fp, $readsize);
1309 1309
 			$header .= $_response;
1310 1310
 		};
1311 1311
 		
1312
-		$rccd = array_pad(explode(' ',$header,3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1313
-		$rc = (int)$rccd[1];
1312
+		$rccd = array_pad(explode(' ', $header, 3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1313
+		$rc = (int) $rccd[1];
1314 1314
 		
1315 1315
 		// Redirect
1316 1316
 		switch ($rc) {
@@ -1319,19 +1319,19 @@  discard block
 block discarded – undo
1319 1319
 			case 302: // Moved Temporarily
1320 1320
 			case 301: // Moved Permanently
1321 1321
 				$matches = array();
1322
-				if (preg_match('/^Location: (.+?)(#.+)?$/im',$header,$matches) && --$redirect_max > 0) {
1322
+				if (preg_match('/^Location: (.+?)(#.+)?$/im', $header, $matches) && --$redirect_max > 0) {
1323 1323
 					$url = trim($matches[1]);
1324
-					$hash = isset($matches[2])? trim($matches[2]) : '';
1325
-					if (!preg_match('/^https?:\//',$url)) { // no scheme
1324
+					$hash = isset($matches[2]) ? trim($matches[2]) : '';
1325
+					if (!preg_match('/^https?:\//', $url)) { // no scheme
1326 1326
 						if ($url{0} != '/') { // Relative path
1327 1327
 							// to Absolute path
1328
-							$url = substr($url_path,0,strrpos($url_path,'/')).'/'.$url;
1328
+							$url = substr($url_path, 0, strrpos($url_path, '/')).'/'.$url;
1329 1329
 						}
1330 1330
 						// add sheme,host
1331 1331
 						$url = $url_base.$url;
1332 1332
 					}
1333 1333
 					fclose($fp);
1334
-					return $this->fsock_get_contents( $url, $timeout, $redirect_max, $ua, $outfp );
1334
+					return $this->fsock_get_contents($url, $timeout, $redirect_max, $ua, $outfp);
1335 1335
 				}
1336 1336
 		}
1337 1337
 		
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
 			$outfp = fopen('php://temp', 'rwb');
1341 1341
 			$body = true;
1342 1342
 		}
1343
-		while(fwrite($outfp, fread($fp, $readsize))) {
1343
+		while (fwrite($outfp, fread($fp, $readsize))) {
1344 1344
 			if ($timeout) {
1345 1345
 				$_status = socket_get_status($fp);
1346 1346
 				if ($_status['timed_out']) {
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
 		
1360 1360
 		fclose($fp);
1361 1361
 		
1362
-		return $outfp? $outfp : $body; // Data
1362
+		return $outfp ? $outfp : $body; // Data
1363 1363
 	}
1364 1364
 	
1365 1365
 	/**
@@ -1370,13 +1370,13 @@  discard block
 block discarded – undo
1370 1370
 	 * @return array
1371 1371
 	 * @author Naoki Sawada
1372 1372
 	 */
1373
-	protected function parse_data_scheme( $str, $extTable ) {
1373
+	protected function parse_data_scheme($str, $extTable) {
1374 1374
 		$data = $name = '';
1375 1375
 		if ($fp = fopen('data://'.substr($str, 5), 'rb')) {
1376 1376
 			if ($data = stream_get_contents($fp)) {
1377 1377
 				$meta = stream_get_meta_data($fp);
1378
-				$ext = isset($extTable[$meta['mediatype']])? '.' . $extTable[$meta['mediatype']] : '';
1379
-				$name = substr(md5($data), 0, 8) . $ext;
1378
+				$ext = isset($extTable[$meta['mediatype']]) ? '.'.$extTable[$meta['mediatype']] : '';
1379
+				$name = substr(md5($data), 0, 8).$ext;
1380 1380
 			}
1381 1381
 			fclose($fp);
1382 1382
 		}
@@ -1440,7 +1440,7 @@  discard block
 block discarded – undo
1440 1440
 			}
1441 1441
 		}
1442 1442
 		
1443
-		return ($mime && isset($extTable[$mime]))? ('.' . $extTable[$mime]) : '';
1443
+		return ($mime && isset($extTable[$mime])) ? ('.'.$extTable[$mime]) : '';
1444 1444
 	}
1445 1445
 	
1446 1446
 	/**
@@ -1462,12 +1462,12 @@  discard block
 block discarded – undo
1462 1462
 			$testDirs[] = sys_get_temp_dir();
1463 1463
 		}
1464 1464
 		$tempDir = '';
1465
-		foreach($testDirs as $testDir) {
1465
+		foreach ($testDirs as $testDir) {
1466 1466
 			if (!$testDir || !is_dir($testDir)) continue;
1467 1467
 			if (is_writable($testDir)) {
1468 1468
 				$tempDir = $testDir;
1469 1469
 				$gc = time() - 3600;
1470
-				foreach(glob($tempDir . DIRECTORY_SEPARATOR .'ELF*') as $cf) {
1470
+				foreach (glob($tempDir.DIRECTORY_SEPARATOR.'ELF*') as $cf) {
1471 1471
 					if (filemtime($cf) < $gc) {
1472 1472
 						@unlink($cf);
1473 1473
 					}
@@ -1487,7 +1487,7 @@  discard block
 block discarded – undo
1487 1487
 	 **/
1488 1488
 	protected function chmod($args) {
1489 1489
 		$targets = $args['targets'];
1490
-		$mode    = intval((string)$args['mode'], 8);
1490
+		$mode    = intval((string) $args['mode'], 8);
1491 1491
 
1492 1492
 		if (!is_array($targets)) {
1493 1493
 			$targets = array($targets);
@@ -1502,10 +1502,10 @@  discard block
 block discarded – undo
1502 1502
 
1503 1503
 		$files = array();
1504 1504
 		$errors = array();
1505
-		foreach($targets as $target) {
1505
+		foreach ($targets as $target) {
1506 1506
 			$file = $volume->chmod($target, $mode);
1507 1507
 			if ($file) {
1508
-				$files = array_merge($files, is_array($file)? $file : array($file));
1508
+				$files = array_merge($files, is_array($file) ? $file : array($file));
1509 1509
 			} else {
1510 1510
 				$errors = array_merge($errors, $volume->error());
1511 1511
 			}
@@ -1536,26 +1536,26 @@  discard block
 block discarded – undo
1536 1536
 	private function checkChunkedFile($tmpname, $chunk, $cid, $tempDir, $volume = null) {
1537 1537
 		if (preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m)) {
1538 1538
 			$fname = $m[1];
1539
-			$encname = md5($cid . '_' . $fname);
1540
-			$base = $tempDir . DIRECTORY_SEPARATOR . 'ELF' . $encname;
1539
+			$encname = md5($cid.'_'.$fname);
1540
+			$base = $tempDir.DIRECTORY_SEPARATOR.'ELF'.$encname;
1541 1541
 			$clast = intval($m[3]);
1542 1542
 			if (is_null($tmpname)) {
1543 1543
 				ignore_user_abort(true);
1544 1544
 				sleep(10); // wait 10 sec
1545 1545
 				// chunked file upload fail
1546
-				foreach(glob($base . '*') as $cf) {
1546
+				foreach (glob($base.'*') as $cf) {
1547 1547
 					@unlink($cf);
1548 1548
 				}
1549 1549
 				ignore_user_abort(false);
1550 1550
 				return;
1551 1551
 			}
1552 1552
 			
1553
-			$range = isset($_POST['range'])? trim($_POST['range']) : '';
1553
+			$range = isset($_POST['range']) ? trim($_POST['range']) : '';
1554 1554
 			if ($range && preg_match('/^(\d+),(\d+),(\d+)$/', $range, $ranges)) {
1555 1555
 				$start = $ranges[1];
1556 1556
 				$len   = $ranges[2];
1557 1557
 				$size  = $ranges[3];
1558
-				$tmp = $base . '.part';
1558
+				$tmp = $base.'.part';
1559 1559
 				$csize = filesize($tmpname);
1560 1560
 				
1561 1561
 				$tmpExists = is_file($tmp);
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
 				} else {
1582 1582
 					// wait until makeing temp file (for anothor session)
1583 1583
 					$cnt = 1200; // Time limit 120 sec
1584
-					while(!is_file($base) && --$cnt) {
1584
+					while (!is_file($base) && --$cnt) {
1585 1585
 						usleep(100000); // wait 100ms
1586 1586
 					}
1587 1587
 					if (!$cnt) {
@@ -1616,13 +1616,13 @@  discard block
 block discarded – undo
1616 1616
 				}
1617 1617
 			} else {
1618 1618
 				// old way
1619
-				$part = $base . $m[2];
1619
+				$part = $base.$m[2];
1620 1620
 				if (move_uploaded_file($tmpname, $part)) {
1621 1621
 					@chmod($part, 0600);
1622
-					if ($clast < count(glob($base . '*'))) {
1622
+					if ($clast < count(glob($base.'*'))) {
1623 1623
 						$parts = array();
1624 1624
 						for ($i = 0; $i <= $clast; $i++) {
1625
-							$name = $base . '.' . $i . '_' . $clast;
1625
+							$name = $base.'.'.$i.'_'.$clast;
1626 1626
 							if (is_readable($name)) {
1627 1627
 								$parts[] = $name;
1628 1628
 							} else {
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
 								touch($base);
1636 1636
 								if ($resfile = tempnam($tempDir, 'ELF')) {
1637 1637
 									$target = fopen($resfile, 'wb');
1638
-									foreach($parts as $f) {
1638
+									foreach ($parts as $f) {
1639 1639
 										$fp = fopen($f, 'rb');
1640 1640
 										while (!feof($fp)) {
1641 1641
 											fwrite($target, fread($fp, 8192));
@@ -1671,15 +1671,15 @@  discard block
 block discarded – undo
1671 1671
 		$files  = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array();
1672 1672
 		$header = empty($args['html']) ? array() : array('header' => 'Content-Type: text/html; charset=utf-8');
1673 1673
 		$result = array_merge(array('added' => array()), $header);
1674
-		$paths  = $args['upload_path']? $args['upload_path'] : array();
1675
-		$chunk  = $args['chunk']? $args['chunk'] : '';
1676
-		$cid    = $args['cid']? (int)$args['cid'] : '';
1674
+		$paths  = $args['upload_path'] ? $args['upload_path'] : array();
1675
+		$chunk  = $args['chunk'] ? $args['chunk'] : '';
1676
+		$cid    = $args['cid'] ? (int) $args['cid'] : '';
1677 1677
 		
1678
-		$renames= array();
1678
+		$renames = array();
1679 1679
 		$suffix = '~';
1680 1680
 		if ($args['renames'] && is_array($args['renames'])) {
1681 1681
 			$renames = array_flip($args['renames']);
1682
-			if (is_string($args['suffix']) && ! preg_match($ngReg, $args['suffix'])) {
1682
+			if (is_string($args['suffix']) && !preg_match($ngReg, $args['suffix'])) {
1683 1683
 				$suffix = $args['suffix'];
1684 1684
 			}
1685 1685
 		}
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
 			if (!$args['upload'] && $args['name'] && is_array($args['name'])) {
1713 1713
 				$error = '';
1714 1714
 				$result['name'] = array();
1715
-				foreach($args['name'] as $_i => $_name) {
1715
+				foreach ($args['name'] as $_i => $_name) {
1716 1716
 					if (!$volume->isUploadableByName($_name)) {
1717 1717
 						$error = $this->error(self::ERROR_UPLOAD_FILE, $_name, self::ERROR_UPLOAD_FILE_MIME);
1718 1718
 						break;
@@ -1733,7 +1733,7 @@  discard block
 block discarded – undo
1733 1733
 			}
1734 1734
 			if (isset($args['upload']) && is_array($args['upload']) && ($tempDir = $this->getTempDir($volume->getTempPath()))) {
1735 1735
 				$names = array();
1736
-				foreach($args['upload'] as $i => $url) {
1736
+				foreach ($args['upload'] as $i => $url) {
1737 1737
 					// check chunked file upload commit
1738 1738
 					if ($args['chunk']) {
1739 1739
 						if ($url === 'chunkfail' && $args['mimes'] === 'chunkfail') {
@@ -1743,7 +1743,7 @@  discard block
 block discarded – undo
1743 1743
 							}
1744 1744
 							return $result;
1745 1745
 						} else {
1746
-							$tmpfname = $tempDir . '/' . $args['chunk'];
1746
+							$tmpfname = $tempDir.'/'.$args['chunk'];
1747 1747
 							$files['tmp_name'][$i] = $tmpfname;
1748 1748
 							$files['name'][$i] = $url;
1749 1749
 							$files['error'][$i] = 0;
@@ -1752,7 +1752,7 @@  discard block
 block discarded – undo
1752 1752
 						}
1753 1753
 					}
1754 1754
 					
1755
-					$tmpfname = $tempDir . DIRECTORY_SEPARATOR . 'ELF_FATCH_' . md5($url.microtime(true));
1755
+					$tmpfname = $tempDir.DIRECTORY_SEPARATOR.'ELF_FATCH_'.md5($url.microtime(true));
1756 1756
 					
1757 1757
 					$_name = '';
1758 1758
 					// check is data:
@@ -1788,8 +1788,8 @@  discard block
 block discarded – undo
1788 1788
 								list($_a, $_b) = array_pad(explode('.', $_name, 2), 2, '');
1789 1789
 								if ($_b === '') {
1790 1790
 									if ($_ext) {
1791
-										rename($tmpfname, $tmpfname . $_ext);
1792
-										$tmpfname = $tmpfname . $_ext;
1791
+										rename($tmpfname, $tmpfname.$_ext);
1792
+										$tmpfname = $tmpfname.$_ext;
1793 1793
 									}
1794 1794
 									$_b = $this->detectFileExtension($tmpfname);
1795 1795
 									$_name = $_a.$_b;
@@ -1824,7 +1824,7 @@  discard block
 block discarded – undo
1824 1824
 			}
1825 1825
 			
1826 1826
 			$tmpname = $files['tmp_name'][$i];
1827
-			$path = ($paths && !empty($paths[$i]))? $paths[$i] : '';
1827
+			$path = ($paths && !empty($paths[$i])) ? $paths[$i] : '';
1828 1828
 			if ($name === 'blob') {
1829 1829
 				if ($chunk) {
1830 1830
 					if ($tempDir = $this->getTempDir($volume->getTempPath())) {
@@ -1834,7 +1834,7 @@  discard block
 block discarded – undo
1834 1834
 								preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m);
1835 1835
 								$result['error'] = $this->error(self::ERROR_UPLOAD_FILE, $m[1], $tmpname);
1836 1836
 								$result['_chunkfailure'] = true;
1837
-								$this->uploadDebug = 'Upload error: ' . $tmpname;
1837
+								$this->uploadDebug = 'Upload error: '.$tmpname;
1838 1838
 							} else if ($name) {
1839 1839
 								$result['_chunkmerged'] = basename($tmpname);
1840 1840
 								$result['_name'] = $name;
@@ -1848,14 +1848,14 @@  discard block
 block discarded – undo
1848 1848
 				} else {
1849 1849
 					// for form clipboard with Google Chrome
1850 1850
 					$type = $files['type'][$i];
1851
-					$ext = isset($extTable[$type])? '.' . $extTable[$type] : '';
1852
-					$name = substr(md5(basename($tmpname)), 0, 8) . $ext;
1851
+					$ext = isset($extTable[$type]) ? '.'.$extTable[$type] : '';
1852
+					$name = substr(md5(basename($tmpname)), 0, 8).$ext;
1853 1853
 				}
1854 1854
 			}
1855 1855
 			
1856 1856
 			// do hook function 'upload.presave'
1857
-			if (! empty($this->listeners['upload.presave'])) {
1858
-				foreach($this->listeners['upload.presave'] as $handler) {
1857
+			if (!empty($this->listeners['upload.presave'])) {
1858
+				foreach ($this->listeners['upload.presave'] as $handler) {
1859 1859
 					call_user_func_array($handler, array(&$path, &$name, $tmpname, $this, $volume));
1860 1860
 				}
1861 1861
 			}
@@ -1863,7 +1863,7 @@  discard block
 block discarded – undo
1863 1863
 			if (($fp = fopen($tmpname, 'rb')) == false) {
1864 1864
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER);
1865 1865
 				$this->uploadDebug = 'Upload error: unable open tmp file';
1866
-				if (! is_uploaded_file($tmpname)) {
1866
+				if (!is_uploaded_file($tmpname)) {
1867 1867
 					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]);
1868 1868
 					continue;
1869 1869
 				}
@@ -1885,18 +1885,18 @@  discard block
 block discarded – undo
1885 1885
 					}
1886 1886
 				}
1887 1887
 			}
1888
-			if (! $_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1888
+			if (!$_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1889 1889
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error());
1890 1890
 				fclose($fp);
1891
-				if (! is_uploaded_file($tmpname)) {
1892
-					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);;
1891
+				if (!is_uploaded_file($tmpname)) {
1892
+					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]); ;
1893 1893
 					continue;
1894 1894
 				}
1895 1895
 				break;
1896 1896
 			}
1897 1897
 			
1898 1898
 			is_resource($fp) && fclose($fp);
1899
-			if (! is_uploaded_file($tmpname)){
1899
+			if (!is_uploaded_file($tmpname)) {
1900 1900
 				clearstatcache();
1901 1901
 				if (!is_file($tmpname) || @ unlink($tmpname)) {
1902 1902
 					unset($GLOBALS['elFinderTempFiles'][$tmpname]);
@@ -1908,7 +1908,7 @@  discard block
 block discarded – undo
1908 1908
 			}
1909 1909
 		}
1910 1910
 		if ($GLOBALS['elFinderTempFiles']) {
1911
-			foreach(array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1911
+			foreach (array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1912 1912
 				@ unlink($_temp);
1913 1913
 			}
1914 1914
 		}
@@ -1945,7 +1945,7 @@  discard block
 block discarded – undo
1945 1945
 		$suffix = '~';
1946 1946
 		if (!empty($args['renames'])) {
1947 1947
 			$renames = array_flip($args['renames']);
1948
-			if (is_string($args['suffix']) && ! preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1948
+			if (is_string($args['suffix']) && !preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1949 1949
 				$suffix = $args['suffix'];
1950 1950
 			}
1951 1951
 		}
@@ -2003,9 +2003,9 @@  discard block
 block discarded – undo
2003 2003
 		}
2004 2004
 		
2005 2005
 		if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
2006
-			$mime = isset($file['mime'])? $file['mime'] : '';
2006
+			$mime = isset($file['mime']) ? $file['mime'] : '';
2007 2007
 			if ($mime && strtolower(substr($mime, 0, 4)) === 'text') {
2008
-				if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) {
2008
+				if ($enc = mb_detect_encoding($content, mb_detect_order(), true)) {
2009 2009
 					if (strtolower($enc) !== 'utf-8') {
2010 2010
 						$content = mb_convert_encoding($content, 'UTF-8', $enc);
2011 2011
 					}
@@ -2017,7 +2017,7 @@  discard block
 block discarded – undo
2017 2017
 
2018 2018
 		if ($json === false || strlen($json) < strlen($content)) {
2019 2019
 			if ($args['conv']) {
2020
-				return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
2020
+				return array('error' => $this->error(self::ERROR_CONV_UTF8, self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
2021 2021
 			} else {
2022 2022
 				return array('doconv' => true);
2023 2023
 			}
@@ -2059,7 +2059,7 @@  discard block
 block discarded – undo
2059 2059
 		$target = $args['target'];
2060 2060
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2061 2061
 		$error  = array(self::ERROR_EXTRACT, '#'.$target);
2062
-		$makedir = isset($args['makedir'])? (bool)$args['makedir'] : null;
2062
+		$makedir = isset($args['makedir']) ? (bool) $args['makedir'] : null;
2063 2063
 
2064 2064
 		if (($volume = $this->volume($target)) == false
2065 2065
 		|| ($file = $volume->file($target)) == false) {
@@ -2067,7 +2067,7 @@  discard block
 block discarded – undo
2067 2067
 		}  
2068 2068
 
2069 2069
 		return ($file = $volume->extract($target, $makedir))
2070
-			? array('added' => isset($file['read'])? array($file) : $file)
2070
+			? array('added' => isset($file['read']) ? array($file) : $file)
2071 2071
 			: array('error' => $this->error(self::ERROR_EXTRACT, $volume->path($target), $volume->error()));
2072 2072
 	}
2073 2073
 	
@@ -2082,7 +2082,7 @@  discard block
 block discarded – undo
2082 2082
 	protected function archive($args) {
2083 2083
 		$type    = $args['type'];
2084 2084
 		$targets = isset($args['targets']) && is_array($args['targets']) ? $args['targets'] : array();
2085
-		$name    = isset($args['name'])? $args['name'] : '';
2085
+		$name    = isset($args['name']) ? $args['name'] : '';
2086 2086
 	
2087 2087
 		if (($volume = $this->volume($targets[0])) == false) {
2088 2088
 			return $this->error(self::ERROR_ARCHIVE, self::ERROR_TRGDIR_NOT_FOUND);
@@ -2103,7 +2103,7 @@  discard block
 block discarded – undo
2103 2103
 	protected function search($args) {
2104 2104
 		$q      = trim($args['q']);
2105 2105
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2106
-		$target = !empty($args['target'])? $args['target'] : null;
2106
+		$target = !empty($args['target']) ? $args['target'] : null;
2107 2107
 		$result = array();
2108 2108
 
2109 2109
 		if (!is_null($target)) {
@@ -2167,11 +2167,11 @@  discard block
 block discarded – undo
2167 2167
 		$target = $args['target'];
2168 2168
 		$width  = $args['width'];
2169 2169
 		$height = $args['height'];
2170
-		$x      = (int)$args['x'];
2171
-		$y      = (int)$args['y'];
2170
+		$x      = (int) $args['x'];
2171
+		$y      = (int) $args['y'];
2172 2172
 		$mode   = $args['mode'];
2173 2173
 		$bg     = null;
2174
-		$degree = (int)$args['degree'];
2174
+		$degree = (int) $args['degree'];
2175 2175
 		
2176 2176
 		if (($volume = $this->volume($target)) == false
2177 2177
 		|| ($file = $volume->file($target)) == false) {
@@ -2192,7 +2192,7 @@  discard block
 block discarded – undo
2192 2192
 	**/
2193 2193
 	protected function url($args) {
2194 2194
 		$target = $args['target'];
2195
-		$options = isset($args['options'])? $args['options'] : array();
2195
+		$options = isset($args['options']) ? $args['options'] : array();
2196 2196
 		if (($volume = $this->volume($target)) != false) {
2197 2197
 			$url = $volume->getContentUrl($target, $options);
2198 2198
 			return $url ? array('url' => $url) : array();
@@ -2209,18 +2209,18 @@  discard block
 block discarded – undo
2209 2209
 	 */
2210 2210
 	protected function callback($args) {
2211 2211
 		$checkReg = '/[^a-zA-Z0-9;._-]/';
2212
-		$node = (isset($args['node']) && !preg_match($checkReg, $args['node']))? $args['node'] : '';
2213
-		$json = (isset($args['json']) && @json_decode($args['json']))? $args['json'] : '{}';
2214
-		$bind  = (isset($args['bind']) && !preg_match($checkReg, $args['bind']))? $args['bind'] : '';
2212
+		$node = (isset($args['node']) && !preg_match($checkReg, $args['node'])) ? $args['node'] : '';
2213
+		$json = (isset($args['json']) && @json_decode($args['json'])) ? $args['json'] : '{}';
2214
+		$bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind'])) ? $args['bind'] : '';
2215 2215
 		$done = (!empty($args['done']));
2216 2216
 		
2217
-		while( ob_get_level() ) {
2218
-			if (! ob_end_clean()) {
2217
+		while (ob_get_level()) {
2218
+			if (!ob_end_clean()) {
2219 2219
 				break;
2220 2220
 			}
2221 2221
 		}
2222 2222
 		
2223
-		if ($done || ! $this->callbackWindowURL) {
2223
+		if ($done || !$this->callbackWindowURL) {
2224 2224
 			$script = '';
2225 2225
 			if ($node) {
2226 2226
 				$script .= '
@@ -2262,13 +2262,13 @@  discard block
 block discarded – undo
2262 2262
 			
2263 2263
 		} else {
2264 2264
 			$url = $this->callbackWindowURL;
2265
-			$url .= ((strpos($url, '?') === false)? '?' : '&')
2266
-				 . '&node=' . rawurlencode($node)
2267
-				 . (($json !== '{}')? ('&json=' . rawurlencode($json)) : '')
2268
-				 . ($bind? ('&bind=' .  rawurlencode($bind)) : '')
2265
+			$url .= ((strpos($url, '?') === false) ? '?' : '&')
2266
+				 . '&node='.rawurlencode($node)
2267
+				 . (($json !== '{}') ? ('&json='.rawurlencode($json)) : '')
2268
+				 . ($bind ? ('&bind='.rawurlencode($bind)) : '')
2269 2269
 				 . '&done=1';
2270 2270
 			
2271
-			header('Location: ' . $url);
2271
+			header('Location: '.$url);
2272 2272
 			
2273 2273
 		}
2274 2274
 		exit();
@@ -2338,7 +2338,7 @@  discard block
 block discarded – undo
2338 2338
 	
2339 2339
 	protected function utime() {
2340 2340
 		$time = explode(" ", microtime());
2341
-		return (double)$time[1] + (double)$time[0];
2341
+		return (double) $time[1] + (double) $time[0];
2342 2342
 	}
2343 2343
 	
2344 2344
 	
@@ -2364,7 +2364,7 @@  discard block
 block discarded – undo
2364 2364
 		$imgcnt = 0;
2365 2365
 		$fp = fopen($path, 'rb');
2366 2366
 		@fread($fp, 4);
2367
-		$c = @fread($fp,1);
2367
+		$c = @fread($fp, 1);
2368 2368
 		if (ord($c) != 0x39) {  // GIF89a
2369 2369
 			return false;
2370 2370
 		}
@@ -2372,13 +2372,13 @@  discard block
 block discarded – undo
2372 2372
 		while (!feof($fp)) {
2373 2373
 			do {
2374 2374
 				$c = fread($fp, 1);
2375
-			} while(ord($c) != 0x21 && !feof($fp));
2375
+			} while (ord($c) != 0x21 && !feof($fp));
2376 2376
 	
2377 2377
 			if (feof($fp)) {
2378 2378
 				break;
2379 2379
 			}
2380 2380
 	
2381
-			$c2 = fread($fp,2);
2381
+			$c2 = fread($fp, 2);
2382 2382
 			if (bin2hex($c2) == "f904") {
2383 2383
 				$imgcnt++;
2384 2384
 			}
Please login to merge, or discard this patch.