Completed
Push — 2.x ( 82b028...ec6e0b )
by Naoki
04:23
created
php/elFinder.class.php 1 patch
Spacing   +150 added lines, -150 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;
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
 			$disp = 'attachment';
977 977
 			$mime = $file['mime'];
978 978
 		} else {
979
-			$disp  = preg_match('/^(image|text)/i', $file['mime']) || $file['mime'] == 'application/x-shockwave-flash' 
979
+			$disp = preg_match('/^(image|text)/i', $file['mime']) || $file['mime'] == 'application/x-shockwave-flash' 
980 980
 					? 'inline' 
981 981
 					: 'attachment';
982 982
 			$mime = $file['mime'];
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
 		$name   = $args['name'];
1089 1089
 		
1090 1090
 		if (($volume = $this->volume($target)) == false
1091
-		||  ($rm  = $volume->file($target)) == false) {
1091
+		||  ($rm = $volume->file($target)) == false) {
1092 1092
 			return array('error' => $this->error(self::ERROR_RENAME, '#'.$target, self::ERROR_FILE_NOT_FOUND));
1093 1093
 		}
1094 1094
 		$rm['realpath'] = $volume->realpath($target);
@@ -1166,9 +1166,9 @@  discard block
 block discarded – undo
1166 1166
 	* @retval false  error
1167 1167
 	* @author Naoki Sawada
1168 1168
 	**/
1169
-	protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) {
1170
-		$method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; 
1171
-		return $this->$method( $url, $timeout, $redirect_max, $ua, $fp );
1169
+	protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) {
1170
+		$method = (function_exists('curl_exec') && !ini_get('safe_mode')) ? 'curl_get_contents' : 'fsock_get_contents'; 
1171
+		return $this->$method($url, $timeout, $redirect_max, $ua, $fp);
1172 1172
 	}
1173 1173
 	
1174 1174
 	/**
@@ -1184,26 +1184,26 @@  discard block
 block discarded – undo
1184 1184
 	 * @retval false  error
1185 1185
 	 * @author Naoki Sawada
1186 1186
 	 **/
1187
-	 protected function curl_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ){
1187
+	 protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1188 1188
 		$ch = curl_init();
1189
-		curl_setopt( $ch, CURLOPT_URL, $url );
1190
-		curl_setopt( $ch, CURLOPT_HEADER, false );
1189
+		curl_setopt($ch, CURLOPT_URL, $url);
1190
+		curl_setopt($ch, CURLOPT_HEADER, false);
1191 1191
 		if ($outfp) {
1192
-			curl_setopt( $ch, CURLOPT_FILE, $outfp );
1192
+			curl_setopt($ch, CURLOPT_FILE, $outfp);
1193 1193
 		} else {
1194
-			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
1195
-			curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true );
1196
-		}
1197
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 );
1198
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_TIME, $timeout );
1199
-		curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
1200
-		curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
1201
-		curl_setopt( $ch, CURLOPT_MAXREDIRS, $redirect_max);
1202
-		curl_setopt( $ch, CURLOPT_USERAGENT, $ua);
1203
-		$result = curl_exec( $ch );
1194
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1195
+			curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
1196
+		}
1197
+		curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1);
1198
+		curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout);
1199
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1200
+		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
1201
+		curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max);
1202
+		curl_setopt($ch, CURLOPT_USERAGENT, $ua);
1203
+		$result = curl_exec($ch);
1204 1204
 		$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
1205
-		curl_close( $ch );
1206
-		return $outfp? $outfp : $result;
1205
+		curl_close($ch);
1206
+		return $outfp ? $outfp : $result;
1207 1207
 	}
1208 1208
 	
1209 1209
 	/**
@@ -1219,7 +1219,7 @@  discard block
 block discarded – undo
1219 1219
 	 * @retval false  error
1220 1220
 	 * @author Naoki Sawada
1221 1221
 	 */
1222
-	protected function fsock_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ) {
1222
+	protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1223 1223
 
1224 1224
 		$connect_timeout = 3;
1225 1225
 		$connect_try = 3;
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 		$headers = '';
1231 1231
 		
1232 1232
 		$arr = parse_url($url);
1233
-		if (!$arr){
1233
+		if (!$arr) {
1234 1234
 			// Bad request
1235 1235
 			return false;
1236 1236
 		}
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
 		// query
1239 1239
 		$arr['query'] = isset($arr['query']) ? '?'.$arr['query'] : '';
1240 1240
 		// port
1241
-		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https'])? 443 : 80);
1241
+		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https']) ? 443 : 80);
1242 1242
 		
1243 1243
 		$url_base = $arr['scheme'].'://'.$arr['host'].':'.$arr['port'];
1244 1244
 		$url_path = isset($arr['path']) ? $arr['path'] : '/';
@@ -1247,21 +1247,21 @@  discard block
 block discarded – undo
1247 1247
 		$query = $method.' '.$uri." HTTP/1.0\r\n";
1248 1248
 		$query .= "Host: ".$arr['host']."\r\n";
1249 1249
 		if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n";
1250
-		if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n";
1250
+		if (!is_null($getSize)) $query .= 'Range: bytes=0-'.($getSize - 1)."\r\n";
1251 1251
 		
1252 1252
 		$query .= $headers;
1253 1253
 
1254 1254
 		$query .= "\r\n";
1255 1255
 
1256 1256
 		$fp = $connect_try_count = 0;
1257
-		while( !$fp && $connect_try_count < $connect_try ) {
1257
+		while (!$fp && $connect_try_count < $connect_try) {
1258 1258
 	
1259 1259
 			$errno = 0;
1260 1260
 			$errstr = "";
1261 1261
 			$fp = @ fsockopen(
1262 1262
 			$arr['https'].$arr['host'],
1263 1263
 			$arr['port'],
1264
-			$errno,$errstr,$connect_timeout);
1264
+			$errno, $errstr, $connect_timeout);
1265 1265
 			if ($fp) break;
1266 1266
 			$connect_try_count++;
1267 1267
 			if (connection_aborted()) {
@@ -1286,13 +1286,13 @@  discard block
 block discarded – undo
1286 1286
 		
1287 1287
 		$_response = '';
1288 1288
 		$header = '';
1289
-		while($_response !== "\r\n"){
1289
+		while ($_response !== "\r\n") {
1290 1290
 			$_response = fgets($fp, $readsize);
1291 1291
 			$header .= $_response;
1292 1292
 		};
1293 1293
 		
1294
-		$rccd = array_pad(explode(' ',$header,3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1295
-		$rc = (int)$rccd[1];
1294
+		$rccd = array_pad(explode(' ', $header, 3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1295
+		$rc = (int) $rccd[1];
1296 1296
 		
1297 1297
 		// Redirect
1298 1298
 		switch ($rc) {
@@ -1301,19 +1301,19 @@  discard block
 block discarded – undo
1301 1301
 			case 302: // Moved Temporarily
1302 1302
 			case 301: // Moved Permanently
1303 1303
 				$matches = array();
1304
-				if (preg_match('/^Location: (.+?)(#.+)?$/im',$header,$matches) && --$redirect_max > 0) {
1304
+				if (preg_match('/^Location: (.+?)(#.+)?$/im', $header, $matches) && --$redirect_max > 0) {
1305 1305
 					$url = trim($matches[1]);
1306
-					$hash = isset($matches[2])? trim($matches[2]) : '';
1307
-					if (!preg_match('/^https?:\//',$url)) { // no scheme
1306
+					$hash = isset($matches[2]) ? trim($matches[2]) : '';
1307
+					if (!preg_match('/^https?:\//', $url)) { // no scheme
1308 1308
 						if ($url{0} != '/') { // Relative path
1309 1309
 							// to Absolute path
1310
-							$url = substr($url_path,0,strrpos($url_path,'/')).'/'.$url;
1310
+							$url = substr($url_path, 0, strrpos($url_path, '/')).'/'.$url;
1311 1311
 						}
1312 1312
 						// add sheme,host
1313 1313
 						$url = $url_base.$url;
1314 1314
 					}
1315 1315
 					fclose($fp);
1316
-					return $this->fsock_get_contents( $url, $timeout, $redirect_max, $ua, $outfp );
1316
+					return $this->fsock_get_contents($url, $timeout, $redirect_max, $ua, $outfp);
1317 1317
 				}
1318 1318
 		}
1319 1319
 		
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
 			$outfp = fopen('php://temp', 'rwb');
1323 1323
 			$body = true;
1324 1324
 		}
1325
-		while(fwrite($outfp, fread($fp, $readsize))) {
1325
+		while (fwrite($outfp, fread($fp, $readsize))) {
1326 1326
 			if ($timeout) {
1327 1327
 				$_status = socket_get_status($fp);
1328 1328
 				if ($_status['timed_out']) {
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
 		
1342 1342
 		fclose($fp);
1343 1343
 		
1344
-		return $outfp? $outfp : $body; // Data
1344
+		return $outfp ? $outfp : $body; // Data
1345 1345
 	}
1346 1346
 	
1347 1347
 	/**
@@ -1352,13 +1352,13 @@  discard block
 block discarded – undo
1352 1352
 	 * @return array
1353 1353
 	 * @author Naoki Sawada
1354 1354
 	 */
1355
-	protected function parse_data_scheme( $str, $extTable ) {
1355
+	protected function parse_data_scheme($str, $extTable) {
1356 1356
 		$data = $name = '';
1357 1357
 		if ($fp = fopen('data://'.substr($str, 5), 'rb')) {
1358 1358
 			if ($data = stream_get_contents($fp)) {
1359 1359
 				$meta = stream_get_meta_data($fp);
1360
-				$ext = isset($extTable[$meta['mediatype']])? '.' . $extTable[$meta['mediatype']] : '';
1361
-				$name = substr(md5($data), 0, 8) . $ext;
1360
+				$ext = isset($extTable[$meta['mediatype']]) ? '.'.$extTable[$meta['mediatype']] : '';
1361
+				$name = substr(md5($data), 0, 8).$ext;
1362 1362
 			}
1363 1363
 			fclose($fp);
1364 1364
 		}
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
 			}
1423 1423
 		}
1424 1424
 		
1425
-		return ($mime && isset($extTable[$mime]))? ('.' . $extTable[$mime]) : '';
1425
+		return ($mime && isset($extTable[$mime])) ? ('.'.$extTable[$mime]) : '';
1426 1426
 	}
1427 1427
 	
1428 1428
 	/**
@@ -1438,26 +1438,26 @@  discard block
 block discarded – undo
1438 1438
 	private function checkChunkedFile($tmpname, $chunk, $cid, $tempDir, $volume = null) {
1439 1439
 		if (preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m)) {
1440 1440
 			$fname = $m[1];
1441
-			$encname = md5($cid . '_' . $fname);
1442
-			$base = $tempDir . DIRECTORY_SEPARATOR . 'ELF' . $encname;
1441
+			$encname = md5($cid.'_'.$fname);
1442
+			$base = $tempDir.DIRECTORY_SEPARATOR.'ELF'.$encname;
1443 1443
 			$clast = intval($m[3]);
1444 1444
 			if (is_null($tmpname)) {
1445 1445
 				ignore_user_abort(true);
1446 1446
 				sleep(10); // wait 10 sec
1447 1447
 				// chunked file upload fail
1448
-				foreach(glob($base . '*') as $cf) {
1448
+				foreach (glob($base.'*') as $cf) {
1449 1449
 					@unlink($cf);
1450 1450
 				}
1451 1451
 				ignore_user_abort(false);
1452 1452
 				return;
1453 1453
 			}
1454 1454
 			
1455
-			$range = isset($_POST['range'])? trim($_POST['range']) : '';
1455
+			$range = isset($_POST['range']) ? trim($_POST['range']) : '';
1456 1456
 			if ($range && preg_match('/^(\d+),(\d+),(\d+)$/', $range, $ranges)) {
1457 1457
 				$start = $ranges[1];
1458 1458
 				$len   = $ranges[2];
1459 1459
 				$size  = $ranges[3];
1460
-				$tmp = $base . '.part';
1460
+				$tmp = $base.'.part';
1461 1461
 				$csize = filesize($tmpname);
1462 1462
 				
1463 1463
 				$tmpExists = is_file($tmp);
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
 				} else {
1483 1483
 					// wait until makeing temp file (for anothor session)
1484 1484
 					$cnt = 100; // Time limit 10 sec
1485
-					while(!is_file($base) && --$cnt) {
1485
+					while (!is_file($base) && --$cnt) {
1486 1486
 						usleep(100000); // wait 100ms
1487 1487
 					}
1488 1488
 					if (!$cnt) {
@@ -1517,13 +1517,13 @@  discard block
 block discarded – undo
1517 1517
 				}
1518 1518
 			} else {
1519 1519
 				// old way
1520
-				$part = $base . $m[2];
1520
+				$part = $base.$m[2];
1521 1521
 				if (move_uploaded_file($tmpname, $part)) {
1522 1522
 					@chmod($part, 0600);
1523
-					if ($clast < count(glob($base . '*'))) {
1523
+					if ($clast < count(glob($base.'*'))) {
1524 1524
 						$parts = array();
1525 1525
 						for ($i = 0; $i <= $clast; $i++) {
1526
-							$name = $base . '.' . $i . '_' . $clast;
1526
+							$name = $base.'.'.$i.'_'.$clast;
1527 1527
 							if (is_readable($name)) {
1528 1528
 								$parts[] = $name;
1529 1529
 							} else {
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
 								touch($base);
1537 1537
 								if ($resfile = tempnam($tempDir, 'ELF')) {
1538 1538
 									$target = fopen($resfile, 'wb');
1539
-									foreach($parts as $f) {
1539
+									foreach ($parts as $f) {
1540 1540
 										$fp = fopen($f, 'rb');
1541 1541
 										while (!feof($fp)) {
1542 1542
 											fwrite($target, fread($fp, 8192));
@@ -1577,15 +1577,15 @@  discard block
 block discarded – undo
1577 1577
 			$testDirs[] = rtrim(realpath($volumeTempPath), DIRECTORY_SEPARATOR);
1578 1578
 		}
1579 1579
 		$tempDir = '';
1580
-		$test = DIRECTORY_SEPARATOR . microtime(true);
1581
-		foreach($testDirs as $testDir) {
1580
+		$test = DIRECTORY_SEPARATOR.microtime(true);
1581
+		foreach ($testDirs as $testDir) {
1582 1582
 			if (!$testDir || !is_dir($testDir)) continue;
1583 1583
 			$testFile = $testDir.$test;
1584 1584
 			if (touch($testFile)) {
1585 1585
 				unlink($testFile);
1586 1586
 				$tempDir = $testDir;
1587 1587
 				$gc = time() - 3600;
1588
-				foreach(glob($tempDir . '/ELF*') as $cf) {
1588
+				foreach (glob($tempDir.'/ELF*') as $cf) {
1589 1589
 					if (filemtime($cf) < $gc) {
1590 1590
 						@unlink($cf);
1591 1591
 					}
@@ -1605,7 +1605,7 @@  discard block
 block discarded – undo
1605 1605
 	 **/
1606 1606
 	protected function chmod($args) {
1607 1607
 		$targets = $args['targets'];
1608
-		$mode    = intval((string)$args['mode'], 8);
1608
+		$mode    = intval((string) $args['mode'], 8);
1609 1609
 
1610 1610
 		if (!is_array($targets)) {
1611 1611
 			$targets = array($targets);
@@ -1620,10 +1620,10 @@  discard block
 block discarded – undo
1620 1620
 
1621 1621
 		$files = array();
1622 1622
 		$errors = array();
1623
-		foreach($targets as $target) {
1623
+		foreach ($targets as $target) {
1624 1624
 			$file = $volume->chmod($target, $mode);
1625 1625
 			if ($file) {
1626
-				$files = array_merge($files, is_array($file)? $file : array($file));
1626
+				$files = array_merge($files, is_array($file) ? $file : array($file));
1627 1627
 			} else {
1628 1628
 				$errors = array_merge($errors, $volume->error());
1629 1629
 			}
@@ -1655,15 +1655,15 @@  discard block
 block discarded – undo
1655 1655
 		$files  = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array();
1656 1656
 		$header = empty($args['html']) ? array() : array('header' => 'Content-Type: text/html; charset=utf-8');
1657 1657
 		$result = array_merge(array('added' => array()), $header);
1658
-		$paths  = $args['upload_path']? $args['upload_path'] : array();
1659
-		$chunk  = $args['chunk']? $args['chunk'] : '';
1660
-		$cid    = $args['cid']? (int)$args['cid'] : '';
1658
+		$paths  = $args['upload_path'] ? $args['upload_path'] : array();
1659
+		$chunk  = $args['chunk'] ? $args['chunk'] : '';
1660
+		$cid    = $args['cid'] ? (int) $args['cid'] : '';
1661 1661
 		
1662
-		$renames= array();
1662
+		$renames = array();
1663 1663
 		$suffix = '~';
1664 1664
 		if ($args['renames'] && is_array($args['renames'])) {
1665 1665
 			$renames = array_flip($args['renames']);
1666
-			if (is_string($args['suffix']) && ! preg_match($ngReg, $args['suffix'])) {
1666
+			if (is_string($args['suffix']) && !preg_match($ngReg, $args['suffix'])) {
1667 1667
 				$suffix = $args['suffix'];
1668 1668
 			}
1669 1669
 		}
@@ -1695,14 +1695,14 @@  discard block
 block discarded – undo
1695 1695
 		if (empty($files)) {
1696 1696
 			if (!$args['upload'] && $args['name'] && is_array($args['name'])) {
1697 1697
 				$result['name'] = array();
1698
-				foreach($args['name'] as $_i => $_name) {
1698
+				foreach ($args['name'] as $_i => $_name) {
1699 1699
 					$result['name'][$_i] = preg_replace($ngReg, '_', $_name);
1700 1700
 				}
1701 1701
 				return $result;
1702 1702
 			}
1703 1703
 			if (isset($args['upload']) && is_array($args['upload']) && ($tempDir = $this->getTempDir($volume->getTempPath()))) {
1704 1704
 				$names = array();
1705
-				foreach($args['upload'] as $i => $url) {
1705
+				foreach ($args['upload'] as $i => $url) {
1706 1706
 					// check chunked file upload commit
1707 1707
 					if ($args['chunk']) {
1708 1708
 						if ($url === 'chunkfail' && $args['mimes'] === 'chunkfail') {
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
 							}
1713 1713
 							return $result;
1714 1714
 						} else {
1715
-							$tmpfname = $tempDir . '/' . $args['chunk'];
1715
+							$tmpfname = $tempDir.'/'.$args['chunk'];
1716 1716
 							$files['tmp_name'][$i] = $tmpfname;
1717 1717
 							$files['name'][$i] = $url;
1718 1718
 							$files['error'][$i] = 0;
@@ -1721,7 +1721,7 @@  discard block
 block discarded – undo
1721 1721
 						}
1722 1722
 					}
1723 1723
 					
1724
-					$tmpfname = $tempDir . DIRECTORY_SEPARATOR . 'ELF_FATCH_' . md5($url.microtime(true));
1724
+					$tmpfname = $tempDir.DIRECTORY_SEPARATOR.'ELF_FATCH_'.md5($url.microtime(true));
1725 1725
 					
1726 1726
 					$_name = '';
1727 1727
 					// check is data:
@@ -1757,8 +1757,8 @@  discard block
 block discarded – undo
1757 1757
 								list($_a, $_b) = array_pad(explode('.', $_name, 2), 2, '');
1758 1758
 								if ($_b === '') {
1759 1759
 									if ($_ext) {
1760
-										rename($tmpfname, $tmpfname . $_ext);
1761
-										$tmpfname = $tmpfname . $_ext;
1760
+										rename($tmpfname, $tmpfname.$_ext);
1761
+										$tmpfname = $tmpfname.$_ext;
1762 1762
 									}
1763 1763
 									$_b = $this->detectFileExtension($tmpfname);
1764 1764
 									$_name = $_a.$_b;
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
 			}
1794 1794
 			
1795 1795
 			$tmpname = $files['tmp_name'][$i];
1796
-			$path = ($paths && !empty($paths[$i]))? $paths[$i] : '';
1796
+			$path = ($paths && !empty($paths[$i])) ? $paths[$i] : '';
1797 1797
 			if ($name === 'blob') {
1798 1798
 				if ($chunk) {
1799 1799
 					if ($tempDir = $this->getTempDir($volume->getTempPath())) {
@@ -1803,7 +1803,7 @@  discard block
 block discarded – undo
1803 1803
 								preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m);
1804 1804
 								$result['error'] = $this->error(self::ERROR_UPLOAD_FILE, $m[1], $tmpname);
1805 1805
 								$result['_chunkfailure'] = true;
1806
-								$this->uploadDebug = 'Upload error: ' . $tmpname;
1806
+								$this->uploadDebug = 'Upload error: '.$tmpname;
1807 1807
 							} else if ($name) {
1808 1808
 								$result['_chunkmerged'] = basename($tmpname);
1809 1809
 								$result['_name'] = $name;
@@ -1817,14 +1817,14 @@  discard block
 block discarded – undo
1817 1817
 				} else {
1818 1818
 					// for form clipboard with Google Chrome
1819 1819
 					$type = $files['type'][$i];
1820
-					$ext = isset($extTable[$type])? '.' . $extTable[$type] : '';
1821
-					$name = substr(md5(basename($tmpname)), 0, 8) . $ext;
1820
+					$ext = isset($extTable[$type]) ? '.'.$extTable[$type] : '';
1821
+					$name = substr(md5(basename($tmpname)), 0, 8).$ext;
1822 1822
 				}
1823 1823
 			}
1824 1824
 			
1825 1825
 			// do hook function 'upload.presave'
1826
-			if (! empty($this->listeners['upload.presave'])) {
1827
-				foreach($this->listeners['upload.presave'] as $handler) {
1826
+			if (!empty($this->listeners['upload.presave'])) {
1827
+				foreach ($this->listeners['upload.presave'] as $handler) {
1828 1828
 					call_user_func_array($handler, array(&$path, &$name, $tmpname, $this, $volume));
1829 1829
 				}
1830 1830
 			}
@@ -1832,7 +1832,7 @@  discard block
 block discarded – undo
1832 1832
 			if (($fp = fopen($tmpname, 'rb')) == false) {
1833 1833
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER);
1834 1834
 				$this->uploadDebug = 'Upload error: unable open tmp file';
1835
-				if (! is_uploaded_file($tmpname)) {
1835
+				if (!is_uploaded_file($tmpname)) {
1836 1836
 					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]);
1837 1837
 					continue;
1838 1838
 				}
@@ -1854,18 +1854,18 @@  discard block
 block discarded – undo
1854 1854
 					}
1855 1855
 				}
1856 1856
 			}
1857
-			if (! $_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1857
+			if (!$_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1858 1858
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error());
1859 1859
 				fclose($fp);
1860
-				if (! is_uploaded_file($tmpname)) {
1861
-					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);;
1860
+				if (!is_uploaded_file($tmpname)) {
1861
+					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]); ;
1862 1862
 					continue;
1863 1863
 				}
1864 1864
 				break;
1865 1865
 			}
1866 1866
 			
1867 1867
 			is_resource($fp) && fclose($fp);
1868
-			if (! is_uploaded_file($tmpname)){
1868
+			if (!is_uploaded_file($tmpname)) {
1869 1869
 				clearstatcache();
1870 1870
 				if (!is_file($tmpname) || @ unlink($tmpname)) {
1871 1871
 					unset($GLOBALS['elFinderTempFiles'][$tmpname]);
@@ -1877,7 +1877,7 @@  discard block
 block discarded – undo
1877 1877
 			}
1878 1878
 		}
1879 1879
 		if ($GLOBALS['elFinderTempFiles']) {
1880
-			foreach(array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1880
+			foreach (array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1881 1881
 				@ unlink($_temp);
1882 1882
 			}
1883 1883
 		}
@@ -1914,7 +1914,7 @@  discard block
 block discarded – undo
1914 1914
 		$suffix = '~';
1915 1915
 		if (!empty($args['renames'])) {
1916 1916
 			$renames = array_flip($args['renames']);
1917
-			if (is_string($args['suffix']) && ! preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1917
+			if (is_string($args['suffix']) && !preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1918 1918
 				$suffix = $args['suffix'];
1919 1919
 			}
1920 1920
 		}
@@ -1972,9 +1972,9 @@  discard block
 block discarded – undo
1972 1972
 		}
1973 1973
 		
1974 1974
 		if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
1975
-			$mime = isset($file['mime'])? $file['mime'] : '';
1975
+			$mime = isset($file['mime']) ? $file['mime'] : '';
1976 1976
 			if ($mime && strtolower(substr($mime, 0, 4)) === 'text') {
1977
-				if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) {
1977
+				if ($enc = mb_detect_encoding($content, mb_detect_order(), true)) {
1978 1978
 					if (strtolower($enc) !== 'utf-8') {
1979 1979
 						$content = mb_convert_encoding($content, 'UTF-8', $enc);
1980 1980
 					}
@@ -1986,7 +1986,7 @@  discard block
 block discarded – undo
1986 1986
 
1987 1987
 		if ($json === false || strlen($json) < strlen($content)) {
1988 1988
 			if ($args['conv']) {
1989
-				return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
1989
+				return array('error' => $this->error(self::ERROR_CONV_UTF8, self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
1990 1990
 			} else {
1991 1991
 				return array('doconv' => true);
1992 1992
 			}
@@ -2028,7 +2028,7 @@  discard block
 block discarded – undo
2028 2028
 		$target = $args['target'];
2029 2029
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2030 2030
 		$error  = array(self::ERROR_EXTRACT, '#'.$target);
2031
-		$makedir = isset($args['makedir'])? (bool)$args['makedir'] : null;
2031
+		$makedir = isset($args['makedir']) ? (bool) $args['makedir'] : null;
2032 2032
 
2033 2033
 		if (($volume = $this->volume($target)) == false
2034 2034
 		|| ($file = $volume->file($target)) == false) {
@@ -2036,7 +2036,7 @@  discard block
 block discarded – undo
2036 2036
 		}  
2037 2037
 
2038 2038
 		return ($file = $volume->extract($target, $makedir))
2039
-			? array('added' => isset($file['read'])? array($file) : $file)
2039
+			? array('added' => isset($file['read']) ? array($file) : $file)
2040 2040
 			: array('error' => $this->error(self::ERROR_EXTRACT, $volume->path($target), $volume->error()));
2041 2041
 	}
2042 2042
 	
@@ -2051,7 +2051,7 @@  discard block
 block discarded – undo
2051 2051
 	protected function archive($args) {
2052 2052
 		$type    = $args['type'];
2053 2053
 		$targets = isset($args['targets']) && is_array($args['targets']) ? $args['targets'] : array();
2054
-		$name    = isset($args['name'])? $args['name'] : '';
2054
+		$name    = isset($args['name']) ? $args['name'] : '';
2055 2055
 	
2056 2056
 		if (($volume = $this->volume($targets[0])) == false) {
2057 2057
 			return $this->error(self::ERROR_ARCHIVE, self::ERROR_TRGDIR_NOT_FOUND);
@@ -2072,7 +2072,7 @@  discard block
 block discarded – undo
2072 2072
 	protected function search($args) {
2073 2073
 		$q      = trim($args['q']);
2074 2074
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2075
-		$target = !empty($args['target'])? $args['target'] : null;
2075
+		$target = !empty($args['target']) ? $args['target'] : null;
2076 2076
 		$result = array();
2077 2077
 
2078 2078
 		if (!is_null($target)) {
@@ -2136,11 +2136,11 @@  discard block
 block discarded – undo
2136 2136
 		$target = $args['target'];
2137 2137
 		$width  = $args['width'];
2138 2138
 		$height = $args['height'];
2139
-		$x      = (int)$args['x'];
2140
-		$y      = (int)$args['y'];
2139
+		$x      = (int) $args['x'];
2140
+		$y      = (int) $args['y'];
2141 2141
 		$mode   = $args['mode'];
2142 2142
 		$bg     = null;
2143
-		$degree = (int)$args['degree'];
2143
+		$degree = (int) $args['degree'];
2144 2144
 		
2145 2145
 		if (($volume = $this->volume($target)) == false
2146 2146
 		|| ($file = $volume->file($target)) == false) {
@@ -2161,7 +2161,7 @@  discard block
 block discarded – undo
2161 2161
 	**/
2162 2162
 	protected function url($args) {
2163 2163
 		$target = $args['target'];
2164
-		$options = isset($args['options'])? $args['options'] : array();
2164
+		$options = isset($args['options']) ? $args['options'] : array();
2165 2165
 		if (($volume = $this->volume($target)) != false) {
2166 2166
 			$url = $volume->getContentUrl($target, $options);
2167 2167
 			return $url ? array('url' => $url) : array();
@@ -2178,18 +2178,18 @@  discard block
 block discarded – undo
2178 2178
 	 */
2179 2179
 	protected function callback($args) {
2180 2180
 		$checkReg = '/[^a-zA-Z0-9;._-]/';
2181
-		$node = (isset($args['node']) && !preg_match($checkReg, $args['node']))? $args['node'] : '';
2182
-		$json = (isset($args['json']) && @json_decode($args['json']))? $args['json'] : '{}';
2183
-		$bind  = (isset($args['bind']) && !preg_match($checkReg, $args['bind']))? $args['bind'] : '';
2181
+		$node = (isset($args['node']) && !preg_match($checkReg, $args['node'])) ? $args['node'] : '';
2182
+		$json = (isset($args['json']) && @json_decode($args['json'])) ? $args['json'] : '{}';
2183
+		$bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind'])) ? $args['bind'] : '';
2184 2184
 		$done = (!empty($args['done']));
2185 2185
 		
2186
-		while( ob_get_level() ) {
2187
-			if (! ob_end_clean()) {
2186
+		while (ob_get_level()) {
2187
+			if (!ob_end_clean()) {
2188 2188
 				break;
2189 2189
 			}
2190 2190
 		}
2191 2191
 		
2192
-		if ($done || ! $this->callbackWindowURL) {
2192
+		if ($done || !$this->callbackWindowURL) {
2193 2193
 			$script = '';
2194 2194
 			if ($node) {
2195 2195
 				$script .= '
@@ -2231,13 +2231,13 @@  discard block
 block discarded – undo
2231 2231
 			
2232 2232
 		} else {
2233 2233
 			$url = $this->callbackWindowURL;
2234
-			$url .= ((strpos($url, '?') === false)? '?' : '&')
2235
-				 . '&node=' . rawurlencode($node)
2236
-				 . (($json !== '{}')? ('&json=' . rawurlencode($json)) : '')
2237
-				 . ($bind? ('&bind=' .  rawurlencode($bind)) : '')
2234
+			$url .= ((strpos($url, '?') === false) ? '?' : '&')
2235
+				 . '&node='.rawurlencode($node)
2236
+				 . (($json !== '{}') ? ('&json='.rawurlencode($json)) : '')
2237
+				 . ($bind ? ('&bind='.rawurlencode($bind)) : '')
2238 2238
 				 . '&done=1';
2239 2239
 			
2240
-			header('Location: ' . $url);
2240
+			header('Location: '.$url);
2241 2241
 			
2242 2242
 		}
2243 2243
 		exit();
@@ -2307,7 +2307,7 @@  discard block
 block discarded – undo
2307 2307
 	
2308 2308
 	protected function utime() {
2309 2309
 		$time = explode(" ", microtime());
2310
-		return (double)$time[1] + (double)$time[0];
2310
+		return (double) $time[1] + (double) $time[0];
2311 2311
 	}
2312 2312
 	
2313 2313
 	
@@ -2333,7 +2333,7 @@  discard block
 block discarded – undo
2333 2333
 		$imgcnt = 0;
2334 2334
 		$fp = fopen($path, 'rb');
2335 2335
 		@fread($fp, 4);
2336
-		$c = @fread($fp,1);
2336
+		$c = @fread($fp, 1);
2337 2337
 		if (ord($c) != 0x39) {  // GIF89a
2338 2338
 			return false;
2339 2339
 		}
@@ -2341,13 +2341,13 @@  discard block
 block discarded – undo
2341 2341
 		while (!feof($fp)) {
2342 2342
 			do {
2343 2343
 				$c = fread($fp, 1);
2344
-			} while(ord($c) != 0x21 && !feof($fp));
2344
+			} while (ord($c) != 0x21 && !feof($fp));
2345 2345
 	
2346 2346
 			if (feof($fp)) {
2347 2347
 				break;
2348 2348
 			}
2349 2349
 	
2350
-			$c2 = fread($fp,2);
2350
+			$c2 = fread($fp, 2);
2351 2351
 			if (bin2hex($c2) == "f904") {
2352 2352
 				$imgcnt++;
2353 2353
 			}
Please login to merge, or discard this patch.
php/elFinderVolumeDriver.class.php 1 patch
Spacing   +129 added lines, -130 removed lines patch added patch discarded remove patch
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 		'utf8fix'      => false,
275 275
 		 //                           й                 ё              Й               Ё              Ø         Å
276 276
 		'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"),
277
-		'utf8replace'  => array("\u0439",        "\u0451",       "\u0419",       "\u0401",       "\u00d8", "\u00c5")
277
+		'utf8replace'  => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5")
278 278
 	);
279 279
 
280 280
 	/**
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 **/
567 567
 	protected function configure() {
568 568
 		// set ARGS
569
-		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET;
569
+		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
570 570
 		// set thumbnails path
571 571
 		$path = $this->options['tmbPath'];
572 572
 		if ($path) {
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 		
598 598
 		// check 'statOwner' for command `chmod`
599 599
 		if (empty($this->options['statOwner'])) {
600
-			$this->disabled[] ='chmod';
600
+			$this->disabled[] = 'chmod';
601 601
 		}
602 602
 		
603 603
 		// check 'mimeMap'
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	 **/
703 703
 	public function mount(array $opts) {
704 704
 		if (!isset($opts['path']) || $opts['path'] === '') {
705
-			return $this->setError('Path undefined.');;
705
+			return $this->setError('Path undefined.'); ;
706 706
 		}
707 707
 		
708 708
 		$this->options = array_merge($this->options, $opts);
@@ -721,14 +721,14 @@  discard block
 block discarded – undo
721 721
 		$argInit = !empty($this->ARGS['init']);
722 722
 		
723 723
 		// session cache
724
-		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
724
+		if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
725 725
 			$_SESSION[elFinder::$sessionCacheKey][$this->id] = array();
726 726
 		}
727 727
 		$this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id];
728 728
 		
729 729
 		// default file attribute
730 730
 		$this->defaults = array(
731
-			'read'    => isset($this->options['defaults']['read'])  ? !!$this->options['defaults']['read']  : true,
731
+			'read'    => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true,
732 732
 			'write'   => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true,
733 733
 			'locked'  => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false,
734 734
 			'hidden'  => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false
@@ -755,8 +755,8 @@  discard block
 block discarded – undo
755 755
 			$this->access = $this->options['accessControl'];
756 756
 		}
757 757
 		
758
-		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y'));
759
-		$this->yesterday = $this->today-86400;
758
+		$this->today     = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
759
+		$this->yesterday = $this->today - 86400;
760 760
 		
761 761
 		// debug($this->attributes);
762 762
 		if (!$this->init()) {
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 				foreach ($mimecf as $line_num => $line) {
856 856
 					if (!preg_match('/^\s*#/', $line)) {
857 857
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
858
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
858
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
859 859
 							if (!isset(self::$mimetypes[$mime[$i]])) {
860 860
 								self::$mimetypes[$mime[$i]] = $mime[0];
861 861
 							}
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
 				'read'    => false
908 908
 			));
909 909
 		}
910
-		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1;
911
-		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48;
910
+		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1;
911
+		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48;
912 912
 		$this->URL      = $this->options['URL'];
913 913
 		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) {
914 914
 			$this->URL .= '/';
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 	public function options($hash) {
1050 1050
 		$create = $createext = array();
1051 1051
 		if (isset($this->archivers['create']) && is_array($this->archivers['create'])) {
1052
-			foreach($this->archivers['create'] as $m => $v) {
1052
+			foreach ($this->archivers['create'] as $m => $v) {
1053 1053
 				$create[] = $m;
1054 1054
 				$createext[$m] = $v['ext'];
1055 1055
 			}
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 				'extract'   => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(),
1069 1069
 				'createext' => $createext
1070 1070
 			),
1071
-			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array()
1071
+			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array()
1072 1072
 		);
1073 1073
 	}
1074 1074
 	
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
 	 */
1082 1082
 	public function getOptionsPlugin($name = '') {
1083 1083
 		if ($name) {
1084
-			return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array();
1084
+			return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array();
1085 1085
 		} else {
1086 1086
 			return $this->options['plugin'];
1087 1087
 		}
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 		$file = $this->stat($path);
1212 1212
 		
1213 1213
 		if ($hash === $this->root()) {
1214
-			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array();
1214
+			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array();
1215 1215
 			$file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON
1216 1216
 		}
1217 1217
 		
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
 	 * @return array|false
1227 1227
 	 * @author Dmitry (dio) Levashov
1228 1228
 	 **/
1229
-	public function dir($hash, $resolveLink=false) {
1229
+	public function dir($hash, $resolveLink = false) {
1230 1230
 		if (($dir = $this->file($hash)) == false) {
1231 1231
 			return $this->setError(elFinder::ERROR_DIR_NOT_FOUND);
1232 1232
 		}
@@ -1290,14 +1290,14 @@  discard block
 block discarded – undo
1290 1290
 	 * @return array|false
1291 1291
 	 * @author Dmitry (dio) Levashov
1292 1292
 	 **/
1293
-	public function tree($hash='', $deep=0, $exclude='') {
1293
+	public function tree($hash = '', $deep = 0, $exclude = '') {
1294 1294
 		$path = $hash ? $this->decode($hash) : $this->root;
1295 1295
 		
1296 1296
 		if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') {
1297 1297
 			return false;
1298 1298
 		}
1299 1299
 		
1300
-		$dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null);
1300
+		$dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null);
1301 1301
 		array_unshift($dirs, $dir);
1302 1302
 		return $dirs;
1303 1303
 	}
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
 	 * @return array|false
1528 1528
 	 * @author Dmitry (dio) Levashov
1529 1529
 	 **/
1530
-	public function duplicate($hash, $suffix='copy') {
1530
+	public function duplicate($hash, $suffix = 'copy') {
1531 1531
 		if ($this->commandDisabled('duplicate')) {
1532 1532
 			return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED);
1533 1533
 		}
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
 		
1604 1604
 		if ($file) { // file exists
1605 1605
 			// check POST data `overwrite` for 3rd party uploader
1606
-			$overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite'];
1606
+			$overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite'];
1607 1607
 			if ($overwrite) {
1608 1608
 				if (!$file['write']) {
1609 1609
 					return $this->setError(elFinder::ERROR_PERM_DENIED);
@@ -1674,7 +1674,7 @@  discard block
 block discarded – undo
1674 1674
 		if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) {
1675 1675
 			return $rmSrc
1676 1676
 				? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test))
1677
-				: $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1677
+				: $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1678 1678
 		}
1679 1679
 
1680 1680
 		$test = $this->joinPathCE($destination, $name);
@@ -1837,7 +1837,7 @@  discard block
 block discarded – undo
1837 1837
 			return $this->setError(elFinder::ERROR_PERM_DENIED);
1838 1838
 		}
1839 1839
 		$this->clearcache();
1840
-		$this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir;
1840
+		$this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir;
1841 1841
 		
1842 1842
 		if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) {
1843 1843
 			if (is_array($path)) {
@@ -1895,9 +1895,9 @@  discard block
 block discarded – undo
1895 1895
 		if ($name === '') {
1896 1896
 			$name = count($files) == 1 ? $files[0] : 'Archive';
1897 1897
 		} else {
1898
-			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name));
1898
+			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name));
1899 1899
 		}
1900
-		$name .='.' . $archiver['ext'];
1900
+		$name .= '.'.$archiver['ext'];
1901 1901
 		$name = $this->uniqueName($dir, $name, '');
1902 1902
 		$this->clearcache();
1903 1903
 		return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false;
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
 		
1934 1934
 		$path = $this->decode($hash);
1935 1935
 		
1936
-		$work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path);
1936
+		$work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path);
1937 1937
 
1938 1938
 		if (!$work_path || !is_writable($work_path)) {
1939 1939
 			if ($work_path && $path !== $work_path && is_file($work_path)) {
@@ -1948,7 +1948,7 @@  discard block
 block discarded – undo
1948 1948
 			}
1949 1949
 		}
1950 1950
 
1951
-		switch($mode) {
1951
+		switch ($mode) {
1952 1952
 			
1953 1953
 			case 'propresize':
1954 1954
 				$result = $this->imgResize($work_path, $width, $height, true, true);
@@ -2044,7 +2044,7 @@  discard block
 block discarded – undo
2044 2044
 		}
2045 2045
 		return ($q === '' || $this->commandDisabled('search'))
2046 2046
 			? array()
2047
-			: $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes);
2047
+			: $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes);
2048 2048
 	}
2049 2049
 	
2050 2050
 	/**
@@ -2113,9 +2113,9 @@  discard block
 block discarded – undo
2113 2113
 		$path = ltrim($path, $this->separator);
2114 2114
 		$dirs = explode($this->separator, $path);
2115 2115
 		array_pop($dirs);
2116
-		foreach($dirs as $dir) {
2116
+		foreach ($dirs as $dir) {
2117 2117
 			$targetPath = $this->joinPathCE($base, $dir);
2118
-			if (! $_realpath = $this->realpath($this->encode($targetPath))) {
2118
+			if (!$_realpath = $this->realpath($this->encode($targetPath))) {
2119 2119
 				if ($stat = $this->mkdir($targetHash, $dir)) {
2120 2120
 					$result['added'][] = $stat;
2121 2121
 					$targetHash = $stat['hash'];
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
 	 * @author Naoki Sawada
2183 2183
 	 **/
2184 2184
 	protected function dirnameCE($path) {
2185
-		return (!$this->encoding)? $this->_dirname($path) :	$this->convEncOut($this->_dirname($this->convEncIn($path)));
2185
+		return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path)));
2186 2186
 	}
2187 2187
 	
2188 2188
 	/**
@@ -2193,7 +2193,7 @@  discard block
 block discarded – undo
2193 2193
 	 * @author Naoki Sawada
2194 2194
 	 **/
2195 2195
 	protected function basenameCE($path) {
2196
-		return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2196
+		return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2197 2197
 	}
2198 2198
 	
2199 2199
 	/**
@@ -2206,7 +2206,7 @@  discard block
 block discarded – undo
2206 2206
 	 * @author Naoki Sawada
2207 2207
 	 **/
2208 2208
 	protected function joinPathCE($dir, $name) {
2209
-		return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2209
+		return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2210 2210
 	}
2211 2211
 	
2212 2212
 	/**
@@ -2217,7 +2217,7 @@  discard block
 block discarded – undo
2217 2217
 	 * @author Naoki Sawada
2218 2218
 	 **/
2219 2219
 	protected function normpathCE($path) {
2220
-		return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2220
+		return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2221 2221
 	}
2222 2222
 	
2223 2223
 	/**
@@ -2228,7 +2228,7 @@  discard block
 block discarded – undo
2228 2228
 	 * @author Naoki Sawada
2229 2229
 	 **/
2230 2230
 	protected function relpathCE($path) {
2231
-		return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2231
+		return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2232 2232
 	}
2233 2233
 	
2234 2234
 	/**
@@ -2239,7 +2239,7 @@  discard block
 block discarded – undo
2239 2239
 	 * @author Naoki Sawada
2240 2240
 	 **/
2241 2241
 	protected function abspathCE($path) {
2242
-		return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path)));
2242
+		return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path)));
2243 2243
 	}
2244 2244
 	
2245 2245
 	/**
@@ -2251,7 +2251,7 @@  discard block
 block discarded – undo
2251 2251
 	 * @author Naoki Sawada
2252 2252
 	 **/
2253 2253
 	protected function inpathCE($path, $parent) {
2254
-		return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2254
+		return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2255 2255
 	}
2256 2256
 	
2257 2257
 	/**
@@ -2262,8 +2262,8 @@  discard block
 block discarded – undo
2262 2262
 	 * @return resource|false
2263 2263
 	 * @author Naoki Sawada
2264 2264
 	 **/
2265
-	protected function fopenCE($path, $mode='rb') {
2266
-		return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2265
+	protected function fopenCE($path, $mode = 'rb') {
2266
+		return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2267 2267
 	}
2268 2268
 	
2269 2269
 	/**
@@ -2274,8 +2274,8 @@  discard block
 block discarded – undo
2274 2274
 	 * @return bool
2275 2275
 	 * @author Naoki Sawada
2276 2276
 	 **/
2277
-	protected function fcloseCE($fp, $path='') {
2278
-		return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2277
+	protected function fcloseCE($fp, $path = '') {
2278
+		return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2279 2279
 	}
2280 2280
 	
2281 2281
 	/**
@@ -2290,7 +2290,7 @@  discard block
 block discarded – undo
2290 2290
 	 * @author Naoki Sawada
2291 2291
 	 **/
2292 2292
 	protected function saveCE($fp, $dir, $name, $stat) {
2293
-		return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2293
+		return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2294 2294
 	}
2295 2295
 	
2296 2296
 	/**
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
 	 **/
2303 2303
 	protected function subdirsCE($path) {
2304 2304
 		if (!isset($this->subdirsCache[$path])) {
2305
-			$this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2305
+			$this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2306 2306
 		}
2307 2307
 		return $this->subdirsCache[$path];
2308 2308
 	}
@@ -2315,7 +2315,7 @@  discard block
 block discarded – undo
2315 2315
 	 * @author Naoki Sawada
2316 2316
 	 **/
2317 2317
 	protected function scandirCE($path) {
2318
-		return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2318
+		return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2319 2319
 	}
2320 2320
 	
2321 2321
 	/**
@@ -2328,7 +2328,7 @@  discard block
 block discarded – undo
2328 2328
 	 * @author Naoki Sawada
2329 2329
 	 **/
2330 2330
 	protected function symlinkCE($source, $targetDir, $name) {
2331
-		return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2331
+		return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2332 2332
 	}
2333 2333
 	
2334 2334
 	/***************** paths *******************/
@@ -2347,7 +2347,7 @@  discard block
 block discarded – undo
2347 2347
 			// cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root
2348 2348
 			$p = $this->relpathCE($path);
2349 2349
 			// if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt
2350
-			if ($p === '')	{
2350
+			if ($p === '') {
2351 2351
 				$p = DIRECTORY_SEPARATOR;
2352 2352
 			}
2353 2353
 
@@ -2380,7 +2380,7 @@  discard block
 block discarded – undo
2380 2380
 			// TODO uncrypt hash and return path
2381 2381
 			$path = $this->uncrypt($h); 
2382 2382
 			// append ROOT to path after it was cut in encode
2383
-			return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2383
+			return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2384 2384
 		}
2385 2385
 	}
2386 2386
 	
@@ -2437,21 +2437,21 @@  discard block
 block discarded – undo
2437 2437
 	 * @author Dmitry (dio) Levashov
2438 2438
 	 **/
2439 2439
 	public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) {
2440
-		$ext  = '';
2440
+		$ext = '';
2441 2441
 
2442 2442
 		if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
2443 2443
 			$ext  = '.'.$m[1];
2444
-			$name = substr($name, 0,  strlen($name)-strlen($m[0]));
2444
+			$name = substr($name, 0, strlen($name) - strlen($m[0]));
2445 2445
 		} 
2446 2446
 		
2447 2447
 		if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) {
2448
-			$i    = (int)$m[2];
2449
-			$name = substr($name, 0, strlen($name)-strlen($m[2]));
2448
+			$i    = (int) $m[2];
2449
+			$name = substr($name, 0, strlen($name) - strlen($m[2]));
2450 2450
 		} else {
2451 2451
 			$i     = $start;
2452 2452
 			$name .= $suffix;
2453 2453
 		}
2454
-		$max = $i+100000;
2454
+		$max = $i + 100000;
2455 2455
 
2456 2456
 		while ($i <= $max) {
2457 2457
 			$n = $name.($i > 0 ? $i : '').$ext;
@@ -2475,7 +2475,7 @@  discard block
 block discarded – undo
2475 2475
 	 * @author Naoki Sawada
2476 2476
 	 */
2477 2477
 	public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') {
2478
-		return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2478
+		return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2479 2479
 	}
2480 2480
 	
2481 2481
 	/**
@@ -2488,7 +2488,7 @@  discard block
 block discarded – undo
2488 2488
 	 * @author Naoki Sawada
2489 2489
 	 */
2490 2490
 	public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') {
2491
-		return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2491
+		return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2492 2492
 	}
2493 2493
 	
2494 2494
 	/**
@@ -2508,7 +2508,7 @@  discard block
 block discarded – undo
2508 2508
 			}
2509 2509
 			if (is_array($var)) {
2510 2510
 				$_ret = array();
2511
-				foreach($var as $_k => $_v) {
2511
+				foreach ($var as $_k => $_v) {
2512 2512
 					$_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_');
2513 2513
 				}
2514 2514
 				$var = $_ret;
@@ -2520,7 +2520,7 @@  discard block
 block discarded – undo
2520 2520
 						$_var = str_replace('?', $unknown, $_var);
2521 2521
 					}
2522 2522
 				}
2523
-				if  ($_var !== false) {
2523
+				if ($_var !== false) {
2524 2524
 					$var = $_var;
2525 2525
 				}
2526 2526
 			}
@@ -2547,7 +2547,7 @@  discard block
 block discarded – undo
2547 2547
 		
2548 2548
 		$key = '';
2549 2549
 		if ($path !== '') {
2550
-			$key = $this->id . '#' . $path;
2550
+			$key = $this->id.'#'.$path;
2551 2551
 			if (isset($cache[$key])) {
2552 2552
 				return $cache[$key];
2553 2553
 			}
@@ -2579,7 +2579,7 @@  discard block
 block discarded – undo
2579 2579
 		if ($work = $this->getTempFile()) {
2580 2580
 			if ($wfp = fopen($work, 'wb')) {
2581 2581
 				if ($fp = $this->_fopen($path)) {
2582
-					while(!feof($fp)) {
2582
+					while (!feof($fp)) {
2583 2583
 						fwrite($wfp, fread($fp, 8192));
2584 2584
 					}
2585 2585
 					$this->_fclose($fp, $path);
@@ -2623,7 +2623,7 @@  discard block
 block discarded – undo
2623 2623
 			@set_time_limit(30);
2624 2624
 			$stat = $this->stat($this->convEncOut($p));
2625 2625
 			$this->convEncIn();
2626
-			($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p);
2626
+			($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p);
2627 2627
 		}
2628 2628
 		return $this->_rmdir($localpath);
2629 2629
 	}
@@ -2640,7 +2640,7 @@  discard block
 block discarded – undo
2640 2640
 	 * @return bool
2641 2641
 	 * @author Dmitry (dio) Levashov
2642 2642
 	 **/
2643
-	protected function attr($path, $name, $val=null, $isDir=null) {
2643
+	protected function attr($path, $name, $val = null, $isDir = null) {
2644 2644
 		if (!isset($this->defaults[$name])) {
2645 2645
 			return false;
2646 2646
 		}
@@ -2672,7 +2672,7 @@  discard block
 block discarded – undo
2672 2672
 			} 
2673 2673
 		}
2674 2674
 		
2675
-		return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm;
2675
+		return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm;
2676 2676
 	}
2677 2677
 	
2678 2678
 	/**
@@ -2716,7 +2716,7 @@  discard block
 block discarded – undo
2716 2716
 	protected function allowPutMime($mime) {
2717 2717
 		// logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order
2718 2718
 		$allow  = $this->mimeAccepted($mime, $this->uploadAllow, null);
2719
-		$deny   = $this->mimeAccepted($mime, $this->uploadDeny,  null);
2719
+		$deny   = $this->mimeAccepted($mime, $this->uploadDeny, null);
2720 2720
 		$res = true; // default to allow
2721 2721
 		if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny'
2722 2722
 			$res = false; // default is deny
@@ -2787,10 +2787,10 @@  discard block
 block discarded – undo
2787 2787
 			if ($this->rootName) {
2788 2788
 				$stat['name'] = $this->rootName;
2789 2789
 			}
2790
-			if (! empty($this->options['icon'])) {
2790
+			if (!empty($this->options['icon'])) {
2791 2791
 				$stat['icon'] = $this->options['icon'];
2792 2792
 			}
2793
-			if (! empty($this->options['rootCssClass'])) {
2793
+			if (!empty($this->options['rootCssClass'])) {
2794 2794
 				$stat['csscls'] = $this->options['rootCssClass'];
2795 2795
 			}
2796 2796
 		} else {
@@ -2834,7 +2834,7 @@  discard block
 block discarded – undo
2834 2834
 			// lock when parent directory is not writable
2835 2835
 			if (!isset($stat['locked'])) {
2836 2836
 				$parent = $this->dirnameCE($path);
2837
-				$pstat = isset($this->cache[$parent])? $this->cache[$parent] : array();
2837
+				$pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array();
2838 2838
 				if (isset($pstat['write']) && !$pstat['write']) {
2839 2839
 					$stat['locked'] = true;
2840 2840
 				}
@@ -2892,7 +2892,7 @@  discard block
 block discarded – undo
2892 2892
 			}
2893 2893
 			if (!isset($stat['url']) && $this->URL && $this->encoding) {
2894 2894
 				$_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1));
2895
-				$stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true)));
2895
+				$stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true)));
2896 2896
 			}
2897 2897
 		} else {
2898 2898
 			if ($isDir) {
@@ -3135,7 +3135,7 @@  discard block
 block discarded – undo
3135 3135
 	 * @return array
3136 3136
 	 * @author Dmitry (dio) Levashov
3137 3137
 	 **/
3138
-	protected function gettree($path, $deep, $exclude='') {
3138
+	protected function gettree($path, $deep, $exclude = '') {
3139 3139
 		$dirs = array();
3140 3140
 		
3141 3141
 		!isset($this->dirsCache[$path]) && $this->cacheDir($path);
@@ -3146,7 +3146,7 @@  discard block
 block discarded – undo
3146 3146
 			if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') {
3147 3147
 				$dirs[] = $stat;
3148 3148
 				if ($deep > 0 && !empty($stat['dirs'])) {
3149
-					$dirs = array_merge($dirs, $this->gettree($p, $deep-1));
3149
+					$dirs = array_merge($dirs, $this->gettree($p, $deep - 1));
3150 3150
 				}
3151 3151
 			}
3152 3152
 		}
@@ -3166,7 +3166,7 @@  discard block
 block discarded – undo
3166 3166
 	protected function doSearch($path, $q, $mimes) {
3167 3167
 		$result = array();
3168 3168
 
3169
-		foreach($this->scandirCE($path) as $p) {
3169
+		foreach ($this->scandirCE($path) as $p) {
3170 3170
 			@set_time_limit(30);
3171 3171
 			$stat = $this->stat($p);
3172 3172
 
@@ -3187,7 +3187,7 @@  discard block
 block discarded – undo
3187 3187
 					if ($this->encoding) {
3188 3188
 						$path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true)));
3189 3189
 					}
3190
-					$stat['url'] = $this->URL . $path;
3190
+					$stat['url'] = $this->URL.$path;
3191 3191
 				}
3192 3192
 				
3193 3193
 				$result[] = $stat;
@@ -3221,7 +3221,7 @@  discard block
 block discarded – undo
3221 3221
 			if (!$this->inpathCE($target, $this->root)) {
3222 3222
 				return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK);
3223 3223
 			}
3224
-			$stat   = $this->stat($target);
3224
+			$stat = $this->stat($target);
3225 3225
 			$this->clearcache();
3226 3226
 			return $stat && $this->symlinkCE($target, $dst, $name)
3227 3227
 				? $this->joinPathCE($dst, $name)
@@ -3502,15 +3502,15 @@  discard block
 block discarded – undo
3502 3502
 		}
3503 3503
 
3504 3504
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
3505
-		if ($s[0] <= $tmbSize && $s[1]	<= $tmbSize) {
3506
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3505
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
3506
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3507 3507
 		} else {
3508 3508
 		
3509 3509
 			if ($this->options['tmbCrop']) {
3510 3510
 		
3511 3511
 				$result = $tmb;
3512 3512
 				/* Resize and crop if image bigger than thumbnail */
3513
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3513
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3514 3514
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
3515 3515
 				}
3516 3516
 		
@@ -3527,7 +3527,7 @@  discard block
 block discarded – undo
3527 3527
 			}
3528 3528
 		
3529 3529
 			if ($result) {
3530
-				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3530
+				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3531 3531
 			}
3532 3532
 		}
3533 3533
 		
@@ -3568,18 +3568,18 @@  discard block
 block discarded – undo
3568 3568
 			/* Resizing by biggest side */
3569 3569
 			if ($resizeByBiggerSide) {
3570 3570
 				if ($orig_w > $orig_h) {
3571
-					$size_h = round($orig_h * $width / $orig_w);
3571
+					$size_h = round($orig_h*$width/$orig_w);
3572 3572
 					$size_w = $width;
3573 3573
 				} else {
3574
-					$size_w = round($orig_w * $height / $orig_h);
3574
+					$size_w = round($orig_w*$height/$orig_h);
3575 3575
 					$size_h = $height;
3576 3576
 				}
3577 3577
 			} else {
3578 3578
 				if ($orig_w > $orig_h) {
3579
-					$size_w = round($orig_w * $height / $orig_h);
3579
+					$size_w = round($orig_w*$height/$orig_h);
3580 3580
 					$size_h = $height;
3581 3581
 				} else {
3582
-					$size_h = round($orig_h * $width / $orig_w);
3582
+					$size_h = round($orig_h*$width/$orig_w);
3583 3583
 					$size_w = $width;
3584 3584
 				}
3585 3585
 			}
@@ -3597,7 +3597,7 @@  discard block
 block discarded – undo
3597 3597
 				// Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb
3598 3598
 				// resize bench: http://app-mgng.rhcloud.com/9
3599 3599
 				// resize sample: http://www.dylanbeattie.net/magick/filters/result.html
3600
-				$filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3600
+				$filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3601 3601
 				
3602 3602
 				$ani = ($img->getNumberImages() > 1);
3603 3603
 				if ($ani && is_null($destformat)) {
@@ -3622,11 +3622,11 @@  discard block
 block discarded – undo
3622 3622
 				break;
3623 3623
 
3624 3624
 			case 'gd':
3625
-				$img = self::gdImageCreate($path,$s['mime']);
3625
+				$img = self::gdImageCreate($path, $s['mime']);
3626 3626
 
3627
-				if ($img &&  false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3627
+				if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3628 3628
 				
3629
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3629
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3630 3630
 					
3631 3631
 					if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) {
3632 3632
 						return false;
@@ -3702,11 +3702,11 @@  discard block
 block discarded – undo
3702 3702
 				break;
3703 3703
 
3704 3704
 			case 'gd':
3705
-				$img = self::gdImageCreate($path,$s['mime']);
3705
+				$img = self::gdImageCreate($path, $s['mime']);
3706 3706
 
3707
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3707
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3708 3708
 					
3709
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3709
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3710 3710
 
3711 3711
 					$size_w = $width;
3712 3712
 					$size_h = $height;
@@ -3756,8 +3756,8 @@  discard block
 block discarded – undo
3756 3756
 		$result = false;
3757 3757
 
3758 3758
 		/* Coordinates for image over square aligning */
3759
-		$y = ceil(abs($height - $s[1]) / 2); 
3760
-		$x = ceil(abs($width - $s[0]) / 2);
3759
+		$y = ceil(abs($height - $s[1])/2); 
3760
+		$x = ceil(abs($width - $s[0])/2);
3761 3761
 
3762 3762
 		switch ($this->imgLib) {
3763 3763
 			case 'imagick':
@@ -3777,7 +3777,7 @@  discard block
 block discarded – undo
3777 3777
 						$gif->newImage($width, $height, new ImagickPixel($bgcolor));
3778 3778
 						$gif->setImageColorspace($img->getImageColorspace());
3779 3779
 						$gif->setImageFormat('gif');
3780
-						$gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3780
+						$gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3781 3781
 						$gif->setImageDelay($img->getImageDelay());
3782 3782
 						$gif->setImageIterations($img->getImageIterations());
3783 3783
 						$img1->addImage($gif);
@@ -3793,7 +3793,7 @@  discard block
 block discarded – undo
3793 3793
 					$img1->newImage($width, $height, new ImagickPixel($bgcolor));
3794 3794
 					$img1->setImageColorspace($img->getImageColorspace());
3795 3795
 					$img1->setImageFormat($destformat != null ? $destformat : $img->getFormat());
3796
-					$img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3796
+					$img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3797 3797
 					$result = $img1->writeImage($path);
3798 3798
 				}
3799 3799
 				
@@ -3804,11 +3804,11 @@  discard block
 block discarded – undo
3804 3804
 				break;
3805 3805
 
3806 3806
 			case 'gd':
3807
-				$img = self::gdImageCreate($path,$s['mime']);
3807
+				$img = self::gdImageCreate($path, $s['mime']);
3808 3808
 
3809
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3809
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3810 3810
 
3811
-					self::gdImageBackground($tmp,$bgcolor);
3811
+					self::gdImageBackground($tmp, $bgcolor);
3812 3812
 
3813 3813
 					if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) {
3814 3814
 						return false;
@@ -3839,15 +3839,15 @@  discard block
 block discarded – undo
3839 3839
 	 * @author Troex Nevelin
3840 3840
 	 **/
3841 3841
 	protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null) {
3842
-		if (($s = @getimagesize($path)) == false || $degree % 360 === 0) {
3842
+		if (($s = @getimagesize($path)) == false || $degree%360 === 0) {
3843 3843
 			return false;
3844 3844
 		}
3845 3845
 
3846 3846
 		$result = false;
3847 3847
 
3848 3848
 		// try lossless rotate
3849
-		if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3850
-			$count = ($degree / 90) % 4;
3849
+		if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3850
+			$count = ($degree/90)%4;
3851 3851
 			$exiftran = array(
3852 3852
 				1 => '-9',
3853 3853
 				2 => '-1',
@@ -3863,7 +3863,7 @@  discard block
 block discarded – undo
3863 3863
 				'exiftran -i '.$exiftran[$count].' '.$path,
3864 3864
 				'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath
3865 3865
 			);
3866
-			foreach($cmds as $cmd) {
3866
+			foreach ($cmds as $cmd) {
3867 3867
 				if ($this->procExec($cmd) === 0) {
3868 3868
 					$result = true;
3869 3869
 					break;
@@ -3899,12 +3899,12 @@  discard block
 block discarded – undo
3899 3899
 				break;
3900 3900
 
3901 3901
 			case 'gd':
3902
-				$img = self::gdImageCreate($path,$s['mime']);
3902
+				$img = self::gdImageCreate($path, $s['mime']);
3903 3903
 
3904 3904
 				$degree = 360 - $degree;
3905 3905
 				list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
3906 3906
 				$bgcolor = imagecolorallocate($img, $r, $g, $b);
3907
-				$tmp = imageRotate($img, $degree, (int)$bgcolor);
3907
+				$tmp = imageRotate($img, $degree, (int) $bgcolor);
3908 3908
 
3909 3909
 				$result = self::gdImage($tmp, $path, $destformat, $s['mime']);
3910 3910
 
@@ -3929,11 +3929,11 @@  discard block
 block discarded – undo
3929 3929
 	 * @return int     exit code
3930 3930
 	 * @author Alexey Sukhotin
3931 3931
 	 **/
3932
-	protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) {
3932
+	protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) {
3933 3933
 
3934 3934
 		$descriptorspec = array(
3935
-			0 => array("pipe", "r"),  // stdin
3936
-			1 => array("pipe", "w"),  // stdout
3935
+			0 => array("pipe", "r"), // stdin
3936
+			1 => array("pipe", "w"), // stdout
3937 3937
 			2 => array("pipe", "w")   // stderr
3938 3938
 		);
3939 3939
 
@@ -3990,8 +3990,8 @@  discard block
 block discarded – undo
3990 3990
 	 * @param string $mime
3991 3991
 	 * @return gd image resource identifier
3992 3992
 	 */
3993
-	protected function gdImageCreate($path,$mime){
3994
-		switch($mime){
3993
+	protected function gdImageCreate($path, $mime) {
3994
+		switch ($mime) {
3995 3995
 			case 'image/jpeg':
3996 3996
 			return imagecreatefromjpeg($path);
3997 3997
 
@@ -4015,7 +4015,7 @@  discard block
 block discarded – undo
4015 4015
 	 * @param string $destformat The Image type to use for $filename
4016 4016
 	 * @param string $mime The original image mime type
4017 4017
 	 */
4018
-	protected function gdImage($image, $filename, $destformat, $mime ){
4018
+	protected function gdImage($image, $filename, $destformat, $mime) {
4019 4019
 
4020 4020
 		if ($destformat == 'jpg' || ($destformat == null && $mime == 'image/jpeg')) {
4021 4021
 			return imagejpeg($image, $filename, 100);
@@ -4034,13 +4034,13 @@  discard block
 block discarded – undo
4034 4034
 	 * @param resource $image gd image resource
4035 4035
 	 * @param string $bgcolor background color in #rrggbb format
4036 4036
 	 */
4037
-	protected function gdImageBackground($image, $bgcolor){
4037
+	protected function gdImageBackground($image, $bgcolor) {
4038 4038
 
4039
-		if( $bgcolor == 'transparent' ){
4040
-			imagesavealpha($image,true);
4039
+		if ($bgcolor == 'transparent') {
4040
+			imagesavealpha($image, true);
4041 4041
 			$bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127);
4042 4042
 
4043
-		}else{
4043
+		} else {
4044 4044
 			list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4045 4045
 			$bgcolor1 = imagecolorallocate($image, $r, $g, $b);
4046 4046
 		}
@@ -4078,13 +4078,13 @@  discard block
 block discarded – undo
4078 4078
 	* @return int|bool
4079 4079
 	* @author Alexey Sukhotin
4080 4080
 	**/
4081
-	protected function stripos($haystack , $needle , $offset = 0) {
4081
+	protected function stripos($haystack, $needle, $offset = 0) {
4082 4082
 		if (function_exists('mb_stripos')) {
4083
-			return mb_stripos($haystack , $needle , $offset);
4083
+			return mb_stripos($haystack, $needle, $offset);
4084 4084
 		} else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) {
4085 4085
 			return mb_strpos(mb_strtolower($haystack), mb_strtolower($needle), $offset);
4086 4086
 		} 
4087
-		return stripos($haystack , $needle , $offset);
4087
+		return stripos($haystack, $needle, $offset);
4088 4088
 	}
4089 4089
 
4090 4090
 	/**
@@ -4134,22 +4134,22 @@  discard block
 block discarded – undo
4134 4134
 			unset($o);
4135 4135
 			$this->procExec('zip -v', $o, $c);
4136 4136
 			if ($c == 0) {
4137
-				$arcs['create']['application/zip']  = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4137
+				$arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4138 4138
 			}
4139 4139
 			unset($o);
4140 4140
 			$this->procExec('unzip --help', $o, $c);
4141 4141
 			if ($c == 0) {
4142
-				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '',  'ext' => 'zip');
4142
+				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip');
4143 4143
 			}
4144 4144
 			unset($o);
4145 4145
 			$this->procExec('rar --version', $o, $c);
4146 4146
 			if ($c == 0 || $c == 7) {
4147 4147
 				$arcs['create']['application/x-rar']  = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar');
4148
-				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y',    'ext' => 'rar');
4148
+				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar');
4149 4149
 			} else {
4150 4150
 				unset($o);
4151 4151
 				$test = $this->procExec('unrar', $o, $c);
4152
-				if ($c==0 || $c == 7) {
4152
+				if ($c == 0 || $c == 7) {
4153 4153
 					$arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar');
4154 4154
 				}
4155 4155
 			}
@@ -4171,7 +4171,7 @@  discard block
 block discarded – undo
4171 4171
 				if (empty($arcs['extract']['application/x-tar'])) {
4172 4172
 					$arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar');
4173 4173
 				}
4174
-			} else if (substr(PHP_OS,0,3) === 'WIN') {
4174
+			} else if (substr(PHP_OS, 0, 3) === 'WIN') {
4175 4175
 				// check `7z` for Windows server.
4176 4176
 				unset($o);
4177 4177
 				$this->procExec('7z', $o, $c);
@@ -4225,22 +4225,22 @@  discard block
 block discarded – undo
4225 4225
 
4226 4226
 		// normalize `/../`
4227 4227
 		$normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#';
4228
-		while(preg_match($normreg, $path)) {
4228
+		while (preg_match($normreg, $path)) {
4229 4229
 			$path = preg_replace($normreg, '$1', $path);
4230 4230
 		}
4231 4231
 		
4232 4232
 		// 'Here'
4233
-		if ($path === '' || $path === '.' . $separator) return $base;
4233
+		if ($path === '' || $path === '.'.$separator) return $base;
4234 4234
 		
4235 4235
 		// Absolute path
4236 4236
 		if ($path[0] === $separator || strpos($path, $systemroot) === 0) {
4237 4237
 			return $path;
4238 4238
 		}
4239 4239
 		
4240
-		$preg_separator = '#' . $sepquoted . '#';
4240
+		$preg_separator = '#'.$sepquoted.'#';
4241 4241
 		
4242 4242
 		// Relative path from 'Here'
4243
-		if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) {
4243
+		if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) {
4244 4244
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4245 4245
 			if ($arrn[0] !== '.') {
4246 4246
 				array_unshift($arrn, '.');
@@ -4254,12 +4254,11 @@  discard block
 block discarded – undo
4254 4254
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4255 4255
 			$arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY);
4256 4256
 		
4257
-			while (! empty($arrn) && $arrn[0] === '..') {
4257
+			while (!empty($arrn) && $arrn[0] === '..') {
4258 4258
 				array_shift($arrn);
4259 4259
 				array_pop($arrp);
4260 4260
 			}
4261
-			$path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) :
4262
-				(! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot);
4261
+			$path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot);
4263 4262
 		}
4264 4263
 		
4265 4264
 		return $path;
@@ -4277,7 +4276,7 @@  discard block
 block discarded – undo
4277 4276
 			@chmod($dir, 0777);
4278 4277
 			foreach (array_diff(scandir($dir), array('.', '..')) as $file) {
4279 4278
 				@set_time_limit(30);
4280
-				$path = $dir . DIRECTORY_SEPARATOR . $file;
4279
+				$path = $dir.DIRECTORY_SEPARATOR.$file;
4281 4280
 				if (!is_link($dir) && is_dir($path)) {
4282 4281
 					$this->rmdirRecursive($path);
4283 4282
 				} else {
@@ -4364,22 +4363,22 @@  discard block
 block discarded – undo
4364 4363
 		try {
4365 4364
 			if ($start = is_string($zipPath)) {
4366 4365
 				$zip = new ZipArchive();
4367
-				if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) {
4366
+				if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) {
4368 4367
 					$zip = false;
4369 4368
 				}
4370 4369
 			} else {
4371 4370
 				$zip = $zipPath;
4372 4371
 			}
4373 4372
 			if ($zip) {
4374
-				foreach($files as $file) {
4375
-					$path = $dir . DIRECTORY_SEPARATOR . $file;
4373
+				foreach ($files as $file) {
4374
+					$path = $dir.DIRECTORY_SEPARATOR.$file;
4376 4375
 					if (is_dir($path)) {
4377 4376
 						$zip->addEmptyDir($file);
4378 4377
 						$_files = array();
4379 4378
 						if ($handle = opendir($path)) {
4380 4379
 							while (false !== ($entry = readdir($handle))) {
4381 4380
 								if ($entry !== "." && $entry !== "..") {
4382
-									$_files[] = $file . DIRECTORY_SEPARATOR . $entry;
4381
+									$_files[] = $file.DIRECTORY_SEPARATOR.$entry;
4383 4382
 								}
4384 4383
 							}
4385 4384
 							closedir($handle);
@@ -4564,7 +4563,7 @@  discard block
 block discarded – undo
4564 4563
 	 * @return resource|false
4565 4564
 	 * @author Dmitry (dio) Levashov
4566 4565
 	 **/
4567
-	abstract protected function _fopen($path, $mode="rb");
4566
+	abstract protected function _fopen($path, $mode = "rb");
4568 4567
 	
4569 4568
 	/**
4570 4569
 	 * Close opened file
@@ -4574,7 +4573,7 @@  discard block
 block discarded – undo
4574 4573
 	 * @return bool
4575 4574
 	 * @author Dmitry (dio) Levashov
4576 4575
 	 **/
4577
-	abstract protected function _fclose($fp, $path='');
4576
+	abstract protected function _fclose($fp, $path = '');
4578 4577
 	
4579 4578
 	/********************  file/dir manipulations *************************/
4580 4579
 	
Please login to merge, or discard this patch.
php/plugins/Normalizer/plugin.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -1,55 +1,55 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * elFinder Plugin Normalizer
4
- * 
5
- * UTF-8 Normalizer of file-name and file-path etc.
6
- * nfc(NFC): Canonical Decomposition followed by Canonical Composition
7
- * nfkc(NFKC): Compatibility Decomposition followed by Canonical
8
- * 
9
- * This plugin require Class "Normalizer" (PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
10
- * or PEAR package "I18N_UnicodeNormalizer"
11
- * 
12
- * ex. binding, configure on connector options
13
- *	$opts = array(
14
- *		'bind' => array(
15
- *			'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre' => array(
16
- *				'Plugin.Normalizer.cmdPreprocess'
17
- *			),
18
- *			'upload.presave' => array(
19
- *				'Plugin.Normalizer.onUpLoadPreSave'
20
- *			)
21
- *		),
22
- *		// global configure (optional)
23
- *		'plugin' => array(
24
- *			'Normalizer' => array(
25
- *				'enable' => true,
26
- *				'nfc'    => true,
27
- *				'nfkc'   => true,
28
- *				'lowercase'   => false
29
- *			)
30
- *		),
31
- *		// each volume configure (optional)
32
- *		'roots' => array(
33
- *			array(
34
- *				'driver' => 'LocalFileSystem',
35
- *				'path'   => '/path/to/files/',
36
- *				'URL'    => 'http://localhost/to/files/'
37
- *				'plugin' => array(
38
- *					'Normalizer' => array(
39
- *						'enable' => true,
40
- *						'nfc'    => true,
41
- *						'nfkc'   => true,
42
- * 						'lowercase'   => false
43
- *					)
44
- *				)
45
- *			)
46
- *		)
47
- *	);
48
- *
49
- * @package elfinder
50
- * @author Naoki Sawada
51
- * @license New BSD
52
- */
3
+	 * elFinder Plugin Normalizer
4
+	 * 
5
+	 * UTF-8 Normalizer of file-name and file-path etc.
6
+	 * nfc(NFC): Canonical Decomposition followed by Canonical Composition
7
+	 * nfkc(NFKC): Compatibility Decomposition followed by Canonical
8
+	 * 
9
+	 * This plugin require Class "Normalizer" (PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
10
+	 * or PEAR package "I18N_UnicodeNormalizer"
11
+	 * 
12
+	 * ex. binding, configure on connector options
13
+	 *	$opts = array(
14
+	 *		'bind' => array(
15
+	 *			'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre' => array(
16
+	 *				'Plugin.Normalizer.cmdPreprocess'
17
+	 *			),
18
+	 *			'upload.presave' => array(
19
+	 *				'Plugin.Normalizer.onUpLoadPreSave'
20
+	 *			)
21
+	 *		),
22
+	 *		// global configure (optional)
23
+	 *		'plugin' => array(
24
+	 *			'Normalizer' => array(
25
+	 *				'enable' => true,
26
+	 *				'nfc'    => true,
27
+	 *				'nfkc'   => true,
28
+	 *				'lowercase'   => false
29
+	 *			)
30
+	 *		),
31
+	 *		// each volume configure (optional)
32
+	 *		'roots' => array(
33
+	 *			array(
34
+	 *				'driver' => 'LocalFileSystem',
35
+	 *				'path'   => '/path/to/files/',
36
+	 *				'URL'    => 'http://localhost/to/files/'
37
+	 *				'plugin' => array(
38
+	 *					'Normalizer' => array(
39
+	 *						'enable' => true,
40
+	 *						'nfc'    => true,
41
+	 *						'nfkc'   => true,
42
+	 * 						'lowercase'   => false
43
+	 *					)
44
+	 *				)
45
+	 *			)
46
+	 *		)
47
+	 *	);
48
+	 *
49
+	 * @package elfinder
50
+	 * @author Naoki Sawada
51
+	 * @license New BSD
52
+	 */
53 53
 class elFinderPluginNormalizer
54 54
 {
55 55
 	private $opts = array();
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		$defaults = array(
59 59
 			'enable' => true, // For control by volume driver
60 60
 			'nfc'    => true, // Canonical Decomposition followed by Canonical Composition
61
-			'nfkc'   => true,  // Compatibility Decomposition followed by Canonical
61
+			'nfkc'   => true, // Compatibility Decomposition followed by Canonical
62 62
 			'lowercase'   => false  // Make chars lowercase
63 63
 		);
64 64
 	
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
 	
68 68
 	public function cmdPreprocess($cmd, &$args, $elfinder, $volume) {
69 69
 		$opts = $this->getOpts($volume);
70
-		if (! $opts['enable']) {
70
+		if (!$opts['enable']) {
71 71
 			return false;
72 72
 		}
73 73
 		
74 74
 		if (isset($args['name'])) {
75 75
 			if (is_array($args['name'])) {
76
-				foreach($args['name'] as $i => $name) {
76
+				foreach ($args['name'] as $i => $name) {
77 77
 					$args['name'][$i] = $this->normalize($name, $opts);
78 78
 				}
79 79
 			} else {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	
86 86
 	public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) {
87 87
 		$opts = $this->getOpts($volume);
88
-		if (! $opts['enable']) {
88
+		if (!$opts['enable']) {
89 89
 			return false;
90 90
 		}
91 91
 		
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
 	private function normalize($str, $opts) {
111 111
 		if ($opts['nfc'] || $opts['nfkc']) {
112 112
 			if (class_exists('Normalizer')) {
113
-				if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C))
113
+				if ($opts['nfc'] && !Normalizer::isNormalized($str, Normalizer::FORM_C))
114 114
 					$str = Normalizer::normalize($str, Normalizer::FORM_C);
115
-				if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC))
115
+				if ($opts['nfkc'] && !Normalizer::isNormalized($str, Normalizer::FORM_KC))
116 116
 					$str = Normalizer::normalize($str, Normalizer::FORM_KC);
117 117
 			} else {
118
-				if (! class_exists('I18N_UnicodeNormalizer')) {
118
+				if (!class_exists('I18N_UnicodeNormalizer')) {
119 119
 					@ include_once 'I18N/UnicodeNormalizer.php';
120 120
 				}
121 121
 				if (class_exists('I18N_UnicodeNormalizer')) {
Please login to merge, or discard this patch.
php/plugins/Sanitizer/plugin.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -1,48 +1,48 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * elFinder Plugin Sanitizer
4
- *
5
- * Sanitizer of file-name and file-path etc.
6
- *
7
- * ex. binding, configure on connector options
8
- *	$opts = array(
9
- *		'bind' => array(
10
- *			'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre' => array(
11
- *				'Plugin.Sanitizer.cmdPreprocess'
12
- *			),
13
- *			'upload.presave' => array(
14
- *				'Plugin.Sanitizer.onUpLoadPreSave'
15
- *			)
16
- *		),
17
- *		// global configure (optional)
18
- *		'plugin' => array(
19
- *			'Sanitizer' => array(
20
- *				'enable' => true,
21
- *				'targets'  => array('\\','/',':','*','?','"','<','>','|'), // target chars
22
- *				'replace'  => '_'    // replace to this
23
- *			)
24
- *		),
25
- *		// each volume configure (optional)
26
- *		'roots' => array(
27
- *			array(
28
- *				'driver' => 'LocalFileSystem',
29
- *				'path'   => '/path/to/files/',
30
- *				'URL'    => 'http://localhost/to/files/'
31
- *				'plugin' => array(
32
- *					'Sanitizer' => array(
33
- *						'enable' => true,
34
- *						'targets'  => array('\\','/',':','*','?','"','<','>','|'), // target chars
35
- *						'replace'  => '_'    // replace to this
36
- *					)
37
- *				)
38
- *			)
39
- *		)
40
- *	);
41
- *
42
- * @package elfinder
43
- * @author Naoki Sawada
44
- * @license New BSD
45
- */
3
+	 * elFinder Plugin Sanitizer
4
+	 *
5
+	 * Sanitizer of file-name and file-path etc.
6
+	 *
7
+	 * ex. binding, configure on connector options
8
+	 *	$opts = array(
9
+	 *		'bind' => array(
10
+	 *			'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre' => array(
11
+	 *				'Plugin.Sanitizer.cmdPreprocess'
12
+	 *			),
13
+	 *			'upload.presave' => array(
14
+	 *				'Plugin.Sanitizer.onUpLoadPreSave'
15
+	 *			)
16
+	 *		),
17
+	 *		// global configure (optional)
18
+	 *		'plugin' => array(
19
+	 *			'Sanitizer' => array(
20
+	 *				'enable' => true,
21
+	 *				'targets'  => array('\\','/',':','*','?','"','<','>','|'), // target chars
22
+	 *				'replace'  => '_'    // replace to this
23
+	 *			)
24
+	 *		),
25
+	 *		// each volume configure (optional)
26
+	 *		'roots' => array(
27
+	 *			array(
28
+	 *				'driver' => 'LocalFileSystem',
29
+	 *				'path'   => '/path/to/files/',
30
+	 *				'URL'    => 'http://localhost/to/files/'
31
+	 *				'plugin' => array(
32
+	 *					'Sanitizer' => array(
33
+	 *						'enable' => true,
34
+	 *						'targets'  => array('\\','/',':','*','?','"','<','>','|'), // target chars
35
+	 *						'replace'  => '_'    // replace to this
36
+	 *					)
37
+	 *				)
38
+	 *			)
39
+	 *		)
40
+	 *	);
41
+	 *
42
+	 * @package elfinder
43
+	 * @author Naoki Sawada
44
+	 * @license New BSD
45
+	 */
46 46
 class elFinderPluginSanitizer
47 47
 {
48 48
 	private $opts = array();
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	
50 50
 	public function __construct($opts) {
51 51
 		$defaults = array(
52
-			'enable'   => true,  // For control by volume driver
53
-			'targets'  => array('\\','/',':','*','?','"','<','>','|'), // target chars
52
+			'enable'   => true, // For control by volume driver
53
+			'targets'  => array('\\', '/', ':', '*', '?', '"', '<', '>', '|'), // target chars
54 54
 			'replace'  => '_'    // replace to this
55 55
 		);
56 56
 	
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	
60 60
 	public function cmdPreprocess($cmd, &$args, $elfinder, $volume) {
61 61
 		$opts = $this->getOpts($volume);
62
-		if (! $opts['enable']) {
62
+		if (!$opts['enable']) {
63 63
 			return false;
64 64
 		}
65 65
 	
66 66
 		if (isset($args['name'])) {
67 67
 			if (is_array($args['name'])) {
68
-				foreach($args['name'] as $i => $name) {
68
+				foreach ($args['name'] as $i => $name) {
69 69
 					$args['name'][$i] = $this->sanitizeFileName($name, $opts);
70 70
 				}
71 71
 			} else {
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 	public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) {
79 79
 		$opts = $this->getOpts($volume);
80
-		if (! $opts['enable']) {
80
+		if (!$opts['enable']) {
81 81
 			return false;
82 82
 		}
83 83
 	
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 	
102 102
 	private function sanitizeFileName($filename, $opts, $allows = array()) {
103
-		$targets = $allows? array_diff($opts['targets'], $allows) : $opts['targets'];
103
+		$targets = $allows ? array_diff($opts['targets'], $allows) : $opts['targets'];
104 104
 		return str_replace($targets, $opts['replace'], $filename);
105 105
   	}
106 106
 }
Please login to merge, or discard this patch.