Completed
Pull Request — 2.x (#1148)
by
unknown
03:18
created
php/elFinder.class.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1344,7 +1344,7 @@
 block discarded – undo
1344 1344
 	 * 
1345 1345
 	 * @param  string $str
1346 1346
 	 * @param  array  $extTable
1347
-	 * @return array
1347
+	 * @return string[]
1348 1348
 	 * @author Naoki Sawada
1349 1349
 	 */
1350 1350
 	protected function parse_data_scheme( $str, $extTable ) {
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1149,18 +1149,18 @@  discard block
 block discarded – undo
1149 1149
 	}
1150 1150
 
1151 1151
 	/**
1152
-	* Get remote contents
1153
-	*
1154
-	* @param  string   $url     target url
1155
-	* @param  int      $timeout timeout (sec)
1156
-	* @param  int      $redirect_max redirect max count
1157
-	* @param  string   $ua
1158
-	* @param  resource $fp
1159
-	* @return string or bool(false)
1160
-	* @retval string contents
1161
-	* @retval false  error
1162
-	* @author Naoki Sawada
1163
-	**/
1152
+	 * Get remote contents
1153
+	 *
1154
+	 * @param  string   $url     target url
1155
+	 * @param  int      $timeout timeout (sec)
1156
+	 * @param  int      $redirect_max redirect max count
1157
+	 * @param  string   $ua
1158
+	 * @param  resource $fp
1159
+	 * @return string or bool(false)
1160
+	 * @retval string contents
1161
+	 * @retval false  error
1162
+	 * @author Naoki Sawada
1163
+	 **/
1164 1164
 	protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) {
1165 1165
 		$method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; 
1166 1166
 		return $this->$method( $url, $timeout, $redirect_max, $ua, $fp );
@@ -2090,12 +2090,12 @@  discard block
 block discarded – undo
2090 2090
 	}
2091 2091
 	
2092 2092
 	/**
2093
-	* Return content URL
2094
-	*
2095
-	* @param  array  $args  command arguments
2096
-	* @return array
2097
-	* @author Naoki Sawada
2098
-	**/
2093
+	 * Return content URL
2094
+	 *
2095
+	 * @param  array  $args  command arguments
2096
+	 * @return array
2097
+	 * @author Naoki Sawada
2098
+	 **/
2099 2099
 	protected function url($args) {
2100 2100
 		$target = $args['target'];
2101 2101
 		$options = isset($args['options'])? $args['options'] : array();
Please login to merge, or discard this patch.
Spacing   +146 added lines, -146 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
 
@@ -276,17 +276,17 @@  discard block
 block discarded – undo
276 276
 
277 277
 		$this->time  = $this->utime();
278 278
 		$this->debug = (isset($opts['debug']) && $opts['debug'] ? true : false);
279
-		$this->sessionCloseEarlier = isset($opts['sessionCloseEarlier'])? (bool)$opts['sessionCloseEarlier'] : true;
279
+		$this->sessionCloseEarlier = isset($opts['sessionCloseEarlier']) ? (bool) $opts['sessionCloseEarlier'] : true;
280 280
 		$this->sessionUseCmds = array_flip($sessionUseCmds);
281 281
 		$this->timeout = (isset($opts['timeout']) ? $opts['timeout'] : 0);
282 282
 		$this->uploadTempPath = (isset($opts['uploadTempPath']) ? $opts['uploadTempPath'] : '');
283
-		$this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey'])? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
283
+		$this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey']) ? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
284 284
 		$this->callbackWindowURL = (isset($opts['callbackWindowURL']) ? $opts['callbackWindowURL'] : '');
285 285
 		self::$sessionCacheKey = !empty($opts['sessionCacheKey']) ? $opts['sessionCacheKey'] : 'elFinderCaches';
286 286
 		
287 287
 		// check session cache
288 288
 		$_optsMD5 = md5(json_encode($opts['roots']));
289
-		if (! isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) {
289
+		if (!isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) {
290 290
 			$_SESSION[self::$sessionCacheKey] = array(
291 291
 				'_optsMD5' => $_optsMD5
292 292
 			);
@@ -305,20 +305,20 @@  discard block
 block discarded – undo
305 305
 			$_reqCmd = isset($_req['cmd']) ? $_req['cmd'] : '';
306 306
 			foreach ($opts['bind'] as $cmd => $handlers) {
307 307
 				$doRegist = (strpos($cmd, '*') !== false);
308
-				if (! $doRegist) {
308
+				if (!$doRegist) {
309 309
 					$_getcmd = create_function('$cmd', 'list($ret) = explode(\'.\', $cmd);return trim($ret);');
310 310
 					$doRegist = ($_reqCmd && in_array($_reqCmd, array_map($_getcmd, explode(' ', $cmd))));
311 311
 				}
312 312
 				if ($doRegist) {
313
-					if (! is_array($handlers) || is_object($handlers[0])) {
313
+					if (!is_array($handlers) || is_object($handlers[0])) {
314 314
 						$handlers = array($handlers);
315 315
 					}
316
-					foreach($handlers as $handler) {
316
+					foreach ($handlers as $handler) {
317 317
 						if ($handler) {
318 318
 							if (is_string($handler) && strpos($handler, '.')) {
319 319
 								list($_domain, $_name, $_method) = array_pad(explode('.', $handler), 3, '');
320 320
 								if (strcasecmp($_domain, 'plugin') === 0) {
321
-									if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name])? $opts['plugin'][$_name] : array())
321
+									if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name]) ? $opts['plugin'][$_name] : array())
322 322
 											and method_exists($plugin, $_method)) {
323 323
 										$this->bind($cmd, array($plugin, $_method));
324 324
 									}
@@ -405,13 +405,13 @@  discard block
 block discarded – undo
405 405
 	public function bind($cmd, $handler) {
406 406
 		$allCmds = array_keys($this->commands);
407 407
 		$cmds = array();
408
-		foreach(explode(' ', $cmd) as $_cmd) {
408
+		foreach (explode(' ', $cmd) as $_cmd) {
409 409
 			if ($_cmd !== '') {
410 410
 				if ($all = strpos($_cmd, '*') !== false) {
411 411
 					list(, $sub) = array_pad(explode('.', $_cmd), 2, '');
412 412
 					if ($sub) {
413 413
 						$sub = str_replace('\'', '\\\'', $sub);
414
-						$addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\'' . $sub . '\');');
414
+						$addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\''.$sub.'\');');
415 415
 						$cmds = array_merge($cmds, array_map($addSub, $allCmds));
416 416
 					} else {
417 417
 						$cmds = array_merge($cmds, $allCmds);
@@ -491,16 +491,16 @@  discard block
 block discarded – undo
491 491
 
492 492
 	private function session_expires() {
493 493
 		
494
-		if (!isset($_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'])) {
495
-			$_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time();
494
+		if (!isset($_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'])) {
495
+			$_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time();
496 496
 			return false;
497 497
 		}
498 498
 
499
-		if ( ($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] > $this->timeout) ) {
499
+		if (($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] > $this->timeout)) {
500 500
 			return true;
501 501
 		}
502 502
 
503
-		$_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time();
503
+		$_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time();
504 504
 		return false;	
505 505
 	}
506 506
 	
@@ -533,9 +533,9 @@  discard block
 block discarded – undo
533 533
 		}
534 534
 
535 535
 		// call pre handlers for this command
536
-		$args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd])? false : $this->sessionCloseEarlier;
536
+		$args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd]) ? false : $this->sessionCloseEarlier;
537 537
 		if (!empty($this->listeners[$cmd.'.pre'])) {
538
-			$volume = isset($args['target'])? $this->volume($args['target']) : false;
538
+			$volume = isset($args['target']) ? $this->volume($args['target']) : false;
539 539
 			foreach ($this->listeners[$cmd.'.pre'] as $handler) {
540 540
 				call_user_func_array($handler, array($cmd, &$args, $this, $volume));
541 541
 			}
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 		// call handlers for this command
558 558
 		if (!empty($this->listeners[$cmd])) {
559 559
 			foreach ($this->listeners[$cmd] as $handler) {
560
-				if (call_user_func_array($handler,array($cmd,&$result,$args,$this))) {
560
+				if (call_user_func_array($handler, array($cmd, &$result, $args, $this))) {
561 561
 					// handler return true to force sync client after command completed
562 562
 					$result['sync'] = true;
563 563
 				}
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 	 * @return string
617 617
 	 * @author Dmitry (dio) Levashov
618 618
 	 **/
619
-	public function realpath($hash)	{
619
+	public function realpath($hash) {
620 620
 		if (($volume = $this->volume($hash)) == false) {
621 621
 			return false;
622 622
 		}
@@ -672,11 +672,11 @@  discard block
 block discarded – undo
672 672
 	 */
673 673
 	protected function getPluginInstance($name, $opts = array()) {
674 674
 		$key = strtolower($name);
675
-		if (! isset($this->plugins[$key])) {
676
-			$p_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'plugin.php';
675
+		if (!isset($this->plugins[$key])) {
676
+			$p_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.'plugin.php';
677 677
 			if (is_file($p_file)) {
678 678
 				require_once $p_file;
679
-				$class = 'elFinderPlugin' . $name;
679
+				$class = 'elFinderPlugin'.$name;
680 680
 				$this->plugins[$key] = new $class($opts);
681 681
 			} else {
682 682
 				$this->plugins[$key] = false;
@@ -768,8 +768,8 @@  discard block
 block discarded – undo
768 768
 		
769 769
 		$netVolumes = $this->getNetVolumes();
770 770
 		if ($volume->mount($options)) {
771
-			if (! $key = @ $volume->netMountKey) {
772
-				$key = md5($protocol . '-' . join('-', $options));
771
+			if (!$key = @ $volume->netMountKey) {
772
+				$key = md5($protocol.'-'.join('-', $options));
773 773
 			}
774 774
 			$options['driver'] = $driver;
775 775
 			$options['netkey'] = $key;
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
 			$disp = 'attachment';
972 972
 			$mime = $file['mime'];
973 973
 		} else {
974
-			$disp  = preg_match('/^(image|text)/i', $file['mime']) || $file['mime'] == 'application/x-shockwave-flash' 
974
+			$disp = preg_match('/^(image|text)/i', $file['mime']) || $file['mime'] == 'application/x-shockwave-flash' 
975 975
 					? 'inline' 
976 976
 					: 'attachment';
977 977
 			$mime = $file['mime'];
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
 		$name   = $args['name'];
1084 1084
 		
1085 1085
 		if (($volume = $this->volume($target)) == false
1086
-		||  ($rm  = $volume->file($target)) == false) {
1086
+		||  ($rm = $volume->file($target)) == false) {
1087 1087
 			return array('error' => $this->error(self::ERROR_RENAME, '#'.$target, self::ERROR_FILE_NOT_FOUND));
1088 1088
 		}
1089 1089
 		$rm['realpath'] = $volume->realpath($target);
@@ -1161,9 +1161,9 @@  discard block
 block discarded – undo
1161 1161
 	* @retval false  error
1162 1162
 	* @author Naoki Sawada
1163 1163
 	**/
1164
-	protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) {
1165
-		$method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; 
1166
-		return $this->$method( $url, $timeout, $redirect_max, $ua, $fp );
1164
+	protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) {
1165
+		$method = (function_exists('curl_exec') && !ini_get('safe_mode')) ? 'curl_get_contents' : 'fsock_get_contents'; 
1166
+		return $this->$method($url, $timeout, $redirect_max, $ua, $fp);
1167 1167
 	}
1168 1168
 	
1169 1169
 	/**
@@ -1179,26 +1179,26 @@  discard block
 block discarded – undo
1179 1179
 	 * @retval false  error
1180 1180
 	 * @author Naoki Sawada
1181 1181
 	 **/
1182
-	 protected function curl_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ){
1182
+	 protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1183 1183
 		$ch = curl_init();
1184
-		curl_setopt( $ch, CURLOPT_URL, $url );
1185
-		curl_setopt( $ch, CURLOPT_HEADER, false );
1184
+		curl_setopt($ch, CURLOPT_URL, $url);
1185
+		curl_setopt($ch, CURLOPT_HEADER, false);
1186 1186
 		if ($outfp) {
1187
-			curl_setopt( $ch, CURLOPT_FILE, $outfp );
1187
+			curl_setopt($ch, CURLOPT_FILE, $outfp);
1188 1188
 		} else {
1189
-			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
1190
-			curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true );
1191
-		}
1192
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 );
1193
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_TIME, $timeout );
1194
-		curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
1195
-		curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
1196
-		curl_setopt( $ch, CURLOPT_MAXREDIRS, $redirect_max);
1197
-		curl_setopt( $ch, CURLOPT_USERAGENT, $ua);
1198
-		$result = curl_exec( $ch );
1189
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1190
+			curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
1191
+		}
1192
+		curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1);
1193
+		curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout);
1194
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1195
+		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
1196
+		curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max);
1197
+		curl_setopt($ch, CURLOPT_USERAGENT, $ua);
1198
+		$result = curl_exec($ch);
1199 1199
 		$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
1200
-		curl_close( $ch );
1201
-		return $outfp? $outfp : $result;
1200
+		curl_close($ch);
1201
+		return $outfp ? $outfp : $result;
1202 1202
 	}
1203 1203
 	
1204 1204
 	/**
@@ -1214,7 +1214,7 @@  discard block
 block discarded – undo
1214 1214
 	 * @retval false  error
1215 1215
 	 * @author Naoki Sawada
1216 1216
 	 */
1217
-	protected function fsock_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ) {
1217
+	protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1218 1218
 
1219 1219
 		$connect_timeout = 3;
1220 1220
 		$connect_try = 3;
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
 		$headers = '';
1226 1226
 		
1227 1227
 		$arr = parse_url($url);
1228
-		if (!$arr){
1228
+		if (!$arr) {
1229 1229
 			// Bad request
1230 1230
 			return false;
1231 1231
 		}
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 		// query
1234 1234
 		$arr['query'] = isset($arr['query']) ? '?'.$arr['query'] : '';
1235 1235
 		// port
1236
-		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https'])? 443 : 80);
1236
+		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https']) ? 443 : 80);
1237 1237
 		
1238 1238
 		$url_base = $arr['scheme'].'://'.$arr['host'].':'.$arr['port'];
1239 1239
 		$url_path = isset($arr['path']) ? $arr['path'] : '/';
@@ -1242,21 +1242,21 @@  discard block
 block discarded – undo
1242 1242
 		$query = $method.' '.$uri." HTTP/1.0\r\n";
1243 1243
 		$query .= "Host: ".$arr['host']."\r\n";
1244 1244
 		if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n";
1245
-		if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n";
1245
+		if (!is_null($getSize)) $query .= 'Range: bytes=0-'.($getSize - 1)."\r\n";
1246 1246
 		
1247 1247
 		$query .= $headers;
1248 1248
 
1249 1249
 		$query .= "\r\n";
1250 1250
 
1251 1251
 		$fp = $connect_try_count = 0;
1252
-		while( !$fp && $connect_try_count < $connect_try ) {
1252
+		while (!$fp && $connect_try_count < $connect_try) {
1253 1253
 	
1254 1254
 			$errno = 0;
1255 1255
 			$errstr = "";
1256 1256
 			$fp = @ fsockopen(
1257 1257
 			$arr['https'].$arr['host'],
1258 1258
 			$arr['port'],
1259
-			$errno,$errstr,$connect_timeout);
1259
+			$errno, $errstr, $connect_timeout);
1260 1260
 			if ($fp) break;
1261 1261
 			$connect_try_count++;
1262 1262
 			if (connection_aborted()) {
@@ -1281,13 +1281,13 @@  discard block
 block discarded – undo
1281 1281
 		
1282 1282
 		$_response = '';
1283 1283
 		$header = '';
1284
-		while($_response !== "\r\n"){
1284
+		while ($_response !== "\r\n") {
1285 1285
 			$_response = fgets($fp, $readsize);
1286 1286
 			$header .= $_response;
1287 1287
 		};
1288 1288
 		
1289
-		$rccd = array_pad(explode(' ',$header,3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1290
-		$rc = (int)$rccd[1];
1289
+		$rccd = array_pad(explode(' ', $header, 3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1290
+		$rc = (int) $rccd[1];
1291 1291
 		
1292 1292
 		// Redirect
1293 1293
 		switch ($rc) {
@@ -1296,19 +1296,19 @@  discard block
 block discarded – undo
1296 1296
 			case 302: // Moved Temporarily
1297 1297
 			case 301: // Moved Permanently
1298 1298
 				$matches = array();
1299
-				if (preg_match('/^Location: (.+?)(#.+)?$/im',$header,$matches) && --$redirect_max > 0) {
1299
+				if (preg_match('/^Location: (.+?)(#.+)?$/im', $header, $matches) && --$redirect_max > 0) {
1300 1300
 					$url = trim($matches[1]);
1301
-					$hash = isset($matches[2])? trim($matches[2]) : '';
1302
-					if (!preg_match('/^https?:\//',$url)) { // no scheme
1301
+					$hash = isset($matches[2]) ? trim($matches[2]) : '';
1302
+					if (!preg_match('/^https?:\//', $url)) { // no scheme
1303 1303
 						if ($url{0} != '/') { // Relative path
1304 1304
 							// to Absolute path
1305
-							$url = substr($url_path,0,strrpos($url_path,'/')).'/'.$url;
1305
+							$url = substr($url_path, 0, strrpos($url_path, '/')).'/'.$url;
1306 1306
 						}
1307 1307
 						// add sheme,host
1308 1308
 						$url = $url_base.$url;
1309 1309
 					}
1310 1310
 					fclose($fp);
1311
-					return $this->fsock_get_contents( $url, $timeout, $redirect_max, $ua, $outfp );
1311
+					return $this->fsock_get_contents($url, $timeout, $redirect_max, $ua, $outfp);
1312 1312
 				}
1313 1313
 		}
1314 1314
 		
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
 			$outfp = fopen('php://temp', 'rwb');
1318 1318
 			$body = true;
1319 1319
 		}
1320
-		while(fwrite($outfp, fread($fp, $readsize))) {
1320
+		while (fwrite($outfp, fread($fp, $readsize))) {
1321 1321
 			if ($timeout) {
1322 1322
 				$_status = socket_get_status($fp);
1323 1323
 				if ($_status['timed_out']) {
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
 		
1337 1337
 		fclose($fp);
1338 1338
 		
1339
-		return $outfp? $outfp : $body; // Data
1339
+		return $outfp ? $outfp : $body; // Data
1340 1340
 	}
1341 1341
 	
1342 1342
 	/**
@@ -1347,13 +1347,13 @@  discard block
 block discarded – undo
1347 1347
 	 * @return array
1348 1348
 	 * @author Naoki Sawada
1349 1349
 	 */
1350
-	protected function parse_data_scheme( $str, $extTable ) {
1350
+	protected function parse_data_scheme($str, $extTable) {
1351 1351
 		$data = $name = '';
1352 1352
 		if ($fp = fopen('data://'.substr($str, 5), 'rb')) {
1353 1353
 			if ($data = stream_get_contents($fp)) {
1354 1354
 				$meta = stream_get_meta_data($fp);
1355
-				$ext = isset($extTable[$meta['mediatype']])? '.' . $extTable[$meta['mediatype']] : '';
1356
-				$name = substr(md5($data), 0, 8) . $ext;
1355
+				$ext = isset($extTable[$meta['mediatype']]) ? '.'.$extTable[$meta['mediatype']] : '';
1356
+				$name = substr(md5($data), 0, 8).$ext;
1357 1357
 			}
1358 1358
 			fclose($fp);
1359 1359
 		}
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
 			}
1418 1418
 		}
1419 1419
 		
1420
-		return ($mime && isset($extTable[$mime]))? ('.' . $extTable[$mime]) : '';
1420
+		return ($mime && isset($extTable[$mime])) ? ('.'.$extTable[$mime]) : '';
1421 1421
 	}
1422 1422
 	
1423 1423
 	/**
@@ -1433,26 +1433,26 @@  discard block
 block discarded – undo
1433 1433
 	private function checkChunkedFile($tmpname, $chunk, $cid, $tempDir, $volume = null) {
1434 1434
 		if (preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m)) {
1435 1435
 			$fname = $m[1];
1436
-			$encname = md5($cid . '_' . $fname);
1437
-			$base = $tempDir . DIRECTORY_SEPARATOR . 'ELF' . $encname;
1436
+			$encname = md5($cid.'_'.$fname);
1437
+			$base = $tempDir.DIRECTORY_SEPARATOR.'ELF'.$encname;
1438 1438
 			$clast = intval($m[3]);
1439 1439
 			if (is_null($tmpname)) {
1440 1440
 				ignore_user_abort(true);
1441 1441
 				sleep(10); // wait 10 sec
1442 1442
 				// chunked file upload fail
1443
-				foreach(glob($base . '*') as $cf) {
1443
+				foreach (glob($base.'*') as $cf) {
1444 1444
 					@unlink($cf);
1445 1445
 				}
1446 1446
 				ignore_user_abort(false);
1447 1447
 				return;
1448 1448
 			}
1449 1449
 			
1450
-			$range = isset($_POST['range'])? trim($_POST['range']) : '';
1450
+			$range = isset($_POST['range']) ? trim($_POST['range']) : '';
1451 1451
 			if ($range && preg_match('/^(\d+),(\d+),(\d+)$/', $range, $ranges)) {
1452 1452
 				$start = $ranges[1];
1453 1453
 				$len   = $ranges[2];
1454 1454
 				$size  = $ranges[3];
1455
-				$tmp = $base . '.part';
1455
+				$tmp = $base.'.part';
1456 1456
 				$csize = filesize($tmpname);
1457 1457
 				
1458 1458
 				$tmpExists = is_file($tmp);
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
 				} else {
1478 1478
 					// wait until makeing temp file (for anothor session)
1479 1479
 					$cnt = 100; // Time limit 10 sec
1480
-					while(!is_file($base) && --$cnt) {
1480
+					while (!is_file($base) && --$cnt) {
1481 1481
 						usleep(100000); // wait 100ms
1482 1482
 					}
1483 1483
 					if (!$cnt) {
@@ -1512,13 +1512,13 @@  discard block
 block discarded – undo
1512 1512
 				}
1513 1513
 			} else {
1514 1514
 				// old way
1515
-				$part = $base . $m[2];
1515
+				$part = $base.$m[2];
1516 1516
 				if (move_uploaded_file($tmpname, $part)) {
1517 1517
 					@chmod($part, 0600);
1518
-					if ($clast < count(glob($base . '*'))) {
1518
+					if ($clast < count(glob($base.'*'))) {
1519 1519
 						$parts = array();
1520 1520
 						for ($i = 0; $i <= $clast; $i++) {
1521
-							$name = $base . '.' . $i . '_' . $clast;
1521
+							$name = $base.'.'.$i.'_'.$clast;
1522 1522
 							if (is_readable($name)) {
1523 1523
 								$parts[] = $name;
1524 1524
 							} else {
@@ -1531,7 +1531,7 @@  discard block
 block discarded – undo
1531 1531
 								touch($base);
1532 1532
 								if ($resfile = tempnam($tempDir, 'ELF')) {
1533 1533
 									$target = fopen($resfile, 'wb');
1534
-									foreach($parts as $f) {
1534
+									foreach ($parts as $f) {
1535 1535
 										$fp = fopen($f, 'rb');
1536 1536
 										while (!feof($fp)) {
1537 1537
 											fwrite($target, fread($fp, 8192));
@@ -1572,15 +1572,15 @@  discard block
 block discarded – undo
1572 1572
 			$testDirs[] = rtrim(realpath($volumeTempPath), DIRECTORY_SEPARATOR);
1573 1573
 		}
1574 1574
 		$tempDir = '';
1575
-		$test = DIRECTORY_SEPARATOR . microtime(true);
1576
-		foreach($testDirs as $testDir) {
1575
+		$test = DIRECTORY_SEPARATOR.microtime(true);
1576
+		foreach ($testDirs as $testDir) {
1577 1577
 			if (!$testDir || !is_dir($testDir)) continue;
1578 1578
 			$testFile = $testDir.$test;
1579 1579
 			if (touch($testFile)) {
1580 1580
 				unlink($testFile);
1581 1581
 				$tempDir = $testDir;
1582 1582
 				$gc = time() - 3600;
1583
-				foreach(glob($tempDir . '/ELF*') as $cf) {
1583
+				foreach (glob($tempDir.'/ELF*') as $cf) {
1584 1584
 					if (filemtime($cf) < $gc) {
1585 1585
 						@unlink($cf);
1586 1586
 					}
@@ -1600,7 +1600,7 @@  discard block
 block discarded – undo
1600 1600
 	 **/
1601 1601
 	protected function chmod($args) {
1602 1602
 		$targets = $args['targets'];
1603
-		$mode    = intval((string)$args['mode'], 8);
1603
+		$mode    = intval((string) $args['mode'], 8);
1604 1604
 
1605 1605
 		if (!is_array($targets)) {
1606 1606
 			$targets = array($targets);
@@ -1615,10 +1615,10 @@  discard block
 block discarded – undo
1615 1615
 
1616 1616
 		$files = array();
1617 1617
 		$errors = array();
1618
-		foreach($targets as $target) {
1618
+		foreach ($targets as $target) {
1619 1619
 			$file = $volume->chmod($target, $mode);
1620 1620
 			if ($file) {
1621
-				$files = array_merge($files, is_array($file)? $file : array($file));
1621
+				$files = array_merge($files, is_array($file) ? $file : array($file));
1622 1622
 			} else {
1623 1623
 				$errors = array_merge($errors, $volume->error());
1624 1624
 			}
@@ -1649,9 +1649,9 @@  discard block
 block discarded – undo
1649 1649
 		$files  = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array();
1650 1650
 		$header = empty($args['html']) ? array() : array('header' => 'Content-Type: text/html; charset=utf-8');
1651 1651
 		$result = array_merge(array('added' => array()), $header);
1652
-		$paths  = $args['upload_path']? $args['upload_path'] : array();
1653
-		$chunk  = $args['chunk']? $args['chunk'] : '';
1654
-		$cid    = $args['cid']? (int)$args['cid'] : '';
1652
+		$paths  = $args['upload_path'] ? $args['upload_path'] : array();
1653
+		$chunk  = $args['chunk'] ? $args['chunk'] : '';
1654
+		$cid    = $args['cid'] ? (int) $args['cid'] : '';
1655 1655
 		
1656 1656
 		if (!$volume) {
1657 1657
 			return array_merge(array('error' => $this->error(self::ERROR_UPLOAD, self::ERROR_TRGDIR_NOT_FOUND, '#'.$target)), $header);
@@ -1680,7 +1680,7 @@  discard block
 block discarded – undo
1680 1680
 		if (empty($files)) {
1681 1681
 			if (isset($args['upload']) && is_array($args['upload']) && ($tempDir = $this->getTempDir($volume->getTempPath()))) {
1682 1682
 				$names = array();
1683
-				foreach($args['upload'] as $i => $url) {
1683
+				foreach ($args['upload'] as $i => $url) {
1684 1684
 					// check chunked file upload commit
1685 1685
 					if ($args['chunk']) {
1686 1686
 						if ($url === 'chunkfail' && $args['mimes'] === 'chunkfail') {
@@ -1690,7 +1690,7 @@  discard block
 block discarded – undo
1690 1690
 							}
1691 1691
 							return $result;
1692 1692
 						} else {
1693
-							$tmpfname = $tempDir . '/' . $args['chunk'];
1693
+							$tmpfname = $tempDir.'/'.$args['chunk'];
1694 1694
 							$files['tmp_name'][$i] = $tmpfname;
1695 1695
 							$files['name'][$i] = $url;
1696 1696
 							$files['error'][$i] = 0;
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
 						}
1700 1700
 					}
1701 1701
 					
1702
-					$tmpfname = $tempDir . DIRECTORY_SEPARATOR . 'ELF_FATCH_' . md5($url.microtime(true));
1702
+					$tmpfname = $tempDir.DIRECTORY_SEPARATOR.'ELF_FATCH_'.md5($url.microtime(true));
1703 1703
 					
1704 1704
 					$_name = '';
1705 1705
 					// check is data:
@@ -1734,8 +1734,8 @@  discard block
 block discarded – undo
1734 1734
 								list($_a, $_b) = array_pad(explode('.', $_name, 2), 2, '');
1735 1735
 								if ($_b === '') {
1736 1736
 									if ($_ext) {
1737
-										rename($tmpfname, $tmpfname . $_ext);
1738
-										$tmpfname = $tmpfname . $_ext;
1737
+										rename($tmpfname, $tmpfname.$_ext);
1738
+										$tmpfname = $tmpfname.$_ext;
1739 1739
 									}
1740 1740
 									$_b = $this->detectFileExtension($tmpfname);
1741 1741
 									$_name = $_a.$_b;
@@ -1770,7 +1770,7 @@  discard block
 block discarded – undo
1770 1770
 			}
1771 1771
 			
1772 1772
 			$tmpname = $files['tmp_name'][$i];
1773
-			$path = ($paths && !empty($paths[$i]))? $paths[$i] : '';
1773
+			$path = ($paths && !empty($paths[$i])) ? $paths[$i] : '';
1774 1774
 			if ($name === 'blob') {
1775 1775
 				if ($chunk) {
1776 1776
 					if ($tempDir = $this->getTempDir($volume->getTempPath())) {
@@ -1780,7 +1780,7 @@  discard block
 block discarded – undo
1780 1780
 								preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m);
1781 1781
 								$result['error'] = $this->error(self::ERROR_UPLOAD_FILE, $m[1], $tmpname);
1782 1782
 								$result['_chunkfailure'] = true;
1783
-								$this->uploadDebug = 'Upload error: ' . $tmpname;
1783
+								$this->uploadDebug = 'Upload error: '.$tmpname;
1784 1784
 							} else if ($name) {
1785 1785
 								$result['_chunkmerged'] = basename($tmpname);
1786 1786
 								$result['_name'] = $name;
@@ -1794,14 +1794,14 @@  discard block
 block discarded – undo
1794 1794
 				} else {
1795 1795
 					// for form clipboard with Google Chrome
1796 1796
 					$type = $files['type'][$i];
1797
-					$ext = isset($extTable[$type])? '.' . $extTable[$type] : '';
1798
-					$name = substr(md5(basename($tmpname)), 0, 8) . $ext;
1797
+					$ext = isset($extTable[$type]) ? '.'.$extTable[$type] : '';
1798
+					$name = substr(md5(basename($tmpname)), 0, 8).$ext;
1799 1799
 				}
1800 1800
 			}
1801 1801
 			
1802 1802
 			// do hook function 'upload.presave'
1803
-			if (! empty($this->listeners['upload.presave'])) {
1804
-				foreach($this->listeners['upload.presave'] as $handler) {
1803
+			if (!empty($this->listeners['upload.presave'])) {
1804
+				foreach ($this->listeners['upload.presave'] as $handler) {
1805 1805
 					call_user_func_array($handler, array(&$path, &$name, $tmpname, $this, $volume));
1806 1806
 				}
1807 1807
 			}
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
 			if (($fp = fopen($tmpname, 'rb')) == false) {
1810 1810
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER);
1811 1811
 				$this->uploadDebug = 'Upload error: unable open tmp file';
1812
-				if (! is_uploaded_file($tmpname)) {
1812
+				if (!is_uploaded_file($tmpname)) {
1813 1813
 					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]);
1814 1814
 					continue;
1815 1815
 				}
@@ -1820,18 +1820,18 @@  discard block
 block discarded – undo
1820 1820
 			} else {
1821 1821
 				$_target = $target;
1822 1822
 			}
1823
-			if (! $_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1823
+			if (!$_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1824 1824
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error());
1825 1825
 				fclose($fp);
1826
-				if (! is_uploaded_file($tmpname)) {
1827
-					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);;
1826
+				if (!is_uploaded_file($tmpname)) {
1827
+					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]); ;
1828 1828
 					continue;
1829 1829
 				}
1830 1830
 				break;
1831 1831
 			}
1832 1832
 			
1833 1833
 			is_resource($fp) && fclose($fp);
1834
-			if (! is_uploaded_file($tmpname)){
1834
+			if (!is_uploaded_file($tmpname)) {
1835 1835
 				clearstatcache();
1836 1836
 				if (!is_file($tmpname) || @ unlink($tmpname)) {
1837 1837
 					unset($GLOBALS['elFinderTempFiles'][$tmpname]);
@@ -1840,7 +1840,7 @@  discard block
 block discarded – undo
1840 1840
 			$result['added'][] = $file;
1841 1841
 		}
1842 1842
 		if ($GLOBALS['elFinderTempFiles']) {
1843
-			foreach(array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1843
+			foreach (array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1844 1844
 				@ unlink($_temp);
1845 1845
 			}
1846 1846
 		}
@@ -1909,9 +1909,9 @@  discard block
 block discarded – undo
1909 1909
 		}
1910 1910
 		
1911 1911
 		if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
1912
-			$mime = isset($file['mime'])? $file['mime'] : '';
1912
+			$mime = isset($file['mime']) ? $file['mime'] : '';
1913 1913
 			if ($mime && strtolower(substr($mime, 0, 4)) === 'text') {
1914
-				if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) {
1914
+				if ($enc = mb_detect_encoding($content, mb_detect_order(), true)) {
1915 1915
 					if (strtolower($enc) !== 'utf-8') {
1916 1916
 						$content = mb_convert_encoding($content, 'UTF-8', $enc);
1917 1917
 					}
@@ -1923,7 +1923,7 @@  discard block
 block discarded – undo
1923 1923
 
1924 1924
 		if ($json === false || strlen($json) < strlen($content)) {
1925 1925
 			if ($args['conv']) {
1926
-				return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
1926
+				return array('error' => $this->error(self::ERROR_CONV_UTF8, self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
1927 1927
 			} else {
1928 1928
 				return array('doconv' => true);
1929 1929
 			}
@@ -1965,7 +1965,7 @@  discard block
 block discarded – undo
1965 1965
 		$target = $args['target'];
1966 1966
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
1967 1967
 		$error  = array(self::ERROR_EXTRACT, '#'.$target);
1968
-		$makedir = isset($args['makedir'])? (bool)$args['makedir'] : null;
1968
+		$makedir = isset($args['makedir']) ? (bool) $args['makedir'] : null;
1969 1969
 
1970 1970
 		if (($volume = $this->volume($target)) == false
1971 1971
 		|| ($file = $volume->file($target)) == false) {
@@ -1973,7 +1973,7 @@  discard block
 block discarded – undo
1973 1973
 		}  
1974 1974
 
1975 1975
 		return ($file = $volume->extract($target, $makedir))
1976
-			? array('added' => isset($file['read'])? array($file) : $file)
1976
+			? array('added' => isset($file['read']) ? array($file) : $file)
1977 1977
 			: array('error' => $this->error(self::ERROR_EXTRACT, $volume->path($target), $volume->error()));
1978 1978
 	}
1979 1979
 	
@@ -1988,7 +1988,7 @@  discard block
 block discarded – undo
1988 1988
 	protected function archive($args) {
1989 1989
 		$type    = $args['type'];
1990 1990
 		$targets = isset($args['targets']) && is_array($args['targets']) ? $args['targets'] : array();
1991
-		$name    = isset($args['name'])? $args['name'] : '';
1991
+		$name    = isset($args['name']) ? $args['name'] : '';
1992 1992
 	
1993 1993
 		if (($volume = $this->volume($targets[0])) == false) {
1994 1994
 			return $this->error(self::ERROR_ARCHIVE, self::ERROR_TRGDIR_NOT_FOUND);
@@ -2009,7 +2009,7 @@  discard block
 block discarded – undo
2009 2009
 	protected function search($args) {
2010 2010
 		$q      = trim($args['q']);
2011 2011
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2012
-		$target = !empty($args['target'])? $args['target'] : null;
2012
+		$target = !empty($args['target']) ? $args['target'] : null;
2013 2013
 		$result = array();
2014 2014
 
2015 2015
 		if (!is_null($target)) {
@@ -2073,11 +2073,11 @@  discard block
 block discarded – undo
2073 2073
 		$target = $args['target'];
2074 2074
 		$width  = $args['width'];
2075 2075
 		$height = $args['height'];
2076
-		$x      = (int)$args['x'];
2077
-		$y      = (int)$args['y'];
2076
+		$x      = (int) $args['x'];
2077
+		$y      = (int) $args['y'];
2078 2078
 		$mode   = $args['mode'];
2079 2079
 		$bg     = null;
2080
-		$degree = (int)$args['degree'];
2080
+		$degree = (int) $args['degree'];
2081 2081
 		
2082 2082
 		if (($volume = $this->volume($target)) == false
2083 2083
 		|| ($file = $volume->file($target)) == false) {
@@ -2098,7 +2098,7 @@  discard block
 block discarded – undo
2098 2098
 	**/
2099 2099
 	protected function url($args) {
2100 2100
 		$target = $args['target'];
2101
-		$options = isset($args['options'])? $args['options'] : array();
2101
+		$options = isset($args['options']) ? $args['options'] : array();
2102 2102
 		if (($volume = $this->volume($target)) != false) {
2103 2103
 			$url = $volume->getContentUrl($target, $options);
2104 2104
 			return $url ? array('url' => $url) : array();
@@ -2115,18 +2115,18 @@  discard block
 block discarded – undo
2115 2115
 	 */
2116 2116
 	protected function callback($args) {
2117 2117
 		$checkReg = '/[^a-zA-Z0-9;._-]/';
2118
-		$node = (isset($args['node']) && !preg_match($checkReg, $args['node']))? $args['node'] : '';
2119
-		$json = (isset($args['json']) && @json_decode($args['json']))? $args['json'] : '{}';
2120
-		$bind  = (isset($args['bind']) && !preg_match($checkReg, $args['bind']))? $args['bind'] : '';
2118
+		$node = (isset($args['node']) && !preg_match($checkReg, $args['node'])) ? $args['node'] : '';
2119
+		$json = (isset($args['json']) && @json_decode($args['json'])) ? $args['json'] : '{}';
2120
+		$bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind'])) ? $args['bind'] : '';
2121 2121
 		$done = (!empty($args['done']));
2122 2122
 		
2123
-		while( ob_get_level() ) {
2124
-			if (! ob_end_clean()) {
2123
+		while (ob_get_level()) {
2124
+			if (!ob_end_clean()) {
2125 2125
 				break;
2126 2126
 			}
2127 2127
 		}
2128 2128
 		
2129
-		if ($done || ! $this->callbackWindowURL) {
2129
+		if ($done || !$this->callbackWindowURL) {
2130 2130
 			$script = '';
2131 2131
 			if ($node) {
2132 2132
 				$script .= '
@@ -2168,13 +2168,13 @@  discard block
 block discarded – undo
2168 2168
 			
2169 2169
 		} else {
2170 2170
 			$url = $this->callbackWindowURL;
2171
-			$url .= ((strpos($url, '?') === false)? '?' : '&')
2172
-				 . '&node=' . rawurlencode($node)
2173
-				 . (($json !== '{}')? ('&json=' . rawurlencode($json)) : '')
2174
-				 . ($bind? ('&bind=' .  rawurlencode($bind)) : '')
2171
+			$url .= ((strpos($url, '?') === false) ? '?' : '&')
2172
+				 . '&node='.rawurlencode($node)
2173
+				 . (($json !== '{}') ? ('&json='.rawurlencode($json)) : '')
2174
+				 . ($bind ? ('&bind='.rawurlencode($bind)) : '')
2175 2175
 				 . '&done=1';
2176 2176
 			
2177
-			header('Location: ' . $url);
2177
+			header('Location: '.$url);
2178 2178
 			
2179 2179
 		}
2180 2180
 		exit();
@@ -2244,7 +2244,7 @@  discard block
 block discarded – undo
2244 2244
 	
2245 2245
 	protected function utime() {
2246 2246
 		$time = explode(" ", microtime());
2247
-		return (double)$time[1] + (double)$time[0];
2247
+		return (double) $time[1] + (double) $time[0];
2248 2248
 	}
2249 2249
 	
2250 2250
 	
@@ -2270,7 +2270,7 @@  discard block
 block discarded – undo
2270 2270
 		$imgcnt = 0;
2271 2271
 		$fp = fopen($path, 'rb');
2272 2272
 		@fread($fp, 4);
2273
-		$c = @fread($fp,1);
2273
+		$c = @fread($fp, 1);
2274 2274
 		if (ord($c) != 0x39) {  // GIF89a
2275 2275
 			return false;
2276 2276
 		}
@@ -2278,13 +2278,13 @@  discard block
 block discarded – undo
2278 2278
 		while (!feof($fp)) {
2279 2279
 			do {
2280 2280
 				$c = fread($fp, 1);
2281
-			} while(ord($c) != 0x21 && !feof($fp));
2281
+			} while (ord($c) != 0x21 && !feof($fp));
2282 2282
 	
2283 2283
 			if (feof($fp)) {
2284 2284
 				break;
2285 2285
 			}
2286 2286
 	
2287
-			$c2 = fread($fp,2);
2287
+			$c2 = fread($fp, 2);
2288 2288
 			if (bin2hex($c2) == "f904") {
2289 2289
 				$imgcnt++;
2290 2290
 			}
Please login to merge, or discard this patch.
Braces   +19 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1241,8 +1241,12 @@  discard block
 block discarded – undo
1241 1241
 		
1242 1242
 		$query = $method.' '.$uri." HTTP/1.0\r\n";
1243 1243
 		$query .= "Host: ".$arr['host']."\r\n";
1244
-		if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n";
1245
-		if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n";
1244
+		if (!empty($ua)) {
1245
+			$query .= "User-Agent: ".$ua."\r\n";
1246
+		}
1247
+		if (!is_null($getSize)) {
1248
+			$query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n";
1249
+		}
1246 1250
 		
1247 1251
 		$query .= $headers;
1248 1252
 
@@ -1257,7 +1261,9 @@  discard block
 block discarded – undo
1257 1261
 			$arr['https'].$arr['host'],
1258 1262
 			$arr['port'],
1259 1263
 			$errno,$errstr,$connect_timeout);
1260
-			if ($fp) break;
1264
+			if ($fp) {
1265
+				break;
1266
+			}
1261 1267
 			$connect_try_count++;
1262 1268
 			if (connection_aborted()) {
1263 1269
 				exit();
@@ -1574,7 +1580,9 @@  discard block
 block discarded – undo
1574 1580
 		$tempDir = '';
1575 1581
 		$test = DIRECTORY_SEPARATOR . microtime(true);
1576 1582
 		foreach($testDirs as $testDir) {
1577
-			if (!$testDir || !is_dir($testDir)) continue;
1583
+			if (!$testDir || !is_dir($testDir)) {
1584
+				continue;
1585
+			}
1578 1586
 			$testFile = $testDir.$test;
1579 1587
 			if (touch($testFile)) {
1580 1588
 				unlink($testFile);
@@ -1810,7 +1818,9 @@  discard block
 block discarded – undo
1810 1818
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER);
1811 1819
 				$this->uploadDebug = 'Upload error: unable open tmp file';
1812 1820
 				if (! is_uploaded_file($tmpname)) {
1813
-					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]);
1821
+					if (@ unlink($tmpname)) {
1822
+						unset($GLOBALS['elFinderTempFiles'][$tmpfname]);
1823
+					}
1814 1824
 					continue;
1815 1825
 				}
1816 1826
 				break;
@@ -1824,7 +1834,10 @@  discard block
 block discarded – undo
1824 1834
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error());
1825 1835
 				fclose($fp);
1826 1836
 				if (! is_uploaded_file($tmpname)) {
1827
-					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);;
1837
+					if (@ unlink($tmpname)) {
1838
+						unset($GLOBALS['elFinderTempFiles'][$tmpname]);
1839
+					}
1840
+					;
1828 1841
 					continue;
1829 1842
 				}
1830 1843
 				break;
Please login to merge, or discard this patch.
php/elFinderVolumeDriver.class.php 4 patches
Doc Comments   +17 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1176,7 +1176,6 @@  discard block
 block discarded – undo
1176 1176
 	 * Return file info or false on error
1177 1177
 	 *
1178 1178
 	 * @param  string   $hash      file hash
1179
-	 * @param  bool     $realpath  add realpath field to file info
1180 1179
 	 * @return array|false
1181 1180
 	 * @author Dmitry (dio) Levashov
1182 1181
 	 **/
@@ -1197,7 +1196,6 @@  discard block
 block discarded – undo
1197 1196
 	 * Return folder info
1198 1197
 	 *
1199 1198
 	 * @param  string   $hash  folder hash
1200
-	 * @param  bool     $hidden  return hidden file info
1201 1199
 	 * @return array|false
1202 1200
 	 * @author Dmitry (dio) Levashov
1203 1201
 	 **/
@@ -1530,7 +1528,6 @@  discard block
 block discarded – undo
1530 1528
 	 *
1531 1529
 	 * @param  Resource $fp      file pointer
1532 1530
 	 * @param  string   $dst     destination folder hash
1533
-	 * @param  string   $src     file name
1534 1531
 	 * @param  string   $tmpname file tmp name - required to detect mime type
1535 1532
 	 * @return array|false
1536 1533
 	 * @author Dmitry (dio) Levashov
@@ -1616,7 +1613,6 @@  discard block
 block discarded – undo
1616 1613
 	 * Paste files
1617 1614
 	 *
1618 1615
 	 * @param  Object  $volume  source volume
1619
-	 * @param  string  $source  file hash
1620 1616
 	 * @param  string  $dst     destination dir hash
1621 1617
 	 * @param  bool    $rmSrc   remove source after copy?
1622 1618
 	 * @return array|false
@@ -2235,7 +2231,6 @@  discard block
 block discarded – undo
2235 2231
 	 * Open file and return file pointer (with convert encording)
2236 2232
 	 *
2237 2233
 	 * @param  string  $path  file path
2238
-	 * @param  bool    $write open file for writing
2239 2234
 	 * @return resource|false
2240 2235
 	 * @author Naoki Sawada
2241 2236
 	 **/
@@ -2366,7 +2361,8 @@  discard block
 block discarded – undo
2366 2361
 	 * Not implemented
2367 2362
 	 *
2368 2363
 	 * @param  string  path
2369
-	 * @return mixed
2364
+	 * @param string $path
2365
+	 * @return string
2370 2366
 	 * @author Dmitry (dio) Levashov
2371 2367
 	 **/
2372 2368
 	protected function crypt($path) {
@@ -2378,7 +2374,8 @@  discard block
 block discarded – undo
2378 2374
 	 * Not implemented
2379 2375
 	 *
2380 2376
 	 * @param  mixed  hash
2381
-	 * @return mixed
2377
+	 * @param string $hash
2378
+	 * @return string
2382 2379
 	 * @author Dmitry (dio) Levashov
2383 2380
 	 **/
2384 2381
 	protected function uncrypt($hash) {
@@ -2408,7 +2405,6 @@  discard block
 block discarded – undo
2408 2405
 	/**
2409 2406
 	 * Return new unique name based on file name and suffix
2410 2407
 	 *
2411
-	 * @param  string  $path    file path
2412 2408
 	 * @param  string  $suffix  suffix append to name
2413 2409
 	 * @return string
2414 2410
 	 * @author Dmitry (dio) Levashov
@@ -2476,6 +2472,7 @@  discard block
 block discarded – undo
2476 2472
 	 * @param  string $to      to character encoding
2477 2473
 	 * @param  string $locale  local locale
2478 2474
 	 * @param  string $unknown replaces character for unknown
2475
+	 * @param boolean $restoreLocale
2479 2476
 	 * @return mixed
2480 2477
 	 */
2481 2478
 	protected function convEnc($var, $from, $to, $locale, $restoreLocale, $unknown = '_') {
@@ -2657,6 +2654,7 @@  discard block
 block discarded – undo
2657 2654
 	 *
2658 2655
 	 * @param string $dir  parent dir path
2659 2656
 	 * @param string $name new file name
2657
+	 * @param boolean $isDir
2660 2658
 	 * @return bool
2661 2659
 	 * @author Dmitry (dio) Levashov
2662 2660
 	 **/
@@ -3186,7 +3184,7 @@  discard block
 block discarded – undo
3186 3184
 	 * @param  string  $src   source path
3187 3185
 	 * @param  string  $dst   destination dir path
3188 3186
 	 * @param  string  $name  new file name (optionaly)
3189
-	 * @return string|false
3187
+	 * @return boolean|string
3190 3188
 	 * @author Dmitry (dio) Levashov
3191 3189
 	 **/
3192 3190
 	protected function copy($src, $dst, $name) {
@@ -3239,7 +3237,7 @@  discard block
 block discarded – undo
3239 3237
 	 * @param  string  $src   source path
3240 3238
 	 * @param  string  $dst   destination dir path
3241 3239
 	 * @param  string  $name  new file name 
3242
-	 * @return string|false
3240
+	 * @return string|boolean
3243 3241
 	 * @author Dmitry (dio) Levashov
3244 3242
 	 **/
3245 3243
 	protected function move($src, $dst, $name) {
@@ -3265,7 +3263,7 @@  discard block
 block discarded – undo
3265 3263
 	 * @param  string  $src          source file hash
3266 3264
 	 * @param  string  $destination  destination dir path
3267 3265
 	 * @param  string  $name         file name
3268
-	 * @return string|false
3266
+	 * @return boolean|string
3269 3267
 	 * @author Dmitry (dio) Levashov
3270 3268
 	 **/
3271 3269
 	protected function copyFrom($volume, $src, $destination, $name) {
@@ -3409,7 +3407,7 @@  discard block
 block discarded – undo
3409 3407
 	 * @param  string  $path  thumnbnail path 
3410 3408
 	 * @param  array   $stat  file stat
3411 3409
 	 * @param  bool    $checkTmbPath
3412
-	 * @return string|bool
3410
+	 * @return boolean
3413 3411
 	 * @author Dmitry (dio) Levashov
3414 3412
 	 **/
3415 3413
 	protected function canCreateTmb($path, $stat, $checkTmbPath = true) {
@@ -3426,7 +3424,7 @@  discard block
 block discarded – undo
3426 3424
 	 *
3427 3425
 	 * @param  string  $path  thumnbnail path 
3428 3426
 	 * @param  array   $stat  file stat
3429
-	 * @return string|bool
3427
+	 * @return boolean
3430 3428
 	 * @author Dmitry (dio) Levashov
3431 3429
 	 **/
3432 3430
 	protected function canResize($path, $stat) {
@@ -3437,7 +3435,6 @@  discard block
 block discarded – undo
3437 3435
 	 * Create thumnbnail and return it's URL on success
3438 3436
 	 *
3439 3437
 	 * @param  string  $path  file path
3440
-	 * @param  string  $mime  file mime type
3441 3438
 	 * @return string|false
3442 3439
 	 * @author Dmitry (dio) Levashov
3443 3440
 	 **/
@@ -3897,7 +3894,7 @@  discard block
 block discarded – undo
3897 3894
 	 *
3898 3895
 	 * @param  string  $command       command line
3899 3896
 	 * @param  array   $output        stdout strings
3900
-	 * @param  array   $return_var    process exit code
3897
+	 * @param  integer   $return_var    process exit code
3901 3898
 	 * @param  array   $error_output  stderr strings
3902 3899
 	 * @return int     exit code
3903 3900
 	 * @author Alexey Sukhotin
@@ -4048,7 +4045,7 @@  discard block
 block discarded – undo
4048 4045
 	* @param  string  $haystack  The string being checked.
4049 4046
 	* @param  string  $needle    The string to find in haystack.
4050 4047
 	* @param  int     $offset    The search offset. If it is not specified, 0 is used.
4051
-	* @return int|bool
4048
+	* @return integer
4052 4049
 	* @author Alexey Sukhotin
4053 4050
 	**/
4054 4051
 	protected function stripos($haystack , $needle , $offset = 0) {
@@ -4273,7 +4270,7 @@  discard block
 block discarded – undo
4273 4270
 	 * @param  array   $files  files names list
4274 4271
 	 * @param  string  $name   archive name
4275 4272
 	 * @param  array   $arc    archiver options
4276
-	 * @return string|bool
4273
+	 * @return string|false
4277 4274
 	 * @author Dmitry (dio) Levashov, 
4278 4275
 	 * @author Alexey Sukhotin
4279 4276
 	 * @author Naoki Sawada
@@ -4330,7 +4327,7 @@  discard block
 block discarded – undo
4330 4327
 	 * @param  string        $dir      target dir
4331 4328
 	 * @param  array         $files    files names list
4332 4329
 	 * @param  string|object $zipPath  Zip archive name
4333
-	 * @return void
4330
+	 * @return boolean
4334 4331
 	 * @author Naoki Sawada
4335 4332
 	 */
4336 4333
 	protected static function zipArchiveZip($dir, $files, $zipPath) {
@@ -4533,7 +4530,6 @@  discard block
 block discarded – undo
4533 4530
 	 * Open file and return file pointer
4534 4531
 	 *
4535 4532
 	 * @param  string  $path  file path
4536
-	 * @param  bool    $write open file for writing
4537 4533
 	 * @return resource|false
4538 4534
 	 * @author Dmitry (dio) Levashov
4539 4535
 	 **/
@@ -4586,7 +4582,7 @@  discard block
 block discarded – undo
4586 4582
 	 * Copy file into another file (only inside one volume)
4587 4583
 	 *
4588 4584
 	 * @param  string  $source  source file path
4589
-	 * @param  string  $target  target dir path
4585
+	 * @param  string  $targetDir  target dir path
4590 4586
 	 * @param  string  $name    file name
4591 4587
 	 * @return bool
4592 4588
 	 * @author Dmitry (dio) Levashov
@@ -4598,7 +4594,7 @@  discard block
 block discarded – undo
4598 4594
 	 * Return new file path or false.
4599 4595
 	 *
4600 4596
 	 * @param  string  $source  source file path
4601
-	 * @param  string  $target  target dir path
4597
+	 * @param  string  $targetDir  target dir path
4602 4598
 	 * @param  string  $name    file name
4603 4599
 	 * @return string|bool
4604 4600
 	 * @author Dmitry (dio) Levashov
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Base class for elFinder volume.
4
- * Provide 2 layers:
5
- *  1. Public API (commands)
6
- *  2. abstract fs API
7
- *
8
- * All abstract methods begin with "_"
9
- *
10
- * @author Dmitry (dio) Levashov
11
- * @author Troex Nevelin
12
- * @author Alexey Sukhotin
13
- **/
3
+	 * Base class for elFinder volume.
4
+	 * Provide 2 layers:
5
+	 *  1. Public API (commands)
6
+	 *  2. abstract fs API
7
+	 *
8
+	 * All abstract methods begin with "_"
9
+	 *
10
+	 * @author Dmitry (dio) Levashov
11
+	 * @author Troex Nevelin
12
+	 * @author Alexey Sukhotin
13
+	 **/
14 14
 abstract class elFinderVolumeDriver {
15 15
 	
16 16
 	/**
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 		'mimefile'        => '',
193 193
 		// mime type normalize map : Array '[ext]:[detected mime type]' => '[normalized mime]'
194 194
 		'mimeMap'         => array(
195
-		                     'md:application/x-genesis-rom' => 'text/x-markdown',
196
-		                     'md:text/plain'                => 'text/x-markdown',
197
-		                     'markdown:text/plain'          => 'text/x-markdown',
198
-		                     'css:text/x-asm'               => 'text/css'
199
-		                    ),
195
+							 'md:application/x-genesis-rom' => 'text/x-markdown',
196
+							 'md:text/plain'                => 'text/x-markdown',
197
+							 'markdown:text/plain'          => 'text/x-markdown',
198
+							 'css:text/x-asm'               => 'text/css'
199
+							),
200 200
 		// directory for thumbnails
201 201
 		'tmbPath'         => '.tmb',
202 202
 		// mode to create thumbnails dir
@@ -4043,14 +4043,14 @@  discard block
 block discarded – undo
4043 4043
 	// }
4044 4044
 
4045 4045
 	/**
4046
-	* Find position of first occurrence of string in a string with multibyte support
4047
-	*
4048
-	* @param  string  $haystack  The string being checked.
4049
-	* @param  string  $needle    The string to find in haystack.
4050
-	* @param  int     $offset    The search offset. If it is not specified, 0 is used.
4051
-	* @return int|bool
4052
-	* @author Alexey Sukhotin
4053
-	**/
4046
+	 * Find position of first occurrence of string in a string with multibyte support
4047
+	 *
4048
+	 * @param  string  $haystack  The string being checked.
4049
+	 * @param  string  $needle    The string to find in haystack.
4050
+	 * @param  int     $offset    The search offset. If it is not specified, 0 is used.
4051
+	 * @return int|bool
4052
+	 * @author Alexey Sukhotin
4053
+	 **/
4054 4054
 	protected function stripos($haystack , $needle , $offset = 0) {
4055 4055
 		if (function_exists('mb_stripos')) {
4056 4056
 			return mb_stripos($haystack , $needle , $offset);
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -859,7 +859,9 @@  discard block
 block discarded – undo
859 859
 
860 860
 		// This get's triggered if $this->root == '/' and alias is empty.
861 861
 		// Maybe modify _basename instead?
862
-		if ($this->rootName === '') $this->rootName = $this->separator;
862
+		if ($this->rootName === '') {
863
+			$this->rootName = $this->separator;
864
+		}
863 865
 
864 866
 		$root = $this->stat($this->root);
865 867
 		
@@ -2938,7 +2940,9 @@  discard block
 block discarded – undo
2938 2940
 		if ($this->mimeDetect == 'finfo') {
2939 2941
 			if ($type = @finfo_file($this->finfo, $path)) {
2940 2942
 				if ($ext && preg_match('~^application/(?:octet-stream|(?:x-)?zip)~', $type)) {
2941
-					if (isset(elFinderVolumeDriver::$mimetypes[$ext])) $type = elFinderVolumeDriver::$mimetypes[$ext];
2943
+					if (isset(elFinderVolumeDriver::$mimetypes[$ext])) {
2944
+						$type = elFinderVolumeDriver::$mimetypes[$ext];
2945
+					}
2942 2946
 				} else if ($ext === 'js' && preg_match('~^text/~', $type)) {
2943 2947
 					$type = 'text/javascript';
2944 2948
 				}
@@ -4013,7 +4017,7 @@  discard block
 block discarded – undo
4013 4017
 			imagesavealpha($image,true);
4014 4018
 			$bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127);
4015 4019
 
4016
-		}else{
4020
+		} else{
4017 4021
 			list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4018 4022
 			$bgcolor1 = imagecolorallocate($image, $r, $g, $b);
4019 4023
 		}
@@ -4203,7 +4207,9 @@  discard block
 block discarded – undo
4203 4207
 		}
4204 4208
 		
4205 4209
 		// 'Here'
4206
-		if ($path === '' || $path === '.' . $separator) return $base;
4210
+		if ($path === '' || $path === '.' . $separator) {
4211
+			return $base;
4212
+		}
4207 4213
 		
4208 4214
 		// Absolute path
4209 4215
 		if ($path[0] === $separator || strpos($path, $systemroot) === 0) {
Please login to merge, or discard this patch.
Spacing   +130 added lines, -131 removed lines patch added patch discarded remove patch
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 		'utf8fix'      => false,
275 275
 		 //                           й                 ё              Й               Ё              Ø         Å
276 276
 		'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"),
277
-		'utf8replace'  => array("\u0439",        "\u0451",       "\u0419",       "\u0401",       "\u00d8", "\u00c5")
277
+		'utf8replace'  => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5")
278 278
 	);
279 279
 
280 280
 	/**
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 **/
567 567
 	protected function configure() {
568 568
 		// set ARGS
569
-		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET;
569
+		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
570 570
 		// set thumbnails path
571 571
 		$path = $this->options['tmbPath'];
572 572
 		if ($path) {
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 		
598 598
 		// check 'statOwner' for command `chmod`
599 599
 		if (empty($this->options['statOwner'])) {
600
-			$this->disabled[] ='chmod';
600
+			$this->disabled[] = 'chmod';
601 601
 		}
602 602
 		
603 603
 		// check 'mimeMap'
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	 **/
703 703
 	public function mount(array $opts) {
704 704
 		if (!isset($opts['path']) || $opts['path'] === '') {
705
-			return $this->setError('Path undefined.');;
705
+			return $this->setError('Path undefined.'); ;
706 706
 		}
707 707
 		
708 708
 		$this->options = array_merge($this->options, $opts);
@@ -721,14 +721,14 @@  discard block
 block discarded – undo
721 721
 		$argInit = !empty($this->ARGS['init']);
722 722
 		
723 723
 		// session cache
724
-		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
724
+		if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
725 725
 			$_SESSION[elFinder::$sessionCacheKey][$this->id] = array();
726 726
 		}
727 727
 		$this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id];
728 728
 		
729 729
 		// default file attribute
730 730
 		$this->defaults = array(
731
-			'read'    => isset($this->options['defaults']['read'])  ? !!$this->options['defaults']['read']  : true,
731
+			'read'    => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true,
732 732
 			'write'   => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true,
733 733
 			'locked'  => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false,
734 734
 			'hidden'  => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false
@@ -755,8 +755,8 @@  discard block
 block discarded – undo
755 755
 			$this->access = $this->options['accessControl'];
756 756
 		}
757 757
 		
758
-		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y'));
759
-		$this->yesterday = $this->today-86400;
758
+		$this->today     = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
759
+		$this->yesterday = $this->today - 86400;
760 760
 		
761 761
 		// debug($this->attributes);
762 762
 		if (!$this->init()) {
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 				foreach ($mimecf as $line_num => $line) {
856 856
 					if (!preg_match('/^\s*#/', $line)) {
857 857
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
858
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
858
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
859 859
 							if (!isset(self::$mimetypes[$mime[$i]])) {
860 860
 								self::$mimetypes[$mime[$i]] = $mime[0];
861 861
 							}
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
 				'read'    => false
908 908
 			));
909 909
 		}
910
-		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1;
911
-		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48;
910
+		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1;
911
+		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48;
912 912
 		$this->URL      = $this->options['URL'];
913 913
 		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) {
914 914
 			$this->URL .= '/';
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 	public function options($hash) {
1036 1036
 		$create = $createext = array();
1037 1037
 		if (isset($this->archivers['create']) && is_array($this->archivers['create'])) {
1038
-			foreach($this->archivers['create'] as $m => $v) {
1038
+			foreach ($this->archivers['create'] as $m => $v) {
1039 1039
 				$create[] = $m;
1040 1040
 				$createext[$m] = $v['ext'];
1041 1041
 			}
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 				'extract' => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(),
1054 1054
 				'createext' => $createext
1055 1055
 			),
1056
-			'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array()
1056
+			'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array()
1057 1057
 		);
1058 1058
 	}
1059 1059
 	
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
 	 */
1067 1067
 	public function getOptionsPlugin($name = '') {
1068 1068
 		if ($name) {
1069
-			return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array();
1069
+			return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array();
1070 1070
 		} else {
1071 1071
 			return $this->options['plugin'];
1072 1072
 		}
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 		$file = $this->stat($path);
1197 1197
 		
1198 1198
 		if ($hash === $this->root()) {
1199
-			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array();
1199
+			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array();
1200 1200
 			$file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON
1201 1201
 		}
1202 1202
 		
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 	 * @return array|false
1212 1212
 	 * @author Dmitry (dio) Levashov
1213 1213
 	 **/
1214
-	public function dir($hash, $resolveLink=false) {
1214
+	public function dir($hash, $resolveLink = false) {
1215 1215
 		if (($dir = $this->file($hash)) == false) {
1216 1216
 			return $this->setError(elFinder::ERROR_DIR_NOT_FOUND);
1217 1217
 		}
@@ -1275,14 +1275,14 @@  discard block
 block discarded – undo
1275 1275
 	 * @return array|false
1276 1276
 	 * @author Dmitry (dio) Levashov
1277 1277
 	 **/
1278
-	public function tree($hash='', $deep=0, $exclude='') {
1278
+	public function tree($hash = '', $deep = 0, $exclude = '') {
1279 1279
 		$path = $hash ? $this->decode($hash) : $this->root;
1280 1280
 		
1281 1281
 		if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') {
1282 1282
 			return false;
1283 1283
 		}
1284 1284
 		
1285
-		$dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null);
1285
+		$dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null);
1286 1286
 		array_unshift($dirs, $dir);
1287 1287
 		return $dirs;
1288 1288
 	}
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
 	 * @return array|false
1513 1513
 	 * @author Dmitry (dio) Levashov
1514 1514
 	 **/
1515
-	public function duplicate($hash, $suffix='copy') {
1515
+	public function duplicate($hash, $suffix = 'copy') {
1516 1516
 		if ($this->commandDisabled('duplicate')) {
1517 1517
 			return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED);
1518 1518
 		}
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
 		
1589 1589
 		if ($file) { // file exists
1590 1590
 			// check POST data `overwrite` for 3rd party uploader
1591
-			$overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite'];
1591
+			$overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite'];
1592 1592
 			if ($overwrite) {
1593 1593
 				if (!$file['write']) {
1594 1594
 					return $this->setError(elFinder::ERROR_PERM_DENIED);
@@ -1659,7 +1659,7 @@  discard block
 block discarded – undo
1659 1659
 		if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) {
1660 1660
 			return $rmSrc
1661 1661
 				? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test))
1662
-				: $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1662
+				: $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1663 1663
 		}
1664 1664
 
1665 1665
 		$test = $this->joinPathCE($destination, $name);
@@ -1822,7 +1822,7 @@  discard block
 block discarded – undo
1822 1822
 			return $this->setError(elFinder::ERROR_PERM_DENIED);
1823 1823
 		}
1824 1824
 		$this->clearcache();
1825
-		$this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir;
1825
+		$this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir;
1826 1826
 		
1827 1827
 		if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) {
1828 1828
 			if (is_array($path)) {
@@ -1880,9 +1880,9 @@  discard block
 block discarded – undo
1880 1880
 		if ($name === '') {
1881 1881
 			$name = count($files) == 1 ? $files[0] : 'Archive';
1882 1882
 		} else {
1883
-			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name));
1883
+			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name));
1884 1884
 		}
1885
-		$name .='.' . $archiver['ext'];
1885
+		$name .= '.'.$archiver['ext'];
1886 1886
 		$name = $this->uniqueName($dir, $name, '');
1887 1887
 		$this->clearcache();
1888 1888
 		return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false;
@@ -1918,7 +1918,7 @@  discard block
 block discarded – undo
1918 1918
 		
1919 1919
 		$path = $this->decode($hash);
1920 1920
 		
1921
-		$work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path);
1921
+		$work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path);
1922 1922
 
1923 1923
 		if (!$work_path || !is_writable($work_path)) {
1924 1924
 			if ($work_path && $path !== $work_path && is_file($work_path)) {
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
 			}
1934 1934
 		}
1935 1935
 
1936
-		switch($mode) {
1936
+		switch ($mode) {
1937 1937
 			
1938 1938
 			case 'propresize':
1939 1939
 				$result = $this->imgResize($work_path, $width, $height, true, true);
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
 		}
2030 2030
 		return ($q === '' || $this->commandDisabled('search'))
2031 2031
 			? array()
2032
-			: $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes);
2032
+			: $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes);
2033 2033
 	}
2034 2034
 	
2035 2035
 	/**
@@ -2098,9 +2098,9 @@  discard block
 block discarded – undo
2098 2098
 		$path = ltrim($path, $this->separator);
2099 2099
 		$dirs = explode($this->separator, $path);
2100 2100
 		array_pop($dirs);
2101
-		foreach($dirs as $dir) {
2101
+		foreach ($dirs as $dir) {
2102 2102
 			$targetPath = $this->joinPathCE($base, $dir);
2103
-			if (! $_realpath = $this->realpath($this->encode($targetPath))) {
2103
+			if (!$_realpath = $this->realpath($this->encode($targetPath))) {
2104 2104
 				if ($stat = $this->mkdir($targetHash, $dir)) {
2105 2105
 					$result['added'][] = $stat;
2106 2106
 					$targetHash = $stat['hash'];
@@ -2167,7 +2167,7 @@  discard block
 block discarded – undo
2167 2167
 	 * @author Naoki Sawada
2168 2168
 	 **/
2169 2169
 	protected function dirnameCE($path) {
2170
-		return (!$this->encoding)? $this->_dirname($path) :	$this->convEncOut($this->_dirname($this->convEncIn($path)));
2170
+		return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path)));
2171 2171
 	}
2172 2172
 	
2173 2173
 	/**
@@ -2178,7 +2178,7 @@  discard block
 block discarded – undo
2178 2178
 	 * @author Naoki Sawada
2179 2179
 	 **/
2180 2180
 	protected function basenameCE($path) {
2181
-		return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2181
+		return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2182 2182
 	}
2183 2183
 	
2184 2184
 	/**
@@ -2191,7 +2191,7 @@  discard block
 block discarded – undo
2191 2191
 	 * @author Naoki Sawada
2192 2192
 	 **/
2193 2193
 	protected function joinPathCE($dir, $name) {
2194
-		return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2194
+		return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2195 2195
 	}
2196 2196
 	
2197 2197
 	/**
@@ -2202,7 +2202,7 @@  discard block
 block discarded – undo
2202 2202
 	 * @author Naoki Sawada
2203 2203
 	 **/
2204 2204
 	protected function normpathCE($path) {
2205
-		return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2205
+		return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2206 2206
 	}
2207 2207
 	
2208 2208
 	/**
@@ -2213,7 +2213,7 @@  discard block
 block discarded – undo
2213 2213
 	 * @author Naoki Sawada
2214 2214
 	 **/
2215 2215
 	protected function relpathCE($path) {
2216
-		return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2216
+		return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2217 2217
 	}
2218 2218
 	
2219 2219
 	/**
@@ -2224,7 +2224,7 @@  discard block
 block discarded – undo
2224 2224
 	 * @author Naoki Sawada
2225 2225
 	 **/
2226 2226
 	protected function abspathCE($path) {
2227
-		return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path)));
2227
+		return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path)));
2228 2228
 	}
2229 2229
 	
2230 2230
 	/**
@@ -2236,7 +2236,7 @@  discard block
 block discarded – undo
2236 2236
 	 * @author Naoki Sawada
2237 2237
 	 **/
2238 2238
 	protected function inpathCE($path, $parent) {
2239
-		return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2239
+		return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2240 2240
 	}
2241 2241
 	
2242 2242
 	/**
@@ -2247,8 +2247,8 @@  discard block
 block discarded – undo
2247 2247
 	 * @return resource|false
2248 2248
 	 * @author Naoki Sawada
2249 2249
 	 **/
2250
-	protected function fopenCE($path, $mode='rb') {
2251
-		return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2250
+	protected function fopenCE($path, $mode = 'rb') {
2251
+		return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2252 2252
 	}
2253 2253
 	
2254 2254
 	/**
@@ -2259,8 +2259,8 @@  discard block
 block discarded – undo
2259 2259
 	 * @return bool
2260 2260
 	 * @author Naoki Sawada
2261 2261
 	 **/
2262
-	protected function fcloseCE($fp, $path='') {
2263
-		return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2262
+	protected function fcloseCE($fp, $path = '') {
2263
+		return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2264 2264
 	}
2265 2265
 	
2266 2266
 	/**
@@ -2275,7 +2275,7 @@  discard block
 block discarded – undo
2275 2275
 	 * @author Naoki Sawada
2276 2276
 	 **/
2277 2277
 	protected function saveCE($fp, $dir, $name, $stat) {
2278
-		return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2278
+		return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2279 2279
 	}
2280 2280
 	
2281 2281
 	/**
@@ -2287,7 +2287,7 @@  discard block
 block discarded – undo
2287 2287
 	 **/
2288 2288
 	protected function subdirsCE($path) {
2289 2289
 		if (!isset($this->subdirsCache[$path])) {
2290
-			$this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2290
+			$this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2291 2291
 		}
2292 2292
 		return $this->subdirsCache[$path];
2293 2293
 	}
@@ -2300,7 +2300,7 @@  discard block
 block discarded – undo
2300 2300
 	 * @author Naoki Sawada
2301 2301
 	 **/
2302 2302
 	protected function scandirCE($path) {
2303
-		return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2303
+		return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2304 2304
 	}
2305 2305
 	
2306 2306
 	/**
@@ -2313,7 +2313,7 @@  discard block
 block discarded – undo
2313 2313
 	 * @author Naoki Sawada
2314 2314
 	 **/
2315 2315
 	protected function symlinkCE($source, $targetDir, $name) {
2316
-		return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2316
+		return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2317 2317
 	}
2318 2318
 	
2319 2319
 	/***************** paths *******************/
@@ -2332,7 +2332,7 @@  discard block
 block discarded – undo
2332 2332
 			// cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root
2333 2333
 			$p = $this->relpathCE($path);
2334 2334
 			// if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt
2335
-			if ($p === '')	{
2335
+			if ($p === '') {
2336 2336
 				$p = DIRECTORY_SEPARATOR;
2337 2337
 			}
2338 2338
 
@@ -2365,7 +2365,7 @@  discard block
 block discarded – undo
2365 2365
 			// TODO uncrypt hash and return path
2366 2366
 			$path = $this->uncrypt($h); 
2367 2367
 			// append ROOT to path after it was cut in encode
2368
-			return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2368
+			return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2369 2369
 		}
2370 2370
 	}
2371 2371
 	
@@ -2421,22 +2421,22 @@  discard block
 block discarded – undo
2421 2421
 	 * @return string
2422 2422
 	 * @author Dmitry (dio) Levashov
2423 2423
 	 **/
2424
-	public function uniqueName($dir, $name, $suffix = ' copy', $checkNum=true) {
2425
-		$ext  = '';
2424
+	public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true) {
2425
+		$ext = '';
2426 2426
 
2427 2427
 		if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
2428 2428
 			$ext  = '.'.$m[1];
2429
-			$name = substr($name, 0,  strlen($name)-strlen($m[0]));
2429
+			$name = substr($name, 0, strlen($name) - strlen($m[0]));
2430 2430
 		} 
2431 2431
 		
2432 2432
 		if ($checkNum && preg_match('/('.$suffix.')(\d*)$/i', $name, $m)) {
2433
-			$i    = (int)$m[2];
2434
-			$name = substr($name, 0, strlen($name)-strlen($m[2]));
2433
+			$i    = (int) $m[2];
2434
+			$name = substr($name, 0, strlen($name) - strlen($m[2]));
2435 2435
 		} else {
2436 2436
 			$i     = 1;
2437 2437
 			$name .= $suffix;
2438 2438
 		}
2439
-		$max = $i+100000;
2439
+		$max = $i + 100000;
2440 2440
 
2441 2441
 		while ($i <= $max) {
2442 2442
 			$n = $name.($i > 0 ? $i : '').$ext;
@@ -2460,7 +2460,7 @@  discard block
 block discarded – undo
2460 2460
 	 * @author Naoki Sawada
2461 2461
 	 */
2462 2462
 	public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') {
2463
-		return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2463
+		return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2464 2464
 	}
2465 2465
 	
2466 2466
 	/**
@@ -2473,7 +2473,7 @@  discard block
 block discarded – undo
2473 2473
 	 * @author Naoki Sawada
2474 2474
 	 */
2475 2475
 	public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') {
2476
-		return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2476
+		return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2477 2477
 	}
2478 2478
 	
2479 2479
 	/**
@@ -2493,7 +2493,7 @@  discard block
 block discarded – undo
2493 2493
 			}
2494 2494
 			if (is_array($var)) {
2495 2495
 				$_ret = array();
2496
-				foreach($var as $_k => $_v) {
2496
+				foreach ($var as $_k => $_v) {
2497 2497
 					$_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_');
2498 2498
 				}
2499 2499
 				$var = $_ret;
@@ -2505,7 +2505,7 @@  discard block
 block discarded – undo
2505 2505
 						$_var = str_replace('?', $unknown, $_var);
2506 2506
 					}
2507 2507
 				}
2508
-				if  ($_var !== false) {
2508
+				if ($_var !== false) {
2509 2509
 					$var = $_var;
2510 2510
 				}
2511 2511
 			}
@@ -2532,7 +2532,7 @@  discard block
 block discarded – undo
2532 2532
 		
2533 2533
 		$key = '';
2534 2534
 		if ($path !== '') {
2535
-			$key = $this->id . '#' . $path;
2535
+			$key = $this->id.'#'.$path;
2536 2536
 			if (isset($cache[$key])) {
2537 2537
 				return $cache[$key];
2538 2538
 			}
@@ -2564,7 +2564,7 @@  discard block
 block discarded – undo
2564 2564
 		if ($work = $this->getTempFile()) {
2565 2565
 			if ($wfp = fopen($work, 'wb')) {
2566 2566
 				if ($fp = $this->_fopen($path)) {
2567
-					while(!feof($fp)) {
2567
+					while (!feof($fp)) {
2568 2568
 						fwrite($wfp, fread($fp, 8192));
2569 2569
 					}
2570 2570
 					$this->_fclose($fp, $path);
@@ -2608,7 +2608,7 @@  discard block
 block discarded – undo
2608 2608
 			@set_time_limit(30);
2609 2609
 			$stat = $this->stat($this->convEncOut($p));
2610 2610
 			$this->convEncIn();
2611
-			($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p);
2611
+			($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p);
2612 2612
 		}
2613 2613
 		return $this->_rmdir($localpath);
2614 2614
 	}
@@ -2625,7 +2625,7 @@  discard block
 block discarded – undo
2625 2625
 	 * @return bool
2626 2626
 	 * @author Dmitry (dio) Levashov
2627 2627
 	 **/
2628
-	protected function attr($path, $name, $val=null, $isDir=null) {
2628
+	protected function attr($path, $name, $val = null, $isDir = null) {
2629 2629
 		if (!isset($this->defaults[$name])) {
2630 2630
 			return false;
2631 2631
 		}
@@ -2657,7 +2657,7 @@  discard block
 block discarded – undo
2657 2657
 			} 
2658 2658
 		}
2659 2659
 		
2660
-		return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm;
2660
+		return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm;
2661 2661
 	}
2662 2662
 	
2663 2663
 	/**
@@ -2701,7 +2701,7 @@  discard block
 block discarded – undo
2701 2701
 	protected function allowPutMime($mime) {
2702 2702
 		// logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order
2703 2703
 		$allow  = $this->mimeAccepted($mime, $this->uploadAllow, null);
2704
-		$deny   = $this->mimeAccepted($mime, $this->uploadDeny,  null);
2704
+		$deny   = $this->mimeAccepted($mime, $this->uploadDeny, null);
2705 2705
 		$res = true; // default to allow
2706 2706
 		if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny'
2707 2707
 			$res = false; // default is deny
@@ -2772,10 +2772,10 @@  discard block
 block discarded – undo
2772 2772
 			if ($this->rootName) {
2773 2773
 				$stat['name'] = $this->rootName;
2774 2774
 			}
2775
-			if (! empty($this->options['icon'])) {
2775
+			if (!empty($this->options['icon'])) {
2776 2776
 				$stat['icon'] = $this->options['icon'];
2777 2777
 			}
2778
-			if (! empty($this->options['rootCssClass'])) {
2778
+			if (!empty($this->options['rootCssClass'])) {
2779 2779
 				$stat['csscls'] = $this->options['rootCssClass'];
2780 2780
 			}
2781 2781
 		} else {
@@ -2819,7 +2819,7 @@  discard block
 block discarded – undo
2819 2819
 			// lock when parent directory is not writable
2820 2820
 			if (!isset($stat['locked'])) {
2821 2821
 				$parent = $this->dirnameCE($path);
2822
-				$pstat = isset($this->cache[$parent])? $this->cache[$parent] : array();
2822
+				$pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array();
2823 2823
 				if (isset($pstat['write']) && !$pstat['write']) {
2824 2824
 					$stat['locked'] = true;
2825 2825
 				}
@@ -2877,7 +2877,7 @@  discard block
 block discarded – undo
2877 2877
 			}
2878 2878
 			if (!isset($stat['url']) && $this->URL && $this->encoding) {
2879 2879
 				$_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1));
2880
-				$stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true)));
2880
+				$stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true)));
2881 2881
 			}
2882 2882
 		} else {
2883 2883
 			if ($isDir) {
@@ -3120,7 +3120,7 @@  discard block
 block discarded – undo
3120 3120
 	 * @return array
3121 3121
 	 * @author Dmitry (dio) Levashov
3122 3122
 	 **/
3123
-	protected function gettree($path, $deep, $exclude='') {
3123
+	protected function gettree($path, $deep, $exclude = '') {
3124 3124
 		$dirs = array();
3125 3125
 		
3126 3126
 		!isset($this->dirsCache[$path]) && $this->cacheDir($path);
@@ -3131,7 +3131,7 @@  discard block
 block discarded – undo
3131 3131
 			if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') {
3132 3132
 				$dirs[] = $stat;
3133 3133
 				if ($deep > 0 && !empty($stat['dirs'])) {
3134
-					$dirs = array_merge($dirs, $this->gettree($p, $deep-1));
3134
+					$dirs = array_merge($dirs, $this->gettree($p, $deep - 1));
3135 3135
 				}
3136 3136
 			}
3137 3137
 		}
@@ -3151,7 +3151,7 @@  discard block
 block discarded – undo
3151 3151
 	protected function doSearch($path, $q, $mimes) {
3152 3152
 		$result = array();
3153 3153
 
3154
-		foreach($this->scandirCE($path) as $p) {
3154
+		foreach ($this->scandirCE($path) as $p) {
3155 3155
 			@set_time_limit(30);
3156 3156
 			$stat = $this->stat($p);
3157 3157
 
@@ -3172,7 +3172,7 @@  discard block
 block discarded – undo
3172 3172
 					if ($this->encoding) {
3173 3173
 						$path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true)));
3174 3174
 					}
3175
-					$stat['url'] = $this->URL . $path;
3175
+					$stat['url'] = $this->URL.$path;
3176 3176
 				}
3177 3177
 				
3178 3178
 				$result[] = $stat;
@@ -3206,7 +3206,7 @@  discard block
 block discarded – undo
3206 3206
 			if (!$this->inpathCE($target, $this->root)) {
3207 3207
 				return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK);
3208 3208
 			}
3209
-			$stat   = $this->stat($target);
3209
+			$stat = $this->stat($target);
3210 3210
 			$this->clearcache();
3211 3211
 			return $stat && $this->symlinkCE($target, $dst, $name)
3212 3212
 				? $this->joinPathCE($dst, $name)
@@ -3483,15 +3483,15 @@  discard block
 block discarded – undo
3483 3483
 		}
3484 3484
 
3485 3485
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
3486
-		if ($s[0] <= $tmbSize && $s[1]	<= $tmbSize) {
3487
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3486
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
3487
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3488 3488
 		} else {
3489 3489
 		
3490 3490
 			if ($this->options['tmbCrop']) {
3491 3491
 		
3492 3492
 				$result = $tmb;
3493 3493
 				/* Resize and crop if image bigger than thumbnail */
3494
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3494
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3495 3495
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
3496 3496
 				}
3497 3497
 		
@@ -3508,7 +3508,7 @@  discard block
 block discarded – undo
3508 3508
 			}
3509 3509
 		
3510 3510
 			if ($result) {
3511
-				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3511
+				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3512 3512
 			}
3513 3513
 		}
3514 3514
 		
@@ -3549,18 +3549,18 @@  discard block
 block discarded – undo
3549 3549
 			/* Resizing by biggest side */
3550 3550
 			if ($resizeByBiggerSide) {
3551 3551
 				if ($orig_w > $orig_h) {
3552
-					$size_h = round($orig_h * $width / $orig_w);
3552
+					$size_h = round($orig_h*$width/$orig_w);
3553 3553
 					$size_w = $width;
3554 3554
 				} else {
3555
-					$size_w = round($orig_w * $height / $orig_h);
3555
+					$size_w = round($orig_w*$height/$orig_h);
3556 3556
 					$size_h = $height;
3557 3557
 				}
3558 3558
 			} else {
3559 3559
 				if ($orig_w > $orig_h) {
3560
-					$size_w = round($orig_w * $height / $orig_h);
3560
+					$size_w = round($orig_w*$height/$orig_h);
3561 3561
 					$size_h = $height;
3562 3562
 				} else {
3563
-					$size_h = round($orig_h * $width / $orig_w);
3563
+					$size_h = round($orig_h*$width/$orig_w);
3564 3564
 					$size_w = $width;
3565 3565
 				}
3566 3566
 			}
@@ -3578,7 +3578,7 @@  discard block
 block discarded – undo
3578 3578
 				// Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb
3579 3579
 				// resize bench: http://app-mgng.rhcloud.com/9
3580 3580
 				// resize sample: http://www.dylanbeattie.net/magick/filters/result.html
3581
-				$filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3581
+				$filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3582 3582
 				
3583 3583
 				$ani = ($img->getNumberImages() > 1);
3584 3584
 				if ($ani && is_null($destformat)) {
@@ -3603,11 +3603,11 @@  discard block
 block discarded – undo
3603 3603
 				break;
3604 3604
 
3605 3605
 			case 'gd':
3606
-				$img = self::gdImageCreate($path,$s['mime']);
3606
+				$img = self::gdImageCreate($path, $s['mime']);
3607 3607
 
3608
-				if ($img &&  false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3608
+				if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3609 3609
 				
3610
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3610
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3611 3611
 					
3612 3612
 					if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) {
3613 3613
 						return false;
@@ -3683,11 +3683,11 @@  discard block
 block discarded – undo
3683 3683
 				break;
3684 3684
 
3685 3685
 			case 'gd':
3686
-				$img = self::gdImageCreate($path,$s['mime']);
3686
+				$img = self::gdImageCreate($path, $s['mime']);
3687 3687
 
3688
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3688
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3689 3689
 					
3690
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3690
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3691 3691
 
3692 3692
 					$size_w = $width;
3693 3693
 					$size_h = $height;
@@ -3737,8 +3737,8 @@  discard block
 block discarded – undo
3737 3737
 		$result = false;
3738 3738
 
3739 3739
 		/* Coordinates for image over square aligning */
3740
-		$y = ceil(abs($height - $s[1]) / 2); 
3741
-		$x = ceil(abs($width - $s[0]) / 2);
3740
+		$y = ceil(abs($height - $s[1])/2); 
3741
+		$x = ceil(abs($width - $s[0])/2);
3742 3742
 
3743 3743
 		switch ($this->imgLib) {
3744 3744
 			case 'imagick':
@@ -3758,7 +3758,7 @@  discard block
 block discarded – undo
3758 3758
 						$gif->newImage($width, $height, new ImagickPixel($bgcolor));
3759 3759
 						$gif->setImageColorspace($img->getImageColorspace());
3760 3760
 						$gif->setImageFormat('gif');
3761
-						$gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3761
+						$gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3762 3762
 						$gif->setImageDelay($img->getImageDelay());
3763 3763
 						$gif->setImageIterations($img->getImageIterations());
3764 3764
 						$img1->addImage($gif);
@@ -3774,7 +3774,7 @@  discard block
 block discarded – undo
3774 3774
 					$img1->newImage($width, $height, new ImagickPixel($bgcolor));
3775 3775
 					$img1->setImageColorspace($img->getImageColorspace());
3776 3776
 					$img1->setImageFormat($destformat != null ? $destformat : $img->getFormat());
3777
-					$img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3777
+					$img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3778 3778
 					$result = $img1->writeImage($path);
3779 3779
 				}
3780 3780
 				
@@ -3785,11 +3785,11 @@  discard block
 block discarded – undo
3785 3785
 				break;
3786 3786
 
3787 3787
 			case 'gd':
3788
-				$img = self::gdImageCreate($path,$s['mime']);
3788
+				$img = self::gdImageCreate($path, $s['mime']);
3789 3789
 
3790
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3790
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3791 3791
 
3792
-					self::gdImageBackground($tmp,$bgcolor);
3792
+					self::gdImageBackground($tmp, $bgcolor);
3793 3793
 
3794 3794
 					if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) {
3795 3795
 						return false;
@@ -3820,15 +3820,15 @@  discard block
 block discarded – undo
3820 3820
 	 * @author Troex Nevelin
3821 3821
 	 **/
3822 3822
 	protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null) {
3823
-		if (($s = @getimagesize($path)) == false || $degree % 360 === 0) {
3823
+		if (($s = @getimagesize($path)) == false || $degree%360 === 0) {
3824 3824
 			return false;
3825 3825
 		}
3826 3826
 
3827 3827
 		$result = false;
3828 3828
 
3829 3829
 		// try lossless rotate
3830
-		if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3831
-			$count = ($degree / 90) % 4;
3830
+		if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3831
+			$count = ($degree/90)%4;
3832 3832
 			$exiftran = array(
3833 3833
 				1 => '-9',
3834 3834
 				2 => '-1',
@@ -3844,7 +3844,7 @@  discard block
 block discarded – undo
3844 3844
 				'exiftran -i '.$exiftran[$count].' '.$path,
3845 3845
 				'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath
3846 3846
 			);
3847
-			foreach($cmds as $cmd) {
3847
+			foreach ($cmds as $cmd) {
3848 3848
 				if ($this->procExec($cmd) === 0) {
3849 3849
 					$result = true;
3850 3850
 					break;
@@ -3880,12 +3880,12 @@  discard block
 block discarded – undo
3880 3880
 				break;
3881 3881
 
3882 3882
 			case 'gd':
3883
-				$img = self::gdImageCreate($path,$s['mime']);
3883
+				$img = self::gdImageCreate($path, $s['mime']);
3884 3884
 
3885 3885
 				$degree = 360 - $degree;
3886 3886
 				list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
3887 3887
 				$bgcolor = imagecolorallocate($img, $r, $g, $b);
3888
-				$tmp = imageRotate($img, $degree, (int)$bgcolor);
3888
+				$tmp = imageRotate($img, $degree, (int) $bgcolor);
3889 3889
 
3890 3890
 				$result = self::gdImage($tmp, $path, $destformat, $s['mime']);
3891 3891
 
@@ -3910,11 +3910,11 @@  discard block
 block discarded – undo
3910 3910
 	 * @return int     exit code
3911 3911
 	 * @author Alexey Sukhotin
3912 3912
 	 **/
3913
-	protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) {
3913
+	protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) {
3914 3914
 
3915 3915
 		$descriptorspec = array(
3916
-			0 => array("pipe", "r"),  // stdin
3917
-			1 => array("pipe", "w"),  // stdout
3916
+			0 => array("pipe", "r"), // stdin
3917
+			1 => array("pipe", "w"), // stdout
3918 3918
 			2 => array("pipe", "w")   // stderr
3919 3919
 		);
3920 3920
 
@@ -3971,8 +3971,8 @@  discard block
 block discarded – undo
3971 3971
 	 * @param string $mime
3972 3972
 	 * @return gd image resource identifier
3973 3973
 	 */
3974
-	protected function gdImageCreate($path,$mime){
3975
-		switch($mime){
3974
+	protected function gdImageCreate($path, $mime) {
3975
+		switch ($mime) {
3976 3976
 			case 'image/jpeg':
3977 3977
 			return imagecreatefromjpeg($path);
3978 3978
 
@@ -3996,7 +3996,7 @@  discard block
 block discarded – undo
3996 3996
 	 * @param string $destformat The Image type to use for $filename
3997 3997
 	 * @param string $mime The original image mime type
3998 3998
 	 */
3999
-	protected function gdImage($image, $filename, $destformat, $mime ){
3999
+	protected function gdImage($image, $filename, $destformat, $mime) {
4000 4000
 
4001 4001
 		if ($destformat == 'jpg' || ($destformat == null && $mime == 'image/jpeg')) {
4002 4002
 			return imagejpeg($image, $filename, 100);
@@ -4015,13 +4015,13 @@  discard block
 block discarded – undo
4015 4015
 	 * @param resource $image gd image resource
4016 4016
 	 * @param string $bgcolor background color in #rrggbb format
4017 4017
 	 */
4018
-	protected function gdImageBackground($image, $bgcolor){
4018
+	protected function gdImageBackground($image, $bgcolor) {
4019 4019
 
4020
-		if( $bgcolor == 'transparent' ){
4021
-			imagesavealpha($image,true);
4020
+		if ($bgcolor == 'transparent') {
4021
+			imagesavealpha($image, true);
4022 4022
 			$bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127);
4023 4023
 
4024
-		}else{
4024
+		} else {
4025 4025
 			list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4026 4026
 			$bgcolor1 = imagecolorallocate($image, $r, $g, $b);
4027 4027
 		}
@@ -4059,13 +4059,13 @@  discard block
 block discarded – undo
4059 4059
 	* @return int|bool
4060 4060
 	* @author Alexey Sukhotin
4061 4061
 	**/
4062
-	protected function stripos($haystack , $needle , $offset = 0) {
4062
+	protected function stripos($haystack, $needle, $offset = 0) {
4063 4063
 		if (function_exists('mb_stripos')) {
4064
-			return mb_stripos($haystack , $needle , $offset);
4064
+			return mb_stripos($haystack, $needle, $offset);
4065 4065
 		} else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) {
4066 4066
 			return mb_strpos(mb_strtolower($haystack), mb_strtolower($needle), $offset);
4067 4067
 		} 
4068
-		return stripos($haystack , $needle , $offset);
4068
+		return stripos($haystack, $needle, $offset);
4069 4069
 	}
4070 4070
 
4071 4071
 	/**
@@ -4115,22 +4115,22 @@  discard block
 block discarded – undo
4115 4115
 			unset($o);
4116 4116
 			$this->procExec('zip -v', $o, $c);
4117 4117
 			if ($c == 0) {
4118
-				$arcs['create']['application/zip']  = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4118
+				$arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4119 4119
 			}
4120 4120
 			unset($o);
4121 4121
 			$this->procExec('unzip --help', $o, $c);
4122 4122
 			if ($c == 0) {
4123
-				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '',  'ext' => 'zip');
4123
+				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip');
4124 4124
 			}
4125 4125
 			unset($o);
4126 4126
 			$this->procExec('rar --version', $o, $c);
4127 4127
 			if ($c == 0 || $c == 7) {
4128 4128
 				$arcs['create']['application/x-rar']  = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar');
4129
-				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y',    'ext' => 'rar');
4129
+				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar');
4130 4130
 			} else {
4131 4131
 				unset($o);
4132 4132
 				$test = $this->procExec('unrar', $o, $c);
4133
-				if ($c==0 || $c == 7) {
4133
+				if ($c == 0 || $c == 7) {
4134 4134
 					$arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar');
4135 4135
 				}
4136 4136
 			}
@@ -4152,7 +4152,7 @@  discard block
 block discarded – undo
4152 4152
 				if (empty($arcs['extract']['application/x-tar'])) {
4153 4153
 					$arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar');
4154 4154
 				}
4155
-			} else if (substr(PHP_OS,0,3) === 'WIN') {
4155
+			} else if (substr(PHP_OS, 0, 3) === 'WIN') {
4156 4156
 				// check `7z` for Windows server.
4157 4157
 				unset($o);
4158 4158
 				$this->procExec('7z', $o, $c);
@@ -4206,22 +4206,22 @@  discard block
 block discarded – undo
4206 4206
 
4207 4207
 		// normalize `/../`
4208 4208
 		$normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#';
4209
-		while(preg_match($normreg, $path)) {
4209
+		while (preg_match($normreg, $path)) {
4210 4210
 			$path = preg_replace($normreg, '$1', $path);
4211 4211
 		}
4212 4212
 		
4213 4213
 		// 'Here'
4214
-		if ($path === '' || $path === '.' . $separator) return $base;
4214
+		if ($path === '' || $path === '.'.$separator) return $base;
4215 4215
 		
4216 4216
 		// Absolute path
4217 4217
 		if ($path[0] === $separator || strpos($path, $systemroot) === 0) {
4218 4218
 			return $path;
4219 4219
 		}
4220 4220
 		
4221
-		$preg_separator = '#' . $sepquoted . '#';
4221
+		$preg_separator = '#'.$sepquoted.'#';
4222 4222
 		
4223 4223
 		// Relative path from 'Here'
4224
-		if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) {
4224
+		if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) {
4225 4225
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4226 4226
 			if ($arrn[0] !== '.') {
4227 4227
 				array_unshift($arrn, '.');
@@ -4235,12 +4235,11 @@  discard block
 block discarded – undo
4235 4235
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4236 4236
 			$arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY);
4237 4237
 		
4238
-			while (! empty($arrn) && $arrn[0] === '..') {
4238
+			while (!empty($arrn) && $arrn[0] === '..') {
4239 4239
 				array_shift($arrn);
4240 4240
 				array_pop($arrp);
4241 4241
 			}
4242
-			$path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) :
4243
-				(! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot);
4242
+			$path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot);
4244 4243
 		}
4245 4244
 		
4246 4245
 		return $path;
@@ -4258,7 +4257,7 @@  discard block
 block discarded – undo
4258 4257
 			@chmod($dir, 0777);
4259 4258
 			foreach (array_diff(scandir($dir), array('.', '..')) as $file) {
4260 4259
 				@set_time_limit(30);
4261
-				$path = $dir . DIRECTORY_SEPARATOR . $file;
4260
+				$path = $dir.DIRECTORY_SEPARATOR.$file;
4262 4261
 				if (!is_link($dir) && is_dir($path)) {
4263 4262
 					$this->rmdirRecursive($path);
4264 4263
 				} else {
@@ -4345,22 +4344,22 @@  discard block
 block discarded – undo
4345 4344
 		try {
4346 4345
 			if ($start = is_string($zipPath)) {
4347 4346
 				$zip = new ZipArchive();
4348
-				if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) {
4347
+				if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) {
4349 4348
 					$zip = false;
4350 4349
 				}
4351 4350
 			} else {
4352 4351
 				$zip = $zipPath;
4353 4352
 			}
4354 4353
 			if ($zip) {
4355
-				foreach($files as $file) {
4356
-					$path = $dir . DIRECTORY_SEPARATOR . $file;
4354
+				foreach ($files as $file) {
4355
+					$path = $dir.DIRECTORY_SEPARATOR.$file;
4357 4356
 					if (is_dir($path)) {
4358 4357
 						$zip->addEmptyDir($file);
4359 4358
 						$_files = array();
4360 4359
 						if ($handle = opendir($path)) {
4361 4360
 							while (false !== ($entry = readdir($handle))) {
4362 4361
 								if ($entry !== "." && $entry !== "..") {
4363
-									$_files[] = $file . DIRECTORY_SEPARATOR . $entry;
4362
+									$_files[] = $file.DIRECTORY_SEPARATOR.$entry;
4364 4363
 								}
4365 4364
 							}
4366 4365
 							closedir($handle);
@@ -4545,7 +4544,7 @@  discard block
 block discarded – undo
4545 4544
 	 * @return resource|false
4546 4545
 	 * @author Dmitry (dio) Levashov
4547 4546
 	 **/
4548
-	abstract protected function _fopen($path, $mode="rb");
4547
+	abstract protected function _fopen($path, $mode = "rb");
4549 4548
 	
4550 4549
 	/**
4551 4550
 	 * Close opened file
@@ -4555,7 +4554,7 @@  discard block
 block discarded – undo
4555 4554
 	 * @return bool
4556 4555
 	 * @author Dmitry (dio) Levashov
4557 4556
 	 **/
4558
-	abstract protected function _fclose($fp, $path='');
4557
+	abstract protected function _fclose($fp, $path = '');
4559 4558
 	
4560 4559
 	/********************  file/dir manipulations *************************/
4561 4560
 	
Please login to merge, or discard this patch.
php/elFinderVolumeDropbox.class.php 4 patches
Doc Comments   +5 added lines, -12 removed lines patch added patch discarded remove patch
@@ -234,7 +234,6 @@  discard block
 block discarded – undo
234 234
 	 * process of on netunmount
235 235
 	 * Drop table `dropbox` & rm thumbs
236 236
 	 * 
237
-	 * @param array $options
238 237
 	 * @return boolean
239 238
 	 */
240 239
 	public function netunmount($netVolumes, $key) {
@@ -431,7 +430,7 @@  discard block
 block discarded – undo
431 430
 	/**
432 431
 	 * Check DB for delta cache
433 432
 	 * 
434
-	 * @return void
433
+	 * @return boolean
435 434
 	 */
436 435
 	private function checkDB() {
437 436
 		$res = $this->query('SELECT * FROM sqlite_master WHERE type=\'table\' AND name=\''.$this->DB_TableName.'\'');
@@ -685,7 +684,7 @@  discard block
 block discarded – undo
685 684
 	* @param  string  $src   source path
686 685
 	* @param  string  $dst   destination dir path
687 686
 	* @param  string  $name  new file name (optionaly)
688
-	* @return string|false
687
+	* @return string|boolean
689 688
 	* @author Dmitry (dio) Levashov
690 689
 	* @author Naoki Sawada
691 690
 	**/
@@ -739,10 +738,6 @@  discard block
 block discarded – undo
739 738
 	* Create thumnbnail and return it's URL on success
740 739
 	*
741 740
 	* @param  string  $path  file path
742
-	* @param  string  $mime  file mime type
743
-	* @return string|false
744
-	* @author Dmitry (dio) Levashov
745
-	* @author Naoki Sawada
746 741
 	**/
747 742
 	protected function createTmb($path, $stat) {
748 743
 		if (!$stat || !$this->canCreateTmb($path, $stat)) {
@@ -1099,7 +1094,6 @@  discard block
 block discarded – undo
1099 1094
 	 * Open file and return file pointer
1100 1095
 	 *
1101 1096
 	 * @param  string  $path  file path
1102
-	 * @param  bool    $write open file for writing
1103 1097
 	 * @return resource|false
1104 1098
 	 * @author Dmitry (dio) Levashov
1105 1099
 	 **/
@@ -1141,7 +1135,7 @@  discard block
 block discarded – undo
1141 1135
 	 * Close opened file
1142 1136
 	 *
1143 1137
 	 * @param  resource  $fp  file pointer
1144
-	 * @return bool
1138
+	 * @return boolean|null
1145 1139
 	 * @author Dmitry (dio) Levashov
1146 1140
 	 **/
1147 1141
 	protected function _fclose($fp, $path='') {
@@ -1225,7 +1219,7 @@  discard block
 block discarded – undo
1225 1219
 	 * Return new file path or false.
1226 1220
 	 *
1227 1221
 	 * @param  string  $source  source file path
1228
-	 * @param  string  $target  target dir path
1222
+	 * @param  string  $targetDir  target dir path
1229 1223
 	 * @param  string  $name    file name
1230 1224
 	 * @return string|bool
1231 1225
 	 * @author Dmitry (dio) Levashov
@@ -1274,7 +1268,6 @@  discard block
 block discarded – undo
1274 1268
 	 * Return new file path or false on error.
1275 1269
 	 *
1276 1270
 	 * @param  resource  $fp   file pointer
1277
-	 * @param  string    $dir  target dir path
1278 1271
 	 * @param  string    $name file name
1279 1272
 	 * @param  array     $stat file stat (required by some virtual fs)
1280 1273
 	 * @return bool|string
@@ -1320,7 +1313,7 @@  discard block
 block discarded – undo
1320 1313
 	 *
1321 1314
 	 * @param  string  $path     file path
1322 1315
 	 * @param  string  $content  new file content
1323
-	 * @return bool
1316
+	 * @return boolean|string
1324 1317
 	 * @author Dmitry (dio) Levashov
1325 1318
 	 **/
1326 1319
 	protected function _filePutContents($path, $content) {
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 						$options['url'] = $this->getConnectorUrl();
193 193
 					}
194 194
 					$callback  = $options['url']
195
-					           . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata;
195
+							   . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata;
196 196
 					
197 197
 					try {
198 198
 						$tokens = $this->oauth->getRequestToken();
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
 	 */
266 266
 	private function getConnectorUrl() {
267 267
 		$url  = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://')
268
-		       . $_SERVER['SERVER_NAME']                                              // host
269
-		      . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT'])  // port
270
-		       . $_SERVER['REQUEST_URI'];                                             // path & query
268
+			   . $_SERVER['SERVER_NAME']                                              // host
269
+			  . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT'])  // port
270
+			   . $_SERVER['REQUEST_URI'];                                             // path & query
271 271
 		list($url) = explode('?', $url);
272 272
 		return $url;
273 273
 	}
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 		$stat['mime']  = $raw['is_dir']? 'directory' : $raw['mime_type'];
606 606
 		$stat['size']  = $stat['mime'] == 'directory' ? 0 : $raw['bytes'];
607 607
 		$stat['ts']    = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) :
608
-		                (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']);
608
+						(isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']);
609 609
 		$stat['dirs'] = 0;
610 610
 		if ($raw['is_dir']) {
611 611
 			$stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path'])));
@@ -648,14 +648,14 @@  discard block
 block discarded – undo
648 648
 	}
649 649
 
650 650
 	/**
651
-	* Recursive files search
652
-	*
653
-	* @param  string  $path   dir path
654
-	* @param  string  $q      search string
655
-	* @param  array   $mimes
656
-	* @return array
657
-	* @author Naoki Sawada
658
-	**/
651
+	 * Recursive files search
652
+	 *
653
+	 * @param  string  $path   dir path
654
+	 * @param  string  $q      search string
655
+	 * @param  array   $mimes
656
+	 * @return array
657
+	 * @author Naoki Sawada
658
+	 **/
659 659
 	protected function doSearch($path, $q, $mimes) {
660 660
 		$result = array();
661 661
 		$sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?');
@@ -679,16 +679,16 @@  discard block
 block discarded – undo
679 679
 	}
680 680
 	
681 681
 	/**
682
-	* Copy file/recursive copy dir only in current volume.
683
-	* Return new file path or false.
684
-	*
685
-	* @param  string  $src   source path
686
-	* @param  string  $dst   destination dir path
687
-	* @param  string  $name  new file name (optionaly)
688
-	* @return string|false
689
-	* @author Dmitry (dio) Levashov
690
-	* @author Naoki Sawada
691
-	**/
682
+	 * Copy file/recursive copy dir only in current volume.
683
+	 * Return new file path or false.
684
+	 *
685
+	 * @param  string  $src   source path
686
+	 * @param  string  $dst   destination dir path
687
+	 * @param  string  $name  new file name (optionaly)
688
+	 * @return string|false
689
+	 * @author Dmitry (dio) Levashov
690
+	 * @author Naoki Sawada
691
+	 **/
692 692
 	protected function copy($src, $dst, $name) {
693 693
 
694 694
 		$this->clearcache();
@@ -699,14 +699,14 @@  discard block
 block discarded – undo
699 699
 	}
700 700
 	
701 701
 	/**
702
-	* Remove file/ recursive remove dir
703
-	*
704
-	* @param  string  $path   file path
705
-	* @param  bool    $force  try to remove even if file locked
706
-	* @return bool
707
-	* @author Dmitry (dio) Levashov
708
-	* @author Naoki Sawada
709
-	**/
702
+	 * Remove file/ recursive remove dir
703
+	 *
704
+	 * @param  string  $path   file path
705
+	 * @param  bool    $force  try to remove even if file locked
706
+	 * @return bool
707
+	 * @author Dmitry (dio) Levashov
708
+	 * @author Naoki Sawada
709
+	 **/
710 710
 	protected function remove($path, $force = false, $recursive = false) {
711 711
 		$stat = $this->stat($path);
712 712
 		$stat['realpath'] = $path;
@@ -736,14 +736,14 @@  discard block
 block discarded – undo
736 736
 	}
737 737
 	
738 738
 	/**
739
-	* Create thumnbnail and return it's URL on success
740
-	*
741
-	* @param  string  $path  file path
742
-	* @param  string  $mime  file mime type
743
-	* @return string|false
744
-	* @author Dmitry (dio) Levashov
745
-	* @author Naoki Sawada
746
-	**/
739
+	 * Create thumnbnail and return it's URL on success
740
+	 *
741
+	 * @param  string  $path  file path
742
+	 * @param  string  $mime  file mime type
743
+	 * @return string|false
744
+	 * @author Dmitry (dio) Levashov
745
+	 * @author Naoki Sawada
746
+	 **/
747 747
 	protected function createTmb($path, $stat) {
748 748
 		if (!$stat || !$this->canCreateTmb($path, $stat)) {
749 749
 			return false;
@@ -828,13 +828,13 @@  discard block
 block discarded – undo
828 828
 	}
829 829
 	
830 830
 	/**
831
-	* Return content URL
832
-	*
833
-	* @param string  $hash  file hash
834
-	* @param array $options options
835
-	* @return array
836
-	* @author Naoki Sawada
837
-	**/
831
+	 * Return content URL
832
+	 *
833
+	 * @param string  $hash  file hash
834
+	 * @param array $options options
835
+	 * @return array
836
+	 * @author Naoki Sawada
837
+	 **/
838 838
 	public function getContentUrl($hash, $options = array()) {
839 839
 		if (($file = $this->file($hash)) == false || !$file['url'] || $file['url'] == 1) {
840 840
 			$path = $this->decode($hash);
@@ -897,9 +897,9 @@  discard block
 block discarded – undo
897 897
 			try {
898 898
 				$request2 = new HTTP_Request2();
899 899
 				$request2->setConfig(array(
900
-                    'ssl_verify_peer' => false,
901
-                    'ssl_verify_host' => false
902
-                ));
900
+					'ssl_verify_peer' => false,
901
+					'ssl_verify_host' => false
902
+				));
903 903
 				$request2->setUrl($url);
904 904
 				$request2->setMethod(HTTP_Request2::METHOD_HEAD);
905 905
 				$result = $request2->send();
Please login to merge, or discard this patch.
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -132,8 +132,12 @@  discard block
 block discarded – undo
132 132
 	 * @author Naoki Sawada
133 133
 	 **/
134 134
 	public function netmountPrepare($options) {
135
-		if (empty($options['consumerKey']) && defined('ELFINDER_DROPBOX_CONSUMERKEY')) $options['consumerKey'] = ELFINDER_DROPBOX_CONSUMERKEY;
136
-		if (empty($options['consumerSecret']) && defined('ELFINDER_DROPBOX_CONSUMERSECRET')) $options['consumerSecret'] = ELFINDER_DROPBOX_CONSUMERSECRET;
135
+		if (empty($options['consumerKey']) && defined('ELFINDER_DROPBOX_CONSUMERKEY')) {
136
+			$options['consumerKey'] = ELFINDER_DROPBOX_CONSUMERKEY;
137
+		}
138
+		if (empty($options['consumerSecret']) && defined('ELFINDER_DROPBOX_CONSUMERSECRET')) {
139
+			$options['consumerSecret'] = ELFINDER_DROPBOX_CONSUMERSECRET;
140
+		}
137 141
 		
138 142
 		if ($options['user'] === 'init') {
139 143
 
@@ -616,8 +620,12 @@  discard block
 block discarded – undo
616 620
 		} else {
617 621
 			$stat['url'] = '1';
618 622
 		}
619
-		if (isset($raw['width'])) $stat['width'] = $raw['width'];
620
-		if (isset($raw['height'])) $stat['height'] = $raw['height'];
623
+		if (isset($raw['width'])) {
624
+			$stat['width'] = $raw['width'];
625
+		}
626
+		if (isset($raw['height'])) {
627
+			$stat['height'] = $raw['height'];
628
+		}
621 629
 		
622 630
 		return $stat;
623 631
 	}
@@ -1061,7 +1069,9 @@  discard block
 block discarded – undo
1061 1069
 	 * @author Dmitry (dio) Levashov
1062 1070
 	 **/
1063 1071
 	protected function _dimensions($path, $mime) {
1064
-		if (strpos($mime, 'image') !== 0) return '';
1072
+		if (strpos($mime, 'image') !== 0) {
1073
+			return '';
1074
+		}
1065 1075
 		$cache = $this->getDBdat($path);
1066 1076
 		if (isset($cache['width']) && isset($cache['height'])) {
1067 1077
 			return $cache['width'].'x'.$cache['height'];
@@ -1281,7 +1291,9 @@  discard block
 block discarded – undo
1281 1291
 	 * @author Dmitry (dio) Levashov
1282 1292
 	 **/
1283 1293
 	protected function _save($fp, $path, $name, $stat) {
1284
-		if ($name) $path .= '/'.$name;
1294
+		if ($name) {
1295
+			$path .= '/'.$name;
1296
+		}
1285 1297
 		$path = $this->_normpath($path);
1286 1298
 		try {
1287 1299
 			$this->dropbox->putFile($path, $fp);
@@ -1291,8 +1303,12 @@  discard block
 block discarded – undo
1291 1303
 		$this->deltaCheck();
1292 1304
 		if (is_array($stat)) {
1293 1305
 			$raw = $this->getDBdat($path);
1294
-			if (isset($stat['width'])) $raw['width'] = $stat['width'];
1295
-			if (isset($stat['height'])) $raw['height'] = $stat['height'];
1306
+			if (isset($stat['width'])) {
1307
+				$raw['width'] = $stat['width'];
1308
+			}
1309
+			if (isset($stat['height'])) {
1310
+				$raw['height'] = $stat['height'];
1311
+			}
1296 1312
 			$this->updateDBdat($path, $raw);
1297 1313
 		}
1298 1314
 		return $path;
Please login to merge, or discard this patch.
Spacing   +62 added lines, -63 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		
138 138
 		if ($options['user'] === 'init') {
139 139
 
140
-			if (! $this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO')) {
140
+			if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO')) {
141 141
 				return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}');
142 142
 			}
143 143
 			
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 				if (class_exists('OAuth')) {
148 148
 					$this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']);
149 149
 				} else {
150
-					if (! class_exists('HTTP_OAuth_Consumer')) {
150
+					if (!class_exists('HTTP_OAuth_Consumer')) {
151 151
 						// We're going to try to load in manually
152 152
 						include 'HTTP/OAuth/Consumer.php';
153 153
 					}
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 				}
158 158
 			}
159 159
 			
160
-			if (! $this->oauth) {
160
+			if (!$this->oauth) {
161 161
 				return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}');
162 162
 			}
163 163
 
@@ -178,24 +178,24 @@  discard block
 block discarded – undo
178 178
 						unset($_SESSION['elFinderDropboxTokens']);
179 179
 					}
180 180
 				}
181
-				if (! $html) {
181
+				if (!$html) {
182 182
 					// get customdata
183 183
 					$cdata = '';
184 184
 					$innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user');
185
-					foreach($this->ARGS as $k => $v) {
186
-						if (! in_array($k, $innerKeys)) {
187
-							$cdata .= '&' . $k . '=' . rawurlencode($v);
185
+					foreach ($this->ARGS as $k => $v) {
186
+						if (!in_array($k, $innerKeys)) {
187
+							$cdata .= '&'.$k.'='.rawurlencode($v);
188 188
 						}
189 189
 					}
190
-					if (strpos($options['url'], 'http') !== 0 ) {
190
+					if (strpos($options['url'], 'http') !== 0) {
191 191
 						$options['url'] = $this->getConnectorUrl();
192 192
 					}
193
-					$callback  = $options['url']
193
+					$callback = $options['url']
194 194
 					           . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata;
195 195
 					
196 196
 					try {
197 197
 						$tokens = $this->oauth->getRequestToken();
198
-						$url= $this->oauth->getAuthorizeUrl(rawurlencode($callback));
198
+						$url = $this->oauth->getAuthorizeUrl(rawurlencode($callback));
199 199
 					} catch (Dropbox_Exception $e) {
200 200
 						return array('exit' => true, 'body' => '{msg:errAccess}');
201 201
 					}
@@ -242,14 +242,14 @@  discard block
 block discarded – undo
242 242
 		if (isset($netVolumes[$key])) {
243 243
 			$dropboxUid = $netVolumes[$key]['dropboxUid'];
244 244
 		}
245
-		foreach($netVolumes as $volume) {
245
+		foreach ($netVolumes as $volume) {
246 246
 			if (@$volume['host'] === 'dropbox' && @$volume['dropboxUid'] === $dropboxUid) {
247 247
 				$count++;
248 248
 			}
249 249
 		}
250 250
 		if ($count === 1) {
251 251
 			$this->DB->exec('drop table '.$this->DB_TableName);
252
-			foreach(glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) {
252
+			foreach (glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) {
253 253
 				unlink($tmb);
254 254
 			}
255 255
 		}
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 	 * @author Naoki Sawada
264 264
 	 */
265 265
 	private function getConnectorUrl() {
266
-		$url  = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://')
266
+		$url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://')
267 267
 		       . $_SERVER['SERVER_NAME']                                              // host
268
-		      . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT'])  // port
269
-		       . $_SERVER['REQUEST_URI'];                                             // path & query
268
+		      . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT'])  // port
269
+		       . $_SERVER['REQUEST_URI']; // path & query
270 270
 		list($url) = explode('?', $url);
271 271
 		return $url;
272 272
 	}
@@ -302,14 +302,14 @@  discard block
 block discarded – undo
302 302
 		// make net mount key
303 303
 		$this->netMountKey = md5(join('-', array('dropbox', $this->options['path'])));
304 304
 
305
-		if (! $this->oauth) {
305
+		if (!$this->oauth) {
306 306
 			if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) {
307 307
 				$this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']);
308 308
 			} else {
309 309
 				if (class_exists('OAuth')) {
310 310
 					$this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']);
311 311
 				} else {
312
-					if (! class_exists('HTTP_OAuth_Consumer')) {
312
+					if (!class_exists('HTTP_OAuth_Consumer')) {
313 313
 						// We're going to try to load in manually
314 314
 						include 'HTTP/OAuth/Consumer.php';
315 315
 					}
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 			}
321 321
 		}
322 322
 		
323
-		if (! $this->oauth) {
323
+		if (!$this->oauth) {
324 324
 			return $this->setError('OAuth extension not loaded.');
325 325
 		}
326 326
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		$this->root = $this->options['path'] = $this->_normpath($this->options['path']);
329 329
 
330 330
 		if (empty($this->options['alias'])) {
331
-			$this->options['alias'] = ($this->options['path'] === '/')? 'Dropbox.com'  : 'Dropbox'.$this->options['path'];
331
+			$this->options['alias'] = ($this->options['path'] === '/') ? 'Dropbox.com' : 'Dropbox'.$this->options['path'];
332 332
 		}
333 333
 
334 334
 		$this->rootName = $this->options['alias'];
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		}
385 385
 		
386 386
 		// setup PDO
387
-		if (! $this->options['PDO_DSN']) {
387
+		if (!$this->options['PDO_DSN']) {
388 388
 			$this->options['PDO_DSN'] = 'sqlite:'.$this->metaCache.DIRECTORY_SEPARATOR.'.elFinder_dropbox_db_'.md5($this->dropboxUid.$this->options['consumerSecret']);
389 389
 		}
390 390
 		// DataBase table name
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 		// DataBase check or make table
393 393
 		try {
394 394
 			$this->DB = new PDO($this->options['PDO_DSN'], $this->options['PDO_User'], $this->options['PDO_Pass'], $this->options['PDO_Options']);
395
-			if (! $this->checkDB()) {
395
+			if (!$this->checkDB()) {
396 396
 				return $this->setError('Can not make DB table');
397 397
 			}
398 398
 		} catch (PDOException $e) {
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 				$res = false;
444 444
 			}
445 445
 		}
446
-		if (! $res) {
446
+		if (!$res) {
447 447
 			try {
448 448
 				$this->DB->exec('CREATE TABLE '.$this->DB_TableName.'(path text, fname text, dat blob, isdir integer);');
449 449
 				$this->DB->exec('CREATE UNIQUE INDEX nameidx ON '.$this->DB_TableName.'(path, fname)');
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 	 */
494 494
 	private function updateDBdat($path, $dat) {
495 495
 		return $this->query('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($dat))
496
-				. ', isdir=' . ($dat['is_dir']? 1 : 0)
496
+				. ', isdir='.($dat['is_dir'] ? 1 : 0)
497 497
 				. ' where path='.$this->DB->quote(strtolower(dirname($path))).' and fname='.$this->DB->quote(strtolower(basename($path))));
498 498
 	}
499 499
 	/*********************************************************************/
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 	 */
519 519
 	protected function deltaCheck($refresh = true) {
520 520
 		$chk = false;
521
-		if (! $refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) {
521
+		if (!$refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) {
522 522
 			$chk = unserialize($chk[0]);
523 523
 		}
524 524
 		if ($chk && ($chk['mtime'] + $this->options['metaCacheTime']) > $_SERVER['REQUEST_TIME']) {
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 			do {
541 541
 				@ ini_set('max_execution_time', 120);
542 542
 				$_info = $this->dropbox->delta($cursor);
543
-				if (! empty($_info['reset'])) {
543
+				if (!empty($_info['reset'])) {
544 544
 					$this->DB->exec('TRUNCATE table '.$this->DB_TableName);
545 545
 					$this->DB->exec('insert into '.$this->DB_TableName.' values(\'\', \'\', \''.serialize(array('cursor' => '', 'mtime' => 0)).'\', 0);');
546 546
 					$this->DB->exec('insert into '.$this->DB_TableName.' values(\'/\', \'\', \''.serialize(array(
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 				}
554 554
 				$cursor = $_info['cursor'];
555 555
 				
556
-				foreach($_info['entries'] as $entry) {
556
+				foreach ($_info['entries'] as $entry) {
557 557
 					$key = strtolower($entry[0]);
558 558
 					$pkey = strtolower(dirname($key));
559 559
 					
@@ -563,27 +563,27 @@  discard block
 block discarded – undo
563 563
 					
564 564
 					if (empty($entry[1])) {
565 565
 						$this->DB->exec('delete from '.$this->DB_TableName.' '.$where);
566
-						! $delete && $delete = true;
566
+						!$delete && $delete = true;
567 567
 						continue;
568 568
 					}
569 569
 
570 570
 					$sql = 'select path from '.$this->DB_TableName.' '.$where.' limit 1';
571
-					if (! $reset && $this->query($sql)) {
572
-						$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir']? 1 : 0).' ' .$where);
571
+					if (!$reset && $this->query($sql)) {
572
+						$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir'] ? 1 : 0).' '.$where);
573 573
 					} else {
574
-						$this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int)$entry[1]['is_dir'].')');
574
+						$this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int) $entry[1]['is_dir'].')');
575 575
 					}
576 576
 				}
577
-			} while (! empty($_info['has_more']));
577
+			} while (!empty($_info['has_more']));
578 578
 			$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize(array('cursor'=>$cursor, 'mtime'=>$_SERVER['REQUEST_TIME']))).' where path=\'\' and fname=\'\'');
579
-			if (! $this->DB->commit()) {
579
+			if (!$this->DB->commit()) {
580 580
 				$e = $this->DB->errorInfo();
581 581
 				return $e[2];
582 582
 			}
583 583
 			if ($delete) {
584 584
 				$this->DB->exec('vacuum');
585 585
 			}
586
-		} catch(Dropbox_Exception $e) {
586
+		} catch (Dropbox_Exception $e) {
587 587
 			return $e->getMessage();
588 588
 		}
589 589
 		return true;
@@ -599,15 +599,14 @@  discard block
 block discarded – undo
599 599
 	protected function parseRaw($raw) {
600 600
 		$stat = array();
601 601
 
602
-		$stat['rev']   = isset($raw['rev'])? $raw['rev'] : 'root';
602
+		$stat['rev']   = isset($raw['rev']) ? $raw['rev'] : 'root';
603 603
 		$stat['name']  = basename($raw['path']);
604
-		$stat['mime']  = $raw['is_dir']? 'directory' : $raw['mime_type'];
604
+		$stat['mime']  = $raw['is_dir'] ? 'directory' : $raw['mime_type'];
605 605
 		$stat['size']  = $stat['mime'] == 'directory' ? 0 : $raw['bytes'];
606
-		$stat['ts']    = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) :
607
-		                (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']);
606
+		$stat['ts']    = isset($raw['client_mtime']) ? strtotime($raw['client_mtime']) : (isset($raw['modified']) ? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']);
608 607
 		$stat['dirs'] = 0;
609 608
 		if ($raw['is_dir']) {
610
-			$stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path'])));
609
+			$stat['dirs'] = (int) (bool) $this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path'])));
611 610
 		}
612 611
 		
613 612
 		if (!empty($raw['url'])) {
@@ -633,7 +632,7 @@  discard block
 block discarded – undo
633 632
 		$res = $this->query('select dat from '.$this->DB_TableName.' where path='.$this->DB->quote(strtolower($path)));
634 633
 		
635 634
 		if ($res) {
636
-			foreach($res as $raw) {
635
+			foreach ($res as $raw) {
637 636
 				$raw = unserialize($raw);
638 637
 				if ($stat = $this->parseRaw($raw)) {
639 638
 					$stat = $this->updateCache($raw['path'], $stat);
@@ -658,10 +657,10 @@  discard block
 block discarded – undo
658 657
 	protected function doSearch($path, $q, $mimes) {
659 658
 		$result = array();
660 659
 		$sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?');
661
-		$sth->execute(array('%'.(($path === '/')? '' : strtolower($path)), '%'.strtolower($q).'%'));
660
+		$sth->execute(array('%'.(($path === '/') ? '' : strtolower($path)), '%'.strtolower($q).'%'));
662 661
 		$res = $sth->fetchAll(PDO::FETCH_COLUMN);
663 662
 		if ($res) {
664
-			foreach($res as $raw) {
663
+			foreach ($res as $raw) {
665 664
 				$raw = unserialize($raw);
666 665
 				if ($stat = $this->parseRaw($raw)) {
667 666
 					if (!isset($this->cache[$raw['path']])) {
@@ -752,10 +751,10 @@  discard block
 block discarded – undo
752 751
 		$tmb  = $this->tmbPath.DIRECTORY_SEPARATOR.$name;
753 752
 	
754 753
 		// copy image into tmbPath so some drivers does not store files on local fs
755
-		if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) {
754
+		if (!$data = $this->getThumbnail($path, $this->options['getTmbSize'])) {
756 755
 			return false;
757 756
 		}
758
-		if (! file_put_contents($tmb, $data)) {
757
+		if (!file_put_contents($tmb, $data)) {
759 758
 			return false;
760 759
 		}
761 760
 	
@@ -768,15 +767,15 @@  discard block
 block discarded – undo
768 767
 		}
769 768
 	
770 769
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
771
-		if ($s[0] <= $tmbSize && $s[1]  <= $tmbSize) {
772
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
770
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
771
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
773 772
 	
774 773
 		} else {
775 774
 	
776 775
 			if ($this->options['tmbCrop']) {
777 776
 	
778 777
 				/* Resize and crop if image bigger than thumbnail */
779
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
778
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
780 779
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
781 780
 				}
782 781
 	
@@ -790,7 +789,7 @@  discard block
 block discarded – undo
790 789
 				$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png');
791 790
 			}
792 791
 		
793
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
792
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
794 793
 		}
795 794
 		
796 795
 		if (!$result) {
@@ -847,7 +846,7 @@  discard block
 block discarded – undo
847 846
 					}
848 847
 				}
849 848
 			}
850
-			if (! $url) {
849
+			if (!$url) {
851 850
 				try {
852 851
 					$res = $this->dropbox->share($path, null, false);
853 852
 					$url = $res['url'];
@@ -859,7 +858,7 @@  discard block
 block discarded – undo
859 858
 					}
860 859
 					list($url) = explode('?', $url);
861 860
 					$url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url);
862
-					if (! isset($cache['share']) || $cache['share'] !== $url) {
861
+					if (!isset($cache['share']) || $cache['share'] !== $url) {
863 862
 						$cache['share'] = $url;
864 863
 						$this->updateDBdat($path, $cache);
865 864
 					}
@@ -883,12 +882,12 @@  discard block
 block discarded – undo
883 882
 		if (function_exists('curl_exec')) {
884 883
 
885 884
 			$c = curl_init();
886
-			curl_setopt( $c, CURLOPT_RETURNTRANSFER, true );
887
-			curl_setopt( $c, CURLOPT_CUSTOMREQUEST, 'HEAD' );
888
-			curl_setopt( $c, CURLOPT_HEADER, 1 );
889
-			curl_setopt( $c, CURLOPT_NOBODY, true );
890
-			curl_setopt( $c, CURLOPT_URL, $url );
891
-			$res = curl_exec( $c );
885
+			curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
886
+			curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD');
887
+			curl_setopt($c, CURLOPT_HEADER, 1);
888
+			curl_setopt($c, CURLOPT_NOBODY, true);
889
+			curl_setopt($c, CURLOPT_URL, $url);
890
+			$res = curl_exec($c);
892 891
 			
893 892
 		} else {
894 893
 			
@@ -904,13 +903,13 @@  discard block
 block discarded – undo
904 903
 				$result = $request2->send();
905 904
 				$res = array();
906 905
 				$res[] = 'HTTP/'.$result->getVersion().' '.$result->getStatus().' '.$result->getReasonPhrase();
907
-				foreach($result->getHeader() as $key => $val) {
908
-					$res[] = $key . ': ' . $val;
906
+				foreach ($result->getHeader() as $key => $val) {
907
+					$res[] = $key.': '.$val;
909 908
 				}
910 909
 				$res = join("\r\n", $res);
911
-			} catch( HTTP_Request2_Exception $e ){
910
+			} catch (HTTP_Request2_Exception $e) {
912 911
 				$res = '';
913
-			} catch (Exception $e){
912
+			} catch (Exception $e) {
914 913
 				$res = '';
915 914
 			}
916 915
 		
@@ -963,7 +962,7 @@  discard block
 block discarded – undo
963 962
 	 **/
964 963
 	protected function _normpath($path) {
965 964
 		$path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
966
-		$path = '/' . ltrim($path, '/');
965
+		$path = '/'.ltrim($path, '/');
967 966
 		return $path;
968 967
 	}
969 968
 
@@ -1102,7 +1101,7 @@  discard block
 block discarded – undo
1102 1101
 	 * @return resource|false
1103 1102
 	 * @author Dmitry (dio) Levashov
1104 1103
 	 **/
1105
-	protected function _fopen($path, $mode='rb') {
1104
+	protected function _fopen($path, $mode = 'rb') {
1106 1105
 
1107 1106
 		if (($mode == 'rb' || $mode == 'r')) {
1108 1107
 			try {
@@ -1112,7 +1111,7 @@  discard block
 block discarded – undo
1112 1111
  				fputs($fp, "GET {$url['path']} HTTP/1.0\r\n");
1113 1112
  				fputs($fp, "Host: {$url['host']}\r\n");
1114 1113
  				fputs($fp, "\r\n");
1115
- 				while(trim(fgets($fp)) !== ''){};
1114
+ 				while (trim(fgets($fp)) !== '') {};
1116 1115
  				return $fp;
1117 1116
 			} catch (Dropbox_Exception $e) {
1118 1117
 				return false;
@@ -1143,7 +1142,7 @@  discard block
 block discarded – undo
1143 1142
 	 * @return bool
1144 1143
 	 * @author Dmitry (dio) Levashov
1145 1144
 	 **/
1146
-	protected function _fclose($fp, $path='') {
1145
+	protected function _fclose($fp, $path = '') {
1147 1146
 		@fclose($fp);
1148 1147
 		if ($path) {
1149 1148
 			@unlink($this->getTempFile($path));
Please login to merge, or discard this patch.
php/elFinderVolumeFTP.class.php 2 patches
Doc Comments   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * Return ftp transfer mode for file
478 478
 	 *
479 479
 	 * @param  string  $path  file path
480
-	 * @return string
480
+	 * @return integer
481 481
 	 * @author Dmitry (dio) Levashov
482 482
 	 **/
483 483
 	protected function ftpMode($path) {
@@ -841,7 +841,6 @@  discard block
 block discarded – undo
841 841
 	 * Open file and return file pointer
842 842
 	 *
843 843
 	 * @param  string  $path  file path
844
-	 * @param  bool    $write open file for writing
845 844
 	 * @return resource|false
846 845
 	 * @author Dmitry (dio) Levashov
847 846
 	 **/
@@ -866,7 +865,7 @@  discard block
 block discarded – undo
866 865
 	 * Close opened file
867 866
 	 *
868 867
 	 * @param  resource  $fp  file pointer
869
-	 * @return bool
868
+	 * @return boolean|null
870 869
 	 * @author Dmitry (dio) Levashov
871 870
 	 **/
872 871
 	protected function _fclose($fp, $path='') {
@@ -883,7 +882,7 @@  discard block
 block discarded – undo
883 882
 	 *
884 883
 	 * @param  string  $path  parent dir path
885 884
 	 * @param string  $name  new directory name
886
-	 * @return string|bool
885
+	 * @return false|string
887 886
 	 * @author Dmitry (dio) Levashov
888 887
 	 **/
889 888
 	protected function _mkdir($path, $name) {
@@ -901,7 +900,7 @@  discard block
 block discarded – undo
901 900
 	 *
902 901
 	 * @param  string  $path  parent dir path
903 902
 	 * @param string  $name  new file name
904
-	 * @return string|bool
903
+	 * @return string|false
905 904
 	 * @author Dmitry (dio) Levashov
906 905
 	 **/
907 906
 	protected function _mkfile($path, $name) {
@@ -933,7 +932,7 @@  discard block
 block discarded – undo
933 932
 	 * @param  string  $source     source file path
934 933
 	 * @param  string  $targetDir  target directory path
935 934
 	 * @param  string  $name       new file name
936
-	 * @return bool
935
+	 * @return string|false
937 936
 	 * @author Dmitry (dio) Levashov
938 937
 	 **/
939 938
 	protected function _copy($source, $targetDir, $name) {
@@ -958,9 +957,9 @@  discard block
 block discarded – undo
958 957
 	 * Return new file path or false.
959 958
 	 *
960 959
 	 * @param  string  $source  source file path
961
-	 * @param  string  $target  target dir path
960
+	 * @param  string  $targetDir  target dir path
962 961
 	 * @param  string  $name    file name
963
-	 * @return string|bool
962
+	 * @return string|false
964 963
 	 * @author Dmitry (dio) Levashov
965 964
 	 **/
966 965
 	protected function _move($source, $targetDir, $name) {
@@ -998,7 +997,7 @@  discard block
 block discarded – undo
998 997
 	 * @param  string    $dir  target dir path
999 998
 	 * @param  string    $name file name
1000 999
 	 * @param  array     $stat file stat (required by some virtual fs)
1001
-	 * @return bool|string
1000
+	 * @return string|false
1002 1001
 	 * @author Dmitry (dio) Levashov
1003 1002
 	 **/
1004 1003
 	protected function _save($fp, $dir, $name, $stat) {
@@ -1231,7 +1230,7 @@  discard block
 block discarded – undo
1231 1230
 	 * @param  array   $files  files names list
1232 1231
 	 * @param  string  $name   archive name
1233 1232
 	 * @param  array   $arc    archiver options
1234
-	 * @return string|bool
1233
+	 * @return false|string
1235 1234
 	 * @author Dmitry (dio) Levashov,
1236 1235
 	 * @author Alexey Sukhotin
1237 1236
 	 **/
@@ -1350,9 +1349,9 @@  discard block
 block discarded – undo
1350 1349
 	 * Downloads specified files from remote directory
1351 1350
 	 * if there is a directory among files it is downloaded recursively (omitting symbolic links).
1352 1351
 	 * 
1353
-	 * @param $remote_directory string remote FTP path to a source directory to download from.
1352
+	 * @param string $remote_directory string remote FTP path to a source directory to download from.
1354 1353
 	 * @param array $files list of files to download from remote directory.
1355
-	 * @param $dest_local_directory string destination folder to store downloaded files.
1354
+	 * @param string $dest_local_directory string destination folder to store downloaded files.
1356 1355
 	 * @return bool true on success and false on failure.
1357 1356
 	 */
1358 1357
 	private function ftp_download_files($remote_directory, array $files, $dest_local_directory)
@@ -1423,6 +1422,7 @@  discard block
 block discarded – undo
1423 1422
 	 * Returns array of strings containing all files and folders in the specified local directory.
1424 1423
 	 * @param $dir
1425 1424
 	 * @param string $prefix
1425
+	 * @param boolean $omitSymlinks
1426 1426
 	 * @internal param string $path path to directory to scan.
1427 1427
 	 * @return array array of files and folders names relative to the $path
1428 1428
 	 * or an empty array if the directory $path is empty,
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		);
104 104
 		$this->options = array_merge($this->options, $opts); 
105 105
 		$this->options['mimeDetect'] = 'internal';
106
-		$this->options['maxArcFilesSize'] = 0;     // max allowed archive files size (0 - no limit)
106
+		$this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit)
107 107
 	}
108 108
 	
109 109
 	/**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		$scheme = parse_url($this->options['host'], PHP_URL_SCHEME);
164 164
 
165 165
 		if ($scheme) {
166
-			$this->options['host'] = substr($this->options['host'], strlen($scheme)+3);
166
+			$this->options['host'] = substr($this->options['host'], strlen($scheme) + 3);
167 167
 		}
168 168
 
169 169
 		// normalize root path
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
 		if ($this->encoding) {
236 236
 			@ftp_exec($this->connect, 'OPTS UTF8 OFF');
237 237
 		} else {
238
-			@ftp_exec($this->connect, 'OPTS UTF8 ON' );
238
+			@ftp_exec($this->connect, 'OPTS UTF8 ON');
239 239
 		}
240 240
 		
241 241
 		// switch off extended passive mode - may be usefull for some servers
242
-		@ftp_exec($this->connect, 'epsv4 off' );
242
+		@ftp_exec($this->connect, 'epsv4 off');
243 243
 		// enter passive mode if required
244 244
 		ftp_pasv($this->connect, $this->options['mode'] == 'passive');
245 245
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 		$name = $info[8];
308 308
 		
309 309
 		if (preg_match('|(.+)\-\>(.+)|', $name, $m)) {
310
-			$name   = trim($m[1]);
310
+			$name = trim($m[1]);
311 311
 			// check recursive processing
312 312
 			if ($this->cacheDirTarget && $this->_joinPath($base, $name) !== $this->cacheDirTarget) {
313 313
 				return array();
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 			$stat['owner'] = $info[2];
344 344
 			$stat['group'] = $info[3];
345 345
 			$stat['perm']  = substr($info[0], 1);
346
-			$stat['isowner'] = $stat['owner']? ($stat['owner'] == $this->options['user']) : $this->options['owner'];
346
+			$stat['isowner'] = $stat['owner'] ? ($stat['owner'] == $this->options['user']) : $this->options['owner'];
347 347
 		}
348 348
 		
349 349
 		$perm = $this->parsePermissions($info[0], $stat['owner']);
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 			$info[4] = 0;
376 376
 			$info[0] = 'drwxr-xr-x';
377 377
 		} else {
378
-			$info[4] = (int)$size;
378
+			$info[4] = (int) $size;
379 379
 			$info[0] = '-rw-r--r--';
380 380
 		}
381 381
 		return $info;
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 	protected function parsePermissions($perm, $user = '') {
392 392
 		$res   = array();
393 393
 		$parts = array();
394
-		$owner = $user? ($user == $this->options['user']) : $this->options['owner'];
394
+		$owner = $user ? ($user == $this->options['user']) : $this->options['owner'];
395 395
 		for ($i = 0, $l = strlen($perm); $i < $l; $i++) {
396 396
 			$parts[] = substr($perm, $i, 1);
397 397
 		}
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
 			}
423 423
 		}
424 424
 		$list = $this->convEncOut($list);
425
-		$prefix = ($path === $this->separator)? $this->separator : $path . $this->separator;
425
+		$prefix = ($path === $this->separator) ? $this->separator : $path.$this->separator;
426 426
 		$targets = array();
427
-		foreach($list as $stat) {
428
-			$p = $prefix . $stat['name'];
427
+		foreach ($list as $stat) {
428
+			$p = $prefix.$stat['name'];
429 429
 			if (isset($stat['target'])) {
430 430
 				// stat later
431 431
 				$targets[$stat['name']] = $stat['target'];
@@ -437,10 +437,10 @@  discard block
 block discarded – undo
437 437
 			}
438 438
 		}
439 439
 		// stat link targets
440
-		foreach($targets as $name => $target) {
440
+		foreach ($targets as $name => $target) {
441 441
 			$stat = array();
442 442
 			$stat['name'] = $name;
443
-			$p = $prefix . $name;
443
+			$p = $prefix.$name;
444 444
 			$cacheDirTarget = $this->cacheDirTarget;
445 445
 			$this->cacheDirTarget = $this->convEncIn($target, true);
446 446
 			if ($tstat = $this->stat($target)) {
@@ -449,12 +449,12 @@  discard block
 block discarded – undo
449 449
 				$stat['thash'] = $tstat['hash'];
450 450
 				$stat['mime']  = $tstat['mime'];
451 451
 				$stat['read']  = $tstat['read'];
452
-				$stat['write']  = $tstat['write'];
452
+				$stat['write'] = $tstat['write'];
453 453
 				
454
-				if (isset($tstat['ts']))      { $stat['ts']      = $tstat['ts']; }
455
-				if (isset($tstat['owner']))   { $stat['owner']   = $tstat['owner']; }
456
-				if (isset($tstat['group']))   { $stat['group']   = $tstat['group']; }
457
- 				if (isset($tstat['perm']))    { $stat['perm']    = $tstat['perm']; }
454
+				if (isset($tstat['ts'])) { $stat['ts']      = $tstat['ts']; }
455
+				if (isset($tstat['owner'])) { $stat['owner']   = $tstat['owner']; }
456
+				if (isset($tstat['group'])) { $stat['group']   = $tstat['group']; }
457
+ 				if (isset($tstat['perm'])) { $stat['perm']    = $tstat['perm']; }
458 458
  				if (isset($tstat['isowner'])) { $stat['isowner'] = $tstat['isowner']; }
459 459
 			} else {
460 460
 				
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 		$comps = $new_comps;
568 568
 		$path = implode($this->separator, $comps);
569 569
 		if ($initial_slashes) {
570
-			$path = str_repeat($this->separator, $initial_slashes) . $path;
570
+			$path = str_repeat($this->separator, $initial_slashes).$path;
571 571
 		}
572 572
 		
573 573
 		return $path ? $path : '.';
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 	 * @author Dmitry (dio) Levashov
634 634
 	 **/
635 635
 	protected function _inpath($path, $parent) {
636
-		return $path == $parent || strpos($path, $parent. $this->separator) === 0;
636
+		return $path == $parent || strpos($path, $parent.$this->separator) === 0;
637 637
 	}
638 638
 	
639 639
 	/***************** file stat ********************/
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
 				);
673 673
 			}
674 674
 			$this->cacheDir($this->convEncOut($this->_dirname($path)));
675
-			return $this->convEncIn(isset($this->cache[$outPath])? $this->cache[$outPath] : array());
675
+			return $this->convEncIn(isset($this->cache[$outPath]) ? $this->cache[$outPath] : array());
676 676
 		}
677
-		$raw = ftp_raw($this->connect, 'MLST ' . $path);
677
+		$raw = ftp_raw($this->connect, 'MLST '.$path);
678 678
 		if (is_array($raw) && count($raw) > 1 && substr(trim($raw[0]), 0, 1) == 2) {
679 679
 			$parts = explode(';', trim($raw[1]));
680 680
 			array_pop($parts);
@@ -704,8 +704,8 @@  discard block
 block discarded – undo
704 704
 
705 705
 					case 'perm':
706 706
 						$val = strtolower($val);
707
-						$stat['read']  = (int)preg_match('/e|l|r/', $val);
708
-						$stat['write'] = (int)preg_match('/w|m|c/', $val);
707
+						$stat['read']  = (int) preg_match('/e|l|r/', $val);
708
+						$stat['write'] = (int) preg_match('/w|m|c/', $val);
709 709
 						if (!preg_match('/f|d/', $val)) {
710 710
 							$stat['locked'] = 1;
711 711
 						}
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 			if (!$this->ftpOsUnix) {
791 791
 				$info = $this->normalizeRawWindows($str);
792 792
 			}
793
-			$name = isset($info[8])? trim($info[8]) : '';
793
+			$name = isset($info[8]) ? trim($info[8]) : '';
794 794
 			if ($name && $name !== '.' && $name !== '..' && substr(strtolower($info[0]), 0, 1) === 'd') {
795 795
 				return true;
796 796
 			}
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
 	 * @return resource|false
846 846
 	 * @author Dmitry (dio) Levashov
847 847
 	 **/
848
-	protected function _fopen($path, $mode='rb') {
848
+	protected function _fopen($path, $mode = 'rb') {
849 849
 		
850 850
 		if ($this->tmp) {
851 851
 			$local = $this->getTempFile($path);
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
 	 * @return bool
870 870
 	 * @author Dmitry (dio) Levashov
871 871
 	 **/
872
-	protected function _fclose($fp, $path='') {
872
+	protected function _fclose($fp, $path = '') {
873 873
 		@fclose($fp);
874 874
 		if ($path) {
875 875
 			@unlink($this->getTempFile($path));
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 			if (@file_put_contents($local, $content, LOCK_EX) !== false
1045 1045
 			&& ($fp = @fopen($local, 'rb'))) {
1046 1046
 				clearstatcache();
1047
-				$res  = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path));
1047
+				$res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path));
1048 1048
 				@fclose($fp);
1049 1049
 			}
1050 1050
 			file_exists($local) && @unlink($local);
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 	 * @return bool
1070 1070
 	 **/
1071 1071
 	protected function _chmod($path, $mode) {
1072
-		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode));
1072
+		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode));
1073 1073
 		return @ftp_chmod($this->connect, $modeOct, $path);
1074 1074
 	}
1075 1075
 
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
 		}
1123 1123
 
1124 1124
 		$basename = $this->_basename($path);
1125
-		$localPath = $dir . DIRECTORY_SEPARATOR . $basename;
1125
+		$localPath = $dir.DIRECTORY_SEPARATOR.$basename;
1126 1126
 
1127 1127
 		if (!ftp_get($this->connect, $localPath, $path, FTP_BINARY)) {
1128 1128
 			//cleanup
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 		
1160 1160
 		// archive contains one item - extract in archive dir
1161 1161
 		$name = '';
1162
-		$src = $dir . DIRECTORY_SEPARATOR . $filesToProcess[0];
1162
+		$src = $dir.DIRECTORY_SEPARATOR.$filesToProcess[0];
1163 1163
 		if (($extractTo === 'auto' || !$extractTo) && count($filesToProcess) === 1 && is_file($src)) {
1164 1164
 			$name = $filesToProcess[0];
1165 1165
 		} else if ($extractTo === 'auto' || $extractTo) {
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 			$src = $dir;
1169 1169
 			$name = basename($path);
1170 1170
 			if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
1171
-				$name = substr($name, 0,  strlen($name)-strlen($m[0]));
1171
+				$name = substr($name, 0, strlen($name) - strlen($m[0]));
1172 1172
 			}
1173 1173
 			$test = $this->_joinPath(dirname($path), $name);
1174 1174
 			if ($this->stat($test)) {
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 		if ($name !== '' && is_file($src)) {
1180 1180
 			$result = $this->_joinPath(dirname($path), $name);
1181 1181
 
1182
-			if (! ftp_put($this->connect, $result, $src, FTP_BINARY)) {
1182
+			if (!ftp_put($this->connect, $result, $src, FTP_BINARY)) {
1183 1183
 				$this->rmdirRecursive($dir);
1184 1184
 				return false;
1185 1185
 			}
@@ -1193,19 +1193,19 @@  discard block
 block discarded – undo
1193 1193
 				}
1194 1194
 				$result[] = $dstDir;
1195 1195
 			}
1196
-			foreach($filesToProcess as $name) {
1196
+			foreach ($filesToProcess as $name) {
1197 1197
 				$name = rtrim($name, DIRECTORY_SEPARATOR);
1198
-				$src = $dir . DIRECTORY_SEPARATOR . $name;
1198
+				$src = $dir.DIRECTORY_SEPARATOR.$name;
1199 1199
 				if (is_dir($src)) {
1200 1200
 					$p = dirname($name);
1201 1201
 					$name = basename($name);
1202
-					if (! $target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) {
1202
+					if (!$target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) {
1203 1203
 						$this->rmdirRecursive($dir);
1204 1204
 						return false;
1205 1205
 					}
1206 1206
 				} else {
1207 1207
 					$target = $this->_joinPath($dstDir, $name);
1208
-					if (! ftp_put($this->connect, $target, $src, FTP_BINARY)) {
1208
+					if (!ftp_put($this->connect, $target, $src, FTP_BINARY)) {
1209 1209
 						$this->rmdirRecursive($dir);
1210 1210
 						return false;
1211 1211
 					}
@@ -1221,7 +1221,7 @@  discard block
 block discarded – undo
1221 1221
 		is_dir($dir) && $this->rmdirRecursive($dir);
1222 1222
 		
1223 1223
 		$this->clearcache();
1224
-		return $result? $result : false;
1224
+		return $result ? $result : false;
1225 1225
 	}
1226 1226
 
1227 1227
 	/**
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
 		}
1262 1262
 
1263 1263
 		//cleanup
1264
-		if(!$this->rmdirRecursive($tmpDir)) {
1264
+		if (!$this->rmdirRecursive($tmpDir)) {
1265 1265
 			return false;
1266 1266
 		}
1267 1267
 
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
 		$remoteDirLen = strlen($remote_directory);
1366 1366
 		foreach ($contents as $item) {
1367 1367
 			$relative_path = substr($item['path'], $remoteDirLen);
1368
-			$local_path = $dest_local_directory . DIRECTORY_SEPARATOR . $relative_path;
1368
+			$local_path = $dest_local_directory.DIRECTORY_SEPARATOR.$relative_path;
1369 1369
 			switch ($item['type']) {
1370 1370
 				case 'd':
1371 1371
 					$success = mkdir($local_path);
@@ -1396,8 +1396,8 @@  discard block
 block discarded – undo
1396 1396
 		} else {
1397 1397
 			$success = true;
1398 1398
 			foreach (array_reverse(elFinderVolumeFTP::listFilesInDirectory($dirPath, false)) as $path) {
1399
-				$path = $dirPath . DIRECTORY_SEPARATOR . $path;
1400
-				if(is_link($path)) {
1399
+				$path = $dirPath.DIRECTORY_SEPARATOR.$path;
1400
+				if (is_link($path)) {
1401 1401
 					unlink($path);
1402 1402
 				} else if (is_dir($path)) {
1403 1403
 					$success = rmdir($path);
@@ -1408,11 +1408,11 @@  discard block
 block discarded – undo
1408 1408
 					break;
1409 1409
 				}
1410 1410
 			}
1411
-			if($success) {
1411
+			if ($success) {
1412 1412
 				$success = rmdir($dirPath);
1413 1413
 			}
1414 1414
 		}
1415
-		if(!$success) {
1415
+		if (!$success) {
1416 1416
 			$this->setError(elFinder::ERROR_RM, $dirPath);
1417 1417
 			return false;
1418 1418
 		}
@@ -1434,25 +1434,25 @@  discard block
 block discarded – undo
1434 1434
 		if (!is_dir($dir)) {
1435 1435
 			return false;
1436 1436
 		}
1437
-		$excludes = array(".","..");
1437
+		$excludes = array(".", "..");
1438 1438
 		$result = array();
1439 1439
 		$files = scandir($dir);
1440
-		if(!$files) {
1440
+		if (!$files) {
1441 1441
 			return array();
1442 1442
 		}
1443
-		foreach($files as $file) {
1444
-			if(!in_array($file, $excludes)) {
1443
+		foreach ($files as $file) {
1444
+			if (!in_array($file, $excludes)) {
1445 1445
 				$path = $dir.DIRECTORY_SEPARATOR.$file;
1446
-				if(is_link($path)) {
1447
-					if($omitSymlinks) {
1446
+				if (is_link($path)) {
1447
+					if ($omitSymlinks) {
1448 1448
 						continue;
1449 1449
 					} else {
1450 1450
 						$result[] = $prefix.$file;
1451 1451
 					}
1452
-				} else if(is_dir($path)) {
1452
+				} else if (is_dir($path)) {
1453 1453
 					$result[] = $prefix.$file.DIRECTORY_SEPARATOR;
1454 1454
 					$subs = elFinderVolumeFTP::listFilesInDirectory($path, $omitSymlinks, $prefix.$file.DIRECTORY_SEPARATOR);
1455
-					if($subs) {
1455
+					if ($subs) {
1456 1456
 						$result = array_merge($result, $subs);
1457 1457
 					}
1458 1458
 					
Please login to merge, or discard this patch.
php/elFinderVolumeLocalFileSystem.class.php 2 patches
Doc Comments   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -593,7 +593,6 @@  discard block
 block discarded – undo
593 593
 	 * Open file and return file pointer
594 594
 	 *
595 595
 	 * @param  string  $path  file path
596
-	 * @param  bool    $write open file for writing
597 596
 	 * @return resource|false
598 597
 	 * @author Dmitry (dio) Levashov
599 598
 	 **/
@@ -619,7 +618,7 @@  discard block
 block discarded – undo
619 618
 	 *
620 619
 	 * @param  string  $path  parent dir path
621 620
 	 * @param string  $name  new directory name
622
-	 * @return string|bool
621
+	 * @return string|false
623 622
 	 * @author Dmitry (dio) Levashov
624 623
 	 **/
625 624
 	protected function _mkdir($path, $name) {
@@ -639,7 +638,7 @@  discard block
 block discarded – undo
639 638
 	 *
640 639
 	 * @param  string  $path  parent dir path
641 640
 	 * @param string  $name  new file name
642
-	 * @return string|bool
641
+	 * @return string|false
643 642
 	 * @author Dmitry (dio) Levashov
644 643
 	 **/
645 644
 	protected function _mkfile($path, $name) {
@@ -687,9 +686,9 @@  discard block
 block discarded – undo
687 686
 	 * Return new file path or false.
688 687
 	 *
689 688
 	 * @param  string  $source  source file path
690
-	 * @param  string  $target  target dir path
689
+	 * @param  string  $targetDir  target dir path
691 690
 	 * @param  string  $name    file name
692
-	 * @return string|bool
691
+	 * @return string|false
693 692
 	 * @author Dmitry (dio) Levashov
694 693
 	 **/
695 694
 	protected function _move($source, $targetDir, $name) {
@@ -733,7 +732,7 @@  discard block
 block discarded – undo
733 732
 	 * @param  string    $dir  target dir path
734 733
 	 * @param  string    $name file name
735 734
 	 * @param  array     $stat file stat (required by some virtual fs)
736
-	 * @return bool|string
735
+	 * @return false|string
737 736
 	 * @author Dmitry (dio) Levashov
738 737
 	 **/
739 738
 	protected function _save($fp, $dir, $name, $stat) {
@@ -761,7 +760,7 @@  discard block
 block discarded – undo
761 760
 	 * Get file contents
762 761
 	 *
763 762
 	 * @param  string  $path  file path
764
-	 * @return string|false
763
+	 * @return string
765 764
 	 * @author Dmitry (dio) Levashov
766 765
 	 **/
767 766
 	protected function _getContents($path) {
@@ -965,7 +964,7 @@  discard block
 block discarded – undo
965 964
 	 * @param  array   $files  files names list
966 965
 	 * @param  string  $name   archive name
967 966
 	 * @param  array   $arc    archiver options
968
-	 * @return string|bool
967
+	 * @return string|false
969 968
 	 * @author Dmitry (dio) Levashov, 
970 969
 	 * @author Alexey Sukhotin
971 970
 	 **/
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 	 * @author Dmitry (dio) Levashov
33 33
 	 **/
34 34
 	public function __construct() {
35
-		$this->options['alias']    = '';              // alias to replace root dir name
36
-		$this->options['dirMode']  = 0755;            // new dirs mode
37
-		$this->options['fileMode'] = 0644;            // new files mode
38
-		$this->options['quarantine'] = '.quarantine';  // quarantine folder name - required to check archive (must be hidden)
39
-		$this->options['maxArcFilesSize'] = 0;        // max allowed archive files size (0 - no limit)
35
+		$this->options['alias']    = ''; // alias to replace root dir name
36
+		$this->options['dirMode']  = 0755; // new dirs mode
37
+		$this->options['fileMode'] = 0644; // new files mode
38
+		$this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden)
39
+		$this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit)
40 40
 		$this->options['rootCssClass'] = 'elfinder-navbar-root-local';
41 41
 	}
42 42
 	
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	protected function init() {
54 54
 		// Normalize directory separator for windows
55 55
 		if (DIRECTORY_SEPARATOR !== '/') {
56
-			foreach(array('path', 'tmpPath', 'quarantine') as $key) {
56
+			foreach (array('path', 'tmpPath', 'quarantine') as $key) {
57 57
 				if ($this->options[$key]) {
58 58
 					$this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]);
59 59
 				}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		// if no thumbnails url - try detect it
100 100
 		if ($root['read'] && !$this->tmbURL && $this->URL) {
101 101
 			if (strpos($this->tmbPath, $this->root) === 0) {
102
-				$this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1));
102
+				$this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1));
103 103
 				if (preg_match("|[^/?&=]$|", $this->tmbURL)) {
104 104
 					$this->tmbURL .= '/';
105 105
 				}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 * @author Dmitry (dio) Levashov
176 176
 	 **/
177 177
 	protected function _joinPath($dir, $name) {
178
-		return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name;
178
+		return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name;
179 179
 	}
180 180
 	
181 181
 	/**
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		$comps = $new_comps;
228 228
 		$path = implode('/', $comps);
229 229
 		if ($initial_slashes) {
230
-			$path = str_repeat('/', $initial_slashes) . $path;
230
+			$path = str_repeat('/', $initial_slashes).$path;
231 231
 		}
232 232
 		
233 233
 		if ($changeSep) {
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 **/
299 299
 	protected function _inpath($path, $parent) {
300 300
 		$cwd = getcwd();
301
-		$real_path   = $this->getFullPath($path,   $cwd);
301
+		$real_path   = $this->getFullPath($path, $cwd);
302 302
 		$real_parent = $this->getFullPath($parent, $cwd);
303 303
 		if ($real_path && $real_parent) {
304 304
 			return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0;
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 					$stat = array();
358 358
 					return $stat;
359 359
 				} else {
360
-					$stat['mime']  = 'symlink-broken';
360
+					$stat['mime'] = 'symlink-broken';
361 361
 					$target = readlink($path);
362 362
 					$lstat = lstat($path);
363 363
 					$ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']);
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 			$fstat = stat($path);
374 374
 			$uid = $fstat['uid'];
375 375
 			$gid = $fstat['gid'];
376
-			$stat['perm'] = substr((string)decoct($fstat['mode']), -4);
376
+			$stat['perm'] = substr((string) decoct($fstat['mode']), -4);
377 377
 			$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
378 378
 		}
379 379
 		
@@ -383,8 +383,8 @@  discard block
 block discarded – undo
383 383
 			$stat['mime'] = $dir ? 'directory' : $this->mimetype($path);
384 384
 		}
385 385
 		//logical rights first
386
-		$stat['read'] = ($linkreadable || is_readable($path))? null : false;
387
-		$stat['write'] = is_writable($path)? null : false;
386
+		$stat['read'] = ($linkreadable || is_readable($path)) ? null : false;
387
+		$stat['write'] = is_writable($path) ? null : false;
388 388
 
389 389
 		if (is_null($stat['read'])) {
390 390
 			$stat['size'] = $dir ? 0 : $size;
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	protected function _subdirs($path) {
454 454
 
455 455
 		if (is_dir($path)) {
456
-			return (bool)glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR);
456
+			return (bool) glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR);
457 457
 		}
458 458
 		return false;
459 459
 	}
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 							$br = true;
535 535
 						} else {
536 536
 							$_path = $fpath;
537
-							$stat['mime']  = 'symlink-broken';
537
+							$stat['mime'] = 'symlink-broken';
538 538
 							$target = readlink($_path);
539 539
 							$lstat = lstat($_path);
540 540
 							$ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']);
@@ -559,13 +559,13 @@  discard block
 block discarded – undo
559 559
 					if ($statOwner && !$linkreadable) {
560 560
 						$uid = $file->getOwner();
561 561
 						$gid = $file->getGroup();
562
-						$stat['perm'] = substr((string)decoct($file->getPerms()), -4);
562
+						$stat['perm'] = substr((string) decoct($file->getPerms()), -4);
563 563
 						$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
564 564
 					}
565 565
 					
566 566
 					//logical rights first
567
-					$stat['read'] = ($linkreadable || $file->isReadable())? null : false;
568
-					$stat['write'] = $file->isWritable()? null : false;
567
+					$stat['read'] = ($linkreadable || $file->isReadable()) ? null : false;
568
+					$stat['write'] = $file->isWritable() ? null : false;
569 569
 					
570 570
 					if (is_null($stat['read'])) {
571 571
 						$stat['size'] = $dir ? 0 : $size;
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 		
582 582
 		if ($cache) {
583 583
 			$cache = $this->convEncOut($cache, false);
584
-			foreach($cache as $d) {
584
+			foreach ($cache as $d) {
585 585
 				$this->updateCache($d[0], $d[1]);
586 586
 			}
587 587
 		}
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	 * @return resource|false
598 598
 	 * @author Dmitry (dio) Levashov
599 599
 	 **/
600
-	protected function _fopen($path, $mode='rb') {
600
+	protected function _fopen($path, $mode = 'rb') {
601 601
 		return @fopen($path, $mode);
602 602
 	}
603 603
 	
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 * @return bool
609 609
 	 * @author Dmitry (dio) Levashov
610 610
 	 **/
611
-	protected function _fclose($fp, $path='') {
611
+	protected function _fclose($fp, $path = '') {
612 612
 		return @fclose($fp);
613 613
 	}
614 614
 	
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 		$path = $this->_joinPath($dir, $name);
741 741
 
742 742
 		$meta = stream_get_meta_data($fp);
743
-		$uri = isset($meta['uri'])? $meta['uri'] : '';
743
+		$uri = isset($meta['uri']) ? $meta['uri'] : '';
744 744
 		if ($uri && @is_file($uri)) {
745 745
 			fclose($fp);
746 746
 			if (!@rename($uri, $path) && !@copy($uri, $path)) {
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 	 * @return bool
801 801
 	 **/
802 802
 	protected function _chmod($path, $mode) {
803
-		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode));
803
+		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode));
804 804
 		$ret = @chmod($path, $modeOct);
805 805
 		$ret && clearstatcache();
806 806
 		return  $ret;
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 				$src = $dir;
919 919
 				$name = basename($path);
920 920
 				if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
921
-					$name = substr($name, 0,  strlen($name)-strlen($m[0]));
921
+					$name = substr($name, 0, strlen($name) - strlen($m[0]));
922 922
 				}
923 923
 				$test = dirname($path).DIRECTORY_SEPARATOR.$name;
924 924
 				if (file_exists($test) || is_link($test)) {
@@ -927,9 +927,9 @@  discard block
 block discarded – undo
927 927
 			}
928 928
 			
929 929
 			if ($name !== '') {
930
-				$result  = dirname($path).DIRECTORY_SEPARATOR.$name;
930
+				$result = dirname($path).DIRECTORY_SEPARATOR.$name;
931 931
 
932
-				if (! @rename($src, $result)) {
932
+				if (!@rename($src, $result)) {
933 933
 					$this->delTree($dir);
934 934
 					return false;
935 935
 				}
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 				$dstDir = dirname($path);
938 938
 				$res = false;
939 939
 				$result = array();
940
-				foreach($ls as $name) {
940
+				foreach ($ls as $name) {
941 941
 					$target = $dstDir.DIRECTORY_SEPARATOR.$name;
942 942
 					if (is_dir($target)) {
943 943
 						$this->delTree($target);
@@ -1013,14 +1013,14 @@  discard block
 block discarded – undo
1013 1013
 		$result = array();
1014 1014
 	
1015 1015
 		$path = $this->convEncIn($path);
1016
-		$dirs = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR);
1017
-		$match = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'.$q.'*', GLOB_NOSORT);
1016
+		$dirs = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR);
1017
+		$match = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'.$q.'*', GLOB_NOSORT);
1018 1018
 		if ($dirs) {
1019 1019
 			$dirs = $this->convEncOut($dirs, false);
1020 1020
 		} 
1021 1021
 		$match = $this->convEncOut($match);
1022 1022
 		if ($match) {
1023
-			foreach($match as $p) {
1023
+			foreach ($match as $p) {
1024 1024
 				$stat = $this->stat($p);
1025 1025
 		
1026 1026
 				if (!$stat) { // invalid links
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 						if ($this->encoding) {
1041 1041
 							$path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true)));
1042 1042
 						}
1043
-						$stat['url'] = $this->URL . $path;
1043
+						$stat['url'] = $this->URL.$path;
1044 1044
 					}
1045 1045
 		
1046 1046
 					$result[] = $stat;
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 			}
1049 1049
 		}
1050 1050
 		if ($dirs) {
1051
-			foreach($dirs as $dir) {
1051
+			foreach ($dirs as $dir) {
1052 1052
 				$stat = $this->stat($dir);
1053 1053
 				if ($stat['read'] && !isset($stat['alias'])) {
1054 1054
 					@set_time_limit(30);
Please login to merge, or discard this patch.
php/elFinderVolumeMySQL.class.php 2 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	 * Close opened file
612 612
 	 *
613 613
 	 * @param  resource  $fp  file pointer
614
-	 * @return bool
614
+	 * @return boolean|null
615 615
 	 * @author Dmitry (dio) Levashov
616 616
 	 **/
617 617
 	protected function _fclose($fp, $path='') {
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 	 *
629 629
 	 * @param  string  $path  parent dir path
630 630
 	 * @param string  $name  new directory name
631
-	 * @return string|bool
631
+	 * @return string|false
632 632
 	 * @author Dmitry (dio) Levashov
633 633
 	 **/
634 634
 	protected function _mkdir($path, $name) {
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 	 *
641 641
 	 * @param  string  $path  parent dir path
642 642
 	 * @param string  $name  new file name
643
-	 * @return string|bool
643
+	 * @return string|false
644 644
 	 * @author Dmitry (dio) Levashov
645 645
 	 **/
646 646
 	protected function _mkfile($path, $name) {
@@ -684,9 +684,9 @@  discard block
 block discarded – undo
684 684
 	 * Return new file path or false.
685 685
 	 *
686 686
 	 * @param  string  $source  source file path
687
-	 * @param  string  $target  target dir path
687
+	 * @param  string  $targetDir  target dir path
688 688
 	 * @param  string  $name    file name
689
-	 * @return string|bool
689
+	 * @return string|false
690 690
 	 * @author Dmitry (dio) Levashov
691 691
 	 **/
692 692
 	protected function _move($source, $targetDir, $name) {
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
 	 *
870 870
 	 * @param  string  $path  archive path
871 871
 	 * @param  array   $arc   archiver command and arguments (same as in $this->archivers)
872
-	 * @return true
872
+	 * @return boolean
873 873
 	 * @author Dmitry (dio) Levashov, 
874 874
 	 * @author Alexey Sukhotin
875 875
 	 **/
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 	 * @param  array   $files  files names list
885 885
 	 * @param  string  $name   archive name
886 886
 	 * @param  array   $arc    archiver options
887
-	 * @return string|bool
887
+	 * @return boolean
888 888
 	 * @author Dmitry (dio) Levashov, 
889 889
 	 * @author Alexey Sukhotin
890 890
 	 **/
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 		$dirs = array();
312 312
 		if ($path != $this->root) {
313 313
 			$inpath = array(intval($path));
314
-			while($inpath) {
314
+			while ($inpath) {
315 315
 				$in = '('.join(',', $inpath).')';
316 316
 				$inpath = array();
317 317
 				$sql = 'SELECT f.id FROM %s AS f WHERE f.parent_id IN '.$in.' AND `mime` = \'directory\'';
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 		
331 331
 		if ($mimes) {
332 332
 			$whrs = array();
333
-			foreach($mimes as $mime) {
333
+			foreach ($mimes as $mime) {
334 334
 				if (strpos($mime, '/') === false) {
335 335
 					$whrs[] = sprintf('f.mime LIKE "%s/%%"', $this->db->real_escape_string($mime));
336 336
 				} else {
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 			$whr = sprintf('f.name RLIKE "%s"', $this->db->real_escape_string($q));
343 343
 		}
344 344
 		if ($dirs) {
345
-			$whr = '(' . $whr . ') AND (`parent_id` IN (' . join(',', $dirs) . '))';
345
+			$whr = '('.$whr.') AND (`parent_id` IN ('.join(',', $dirs).'))';
346 346
 		}
347 347
 		
348 348
 		$sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, 0 AS dirs 
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 	 * @return resource|false
588 588
 	 * @author Dmitry (dio) Levashov
589 589
 	 **/
590
-	protected function _fopen($path, $mode='rb') {
590
+	protected function _fopen($path, $mode = 'rb') {
591 591
 		$fp = $this->tmbPath
592 592
 			? @fopen($this->getTempFile($path), 'w+')
593 593
 			: @tmpfile();
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 	 * @return bool
615 615
 	 * @author Dmitry (dio) Levashov
616 616
 	 **/
617
-	protected function _fclose($fp, $path='') {
617
+	protected function _fclose($fp, $path = '') {
618 618
 		@fclose($fp);
619 619
 		if ($path) {
620 620
 			@unlink($this->getTempFile($path));
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 		$this->clearcache();
747 747
 		
748 748
 		$mime = $stat['mime'];
749
-		$w = !empty($stat['width'])  ? $stat['width']  : 0;
749
+		$w = !empty($stat['width']) ? $stat['width'] : 0;
750 750
 		$h = !empty($stat['height']) ? $stat['height'] : 0;
751 751
 		
752 752
 		$id = $this->_joinPath($dir, $name);
Please login to merge, or discard this patch.
php/elFinderVolumeS3.class.php 3 patches
Doc Comments   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -368,7 +368,6 @@  discard block
 block discarded – undo
368 368
 	 * Open file and return file pointer
369 369
 	 *
370 370
 	 * @param  string  $path  file path
371
-	 * @param  bool    $write open file for writing
372 371
 	 * @return resource|false
373 372
 	 * @author Dmitry (dio) Levashov,
374 373
 	 * @author Alexey Sukhotin
@@ -407,7 +406,7 @@  discard block
 block discarded – undo
407 406
 	 * 
408 407
 	 * @param  resource  $fp    file pointer
409 408
 	 * @param  string    $path  file path
410
-	 * @return bool
409
+	 * @return boolean|null
411 410
 	 * @author Dmitry (dio) Levashov
412 411
 	 **/
413 412
 	protected function _fclose($fp, $path='') {
@@ -492,7 +491,7 @@  discard block
 block discarded – undo
492 491
 	 * Copy file into another file (only inside one volume)
493 492
 	 *
494 493
 	 * @param  string  $source  source file path
495
-	 * @param  string  $target  target dir path
494
+	 * @param  string  $targetDir  target dir path
496 495
 	 * @param  string  $name    file name
497 496
 	 * @return bool
498 497
 	 * @author Dmitry (dio) Levashov
@@ -506,9 +505,9 @@  discard block
 block discarded – undo
506 505
 	 * Return new file path or false.
507 506
 	 *
508 507
 	 * @param  string  $source  source file path
509
-	 * @param  string  $target  target dir path
508
+	 * @param  string  $targetDir  target dir path
510 509
 	 * @param  string  $name    file name
511
-	 * @return string|bool
510
+	 * @return boolean
512 511
 	 * @author Dmitry (dio) Levashov
513 512
 	 **/
514 513
 	protected function _move($source, $targetDir, $name) {
@@ -573,7 +572,7 @@  discard block
 block discarded – undo
573 572
 	 * @param  resource  $fp   file pointer
574 573
 	 * @param  string    $dir  target dir path
575 574
 	 * @param  string    $name file name
576
-	 * @return bool|string
575
+	 * @return boolean
577 576
 	 * @author Dmitry (dio) Levashov
578 577
 	 **/
579 578
 	protected function _save($fp, $dir, $name, $mime, $stat) {
@@ -584,7 +583,7 @@  discard block
 block discarded – undo
584 583
 	 * Get file contents
585 584
 	 *
586 585
 	 * @param  string  $path  file path
587
-	 * @return string|false
586
+	 * @return boolean
588 587
 	 * @author Dmitry (dio) Levashov
589 588
 	 **/
590 589
 	protected function _getContents($path) {
@@ -623,7 +622,7 @@  discard block
 block discarded – undo
623 622
 	 * @param  array   $files  files names list
624 623
 	 * @param  string  $name   archive name
625 624
 	 * @param  array   $arc    archiver options
626
-	 * @return string|bool
625
+	 * @return boolean
627 626
 	 * @author Dmitry (dio) Levashov, 
628 627
 	 * @author Alexey Sukhotin
629 628
 	 **/
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 **/
62 62
 	protected function _dirname($path) {
63 63
 	
64
-		$newpath =  preg_replace("/\/$/", "", $path);
65
-		$dn = substr($path, 0, strrpos($newpath, '/')) ;
64
+		$newpath = preg_replace("/\/$/", "", $path);
65
+		$dn = substr($path, 0, strrpos($newpath, '/'));
66 66
 		
67 67
 		if (substr($dn, 0, 1) != '/') {
68 68
 		 $dn = "/$dn";
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	 * @author Troex Nevelin
106 106
 	 **/
107 107
 	protected function _normpath($path) {
108
-		$tmp =  preg_replace("/^\//", "", $path);
109
-		$tmp =  preg_replace("/\/\//", "/", $tmp);
110
-		$tmp =  preg_replace("/\/$/", "", $tmp);
108
+		$tmp = preg_replace("/^\//", "", $path);
109
+		$tmp = preg_replace("/\/\//", "/", $tmp);
110
+		$tmp = preg_replace("/\/$/", "", $tmp);
111 111
 		return $tmp;
112 112
 	}
113 113
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 			$newpath = "/$newpath";
129 129
 		}
130 130
 		
131
-		$newpath =  preg_replace("/\/$/", "", $newpath);
131
+		$newpath = preg_replace("/\/$/", "", $newpath);
132 132
 	
133
-		$ret = ($newpath == $this->root) ? '' : substr($newpath, strlen($this->root)+1);
133
+		$ret = ($newpath == $this->root) ? '' : substr($newpath, strlen($this->root) + 1);
134 134
 		
135 135
 		return $ret;
136 136
 	}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		$np = $this->_normpath($path);
232 232
 		
233 233
 		try {
234
-			$obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np , 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false));
234
+			$obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np, 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false));
235 235
 		} catch (Exception $e) {
236 236
 		
237 237
 		}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		if (!isset($obj) || ($obj->GetObjectResponse->Status->Code != 200)) {
240 240
 			$np .= '/';
241 241
 			try {
242
-				$obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np , 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false));
242
+				$obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np, 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false));
243 243
 			} catch (Exception $e) {
244 244
 		
245 245
 			}
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
 	 **/
342 342
 	protected function _scandir($path) {
343 343
 		
344
-		$s3path = preg_replace("/^\//", "", $path) . '/';
344
+		$s3path = preg_replace("/^\//", "", $path).'/';
345 345
 		
346 346
 		$files = $this->s3->ListBucket(array('Bucket' => $this->options['bucket'], 'delimiter' => '/', 'Prefix' => $s3path))->ListBucketResponse->Contents;
347 347
 	
348 348
 		$finalfiles = array();
349 349
 		
350 350
 		foreach ($files as $file) {
351
-			if (preg_match("|^" . $s3path . "[^/]*/?$|", $file->Key)) {
351
+			if (preg_match("|^".$s3path."[^/]*/?$|", $file->Key)) {
352 352
 				$fname = preg_replace("/\/$/", "", $file->Key);
353 353
 				$fname = $file->Key;
354 354
 				
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 * @author Dmitry (dio) Levashov,
374 374
 	 * @author Alexey Sukhotin
375 375
 	 **/
376
-	protected function _fopen($path, $mode="rb") {
376
+	protected function _fopen($path, $mode = "rb") {
377 377
 	
378 378
 		$tn = $this->getTempFile($path);
379 379
 	
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
 		if ($fp) {
386 386
 
387 387
 			try {
388
-				$obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $this->_normpath($path) , 'GetMetadata' => true, 'InlineData' => true, 'GetData' => true));
389
-			}	catch (Exception $e) {
388
+				$obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $this->_normpath($path), 'GetMetadata' => true, 'InlineData' => true, 'GetData' => true));
389
+			} catch (Exception $e) {
390 390
 		
391 391
 			}
392 392
 				
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 * @return bool
411 411
 	 * @author Dmitry (dio) Levashov
412 412
 	 **/
413
-	protected function _fclose($fp, $path='') {
413
+	protected function _fclose($fp, $path = '') {
414 414
 		@fclose($fp);
415 415
 		if ($path) {
416 416
 			@unlink($this->getTempFile($path));
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 		$newkey = "$newkey/$name/";
436 436
 
437 437
 		try {
438
-			$obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey , 'ContentLength' => 0, 'Data' => ''));
438
+			$obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey, 'ContentLength' => 0, 'Data' => ''));
439 439
 		} catch (Exception $e) {
440 440
 		
441 441
 		}
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 		$newkey = "$newkey/$name";
463 463
 
464 464
 		try {
465
-			$obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey , 'ContentLength' => 0, 'Data' => '', 'Metadata' => array(array('Name' => 'Content-Type', 'Value' => 'text/plain'))));
465
+			$obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey, 'ContentLength' => 0, 'Data' => '', 'Metadata' => array(array('Name' => 'Content-Type', 'Value' => 'text/plain'))));
466 466
 		} catch (Exception $e) {
467 467
 		
468 468
 		}
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	 * @author Dmitry (dio) Levashov
564 564
 	 **/
565 565
 	protected function _rmdir($path) {
566
-		return $this->_unlink($path . '/');
566
+		return $this->_unlink($path.'/');
567 567
 	}
568 568
 
569 569
 	/**
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 		/* Getting list of S3 web service functions which requires signing */
683 683
 		$funcs = $this->__getFunctions();
684 684
 		
685
-		$funcnames  = array();
685
+		$funcnames = array();
686 686
 		
687 687
 		foreach ($funcs as $func) {
688 688
 			preg_match("/\S+\s+([^\)]+)\(/", $func, $m);
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 			'Timestamp' => gmdate('Y-m-d\TH:i:s.000\Z'),
724 724
 		);
725 725
 
726
-		$sign_str = 'AmazonS3' . $operation . $params['Timestamp'];
726
+		$sign_str = 'AmazonS3'.$operation.$params['Timestamp'];
727 727
 		
728 728
 		$params['Signature'] = base64_encode(hash_hmac('sha1', $sign_str, $this->secretkey, TRUE));
729 729
 		
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -386,7 +386,7 @@
 block discarded – undo
386 386
 
387 387
 			try {
388 388
 				$obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $this->_normpath($path) , 'GetMetadata' => true, 'InlineData' => true, 'GetData' => true));
389
-			}	catch (Exception $e) {
389
+			} catch (Exception $e) {
390 390
 		
391 391
 			}
392 392
 				
Please login to merge, or discard this patch.
php/plugins/AutoResize/plugin.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -107,6 +107,10 @@  discard block
 block discarded – undo
107 107
 		}
108 108
 	}
109 109
 	
110
+	/**
111
+	 * @param double $width
112
+	 * @param double $height
113
+	 */
110 114
 	private function resize_gd($src, $width, $height, $quality, $srcImgInfo) {
111 115
 		switch ($srcImgInfo['mime']) {
112 116
 			case 'image/gif':
@@ -177,6 +181,10 @@  discard block
 block discarded – undo
177 181
 		return false;
178 182
 	}
179 183
 	
184
+	/**
185
+	 * @param double $width
186
+	 * @param double $height
187
+	 */
180 188
 	private function resize_imagick($src, $width, $height, $quality) {
181 189
 		try {
182 190
 			$img = new imagick($src);
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 
51 51
 	public function __construct($opts) {
52 52
 		$defaults = array(
53
-			'enable'         => true,       // For control by volume driver
54
-			'maxWidth'       => 1024,       // Path to Water mark image
55
-			'maxHeight'      => 1024,       // Margin right pixel
56
-			'quality'        => 95,         // JPEG image save quality
57
-			'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field )
53
+			'enable'         => true, // For control by volume driver
54
+			'maxWidth'       => 1024, // Path to Water mark image
55
+			'maxHeight'      => 1024, // Margin right pixel
56
+			'quality'        => 95, // JPEG image save quality
57
+			'targetType'     => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP // Target image formats ( bit-field )
58 58
 		);
59 59
 
60 60
 		$this->opts = array_merge($defaults, $opts);
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 			$opts = array_merge($this->opts, $volOpts);
69 69
 		}
70 70
 		
71
-		if (! $opts['enable']) {
71
+		if (!$opts['enable']) {
72 72
 			return false;
73 73
 		}
74 74
 		
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 				IMAGETYPE_PNG => IMG_PNG,
85 85
 				IMAGETYPE_WBMP => IMG_WBMP,
86 86
 		);
87
-		if (! ($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) {
87
+		if (!($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) {
88 88
 			return false;
89 89
 		}
90 90
 		
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 	
98 98
 	private function resize($src, $srcImgInfo, $maxWidth, $maxHeight, $quality) {
99
-		$zoom = min(($maxWidth/$srcImgInfo[0]),($maxHeight/$srcImgInfo[1]));
100
-		$width = round($srcImgInfo[0] * $zoom);
101
-		$height = round($srcImgInfo[1] * $zoom);
99
+		$zoom = min(($maxWidth/$srcImgInfo[0]), ($maxHeight/$srcImgInfo[1]));
100
+		$width = round($srcImgInfo[0]*$zoom);
101
+		$height = round($srcImgInfo[1]*$zoom);
102 102
 		
103 103
 		if (class_exists('Imagick')) {
104 104
 			return $this->resize_imagick($src, $width, $height, $quality);
@@ -118,14 +118,14 @@  discard block
 block discarded – undo
118 118
 				break;
119 119
 			case 'image/jpeg':
120 120
 				if (@imagetypes() & IMG_JPG) {
121
-					$oSrcImg = @imagecreatefromjpeg($src) ;
121
+					$oSrcImg = @imagecreatefromjpeg($src);
122 122
 				} else {
123 123
 					$ermsg = 'JPEG images are not supported';
124 124
 				}
125 125
 				break;
126 126
 			case 'image/png':
127 127
 				if (@imagetypes() & IMG_PNG) {
128
-					$oSrcImg = @imagecreatefrompng($src) ;
128
+					$oSrcImg = @imagecreatefrompng($src);
129 129
 				} else {
130 130
 					$ermsg = 'PNG images are not supported';
131 131
 				}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 				break;
144 144
 		}
145 145
 		
146
-		if ($oSrcImg &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
146
+		if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) {
147 147
 			
148 148
 			if (!imagecopyresampled($tmp, $oSrcImg, 0, 0, 0, 0, $width, $height, $srcImgInfo[0], $srcImgInfo[1])) {
149 149
 				return false;
Please login to merge, or discard this patch.
php/chars-test.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@
 block discarded – undo
24 24
 
25 25
 //                     й                 ё              Й               Ё              Ø         Å
26 26
 $patterns = array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a");
27
-$replace  = array("\u0439",        "\u0451",       "\u0419",       "\u0401",       "\u00d8", "\u00c5");
27
+$replace  = array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5");
28 28
 
29 29
 
30
-foreach(scandir($path) as $f) {
30
+foreach (scandir($path) as $f) {
31 31
 	if ($f != '.' && $f != '..' && substr($f, 0, 1) != '.') {
32 32
 		
33 33
 		// echo mb_detect_encoding($f);
Please login to merge, or discard this patch.