Completed
Push — 2.x ( 68308b...d4db0b )
by Naoki
05:34
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.
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.
Spacing   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -203,14 +203,14 @@  discard block
 block discarded – undo
203 203
 	const ERROR_INV_PARAMS        = 'errCmdParams';
204 204
 	const ERROR_OPEN              = 'errOpen';
205 205
 	const ERROR_DIR_NOT_FOUND     = 'errFolderNotFound';
206
-	const ERROR_FILE_NOT_FOUND    = 'errFileNotFound';     // 'File not found.'
206
+	const ERROR_FILE_NOT_FOUND    = 'errFileNotFound'; // 'File not found.'
207 207
 	const ERROR_TRGDIR_NOT_FOUND  = 'errTrgFolderNotFound'; // 'Target folder "$1" not found.'
208 208
 	const ERROR_NOT_DIR           = 'errNotFolder';
209 209
 	const ERROR_NOT_FILE          = 'errNotFile';
210 210
 	const ERROR_PERM_DENIED       = 'errPerm';
211
-	const ERROR_LOCKED            = 'errLocked';        // '"$1" is locked and can not be renamed, moved or removed.'
212
-	const ERROR_EXISTS            = 'errExists';        // 'File named "$1" already exists.'
213
-	const ERROR_INVALID_NAME      = 'errInvName';       // 'Invalid file name.'
211
+	const ERROR_LOCKED            = 'errLocked'; // '"$1" is locked and can not be renamed, moved or removed.'
212
+	const ERROR_EXISTS            = 'errExists'; // 'File named "$1" already exists.'
213
+	const ERROR_INVALID_NAME      = 'errInvName'; // 'Invalid file name.'
214 214
 	const ERROR_MKDIR             = 'errMkdir';
215 215
 	const ERROR_MKFILE            = 'errMkfile';
216 216
 	const ERROR_RENAME            = 'errRename';
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
 	const ERROR_COPY_FROM         = 'errCopyFrom';
220 220
 	const ERROR_COPY_TO           = 'errCopyTo';
221 221
 	const ERROR_COPY_ITSELF       = 'errCopyInItself';
222
-	const ERROR_REPLACE           = 'errReplace';          // 'Unable to replace "$1".'
223
-	const ERROR_RM                = 'errRm';               // 'Unable to remove "$1".'
224
-	const ERROR_RM_SRC            = 'errRmSrc';            // 'Unable remove source file(s)'
225
-	const ERROR_MKOUTLINK         = 'errMkOutLink';        // 'Unable to create a link to outside the volume root.'
226
-	const ERROR_UPLOAD            = 'errUpload';           // 'Upload error.'
227
-	const ERROR_UPLOAD_FILE       = 'errUploadFile';       // 'Unable to upload "$1".'
228
-	const ERROR_UPLOAD_NO_FILES   = 'errUploadNoFiles';    // 'No files found for upload.'
229
-	const ERROR_UPLOAD_TOTAL_SIZE = 'errUploadTotalSize';  // 'Data exceeds the maximum allowed size.'
230
-	const ERROR_UPLOAD_FILE_SIZE  = 'errUploadFileSize';   // 'File exceeds maximum allowed size.'
231
-	const ERROR_UPLOAD_FILE_MIME  = 'errUploadMime';       // 'File type not allowed.'
232
-	const ERROR_UPLOAD_TRANSFER   = 'errUploadTransfer';   // '"$1" transfer error.'
233
-	const ERROR_UPLOAD_TEMP       = 'errUploadTemp';       // 'Unable to make temporary file for upload.'
222
+	const ERROR_REPLACE           = 'errReplace'; // 'Unable to replace "$1".'
223
+	const ERROR_RM                = 'errRm'; // 'Unable to remove "$1".'
224
+	const ERROR_RM_SRC            = 'errRmSrc'; // 'Unable remove source file(s)'
225
+	const ERROR_MKOUTLINK         = 'errMkOutLink'; // 'Unable to create a link to outside the volume root.'
226
+	const ERROR_UPLOAD            = 'errUpload'; // 'Upload error.'
227
+	const ERROR_UPLOAD_FILE       = 'errUploadFile'; // 'Unable to upload "$1".'
228
+	const ERROR_UPLOAD_NO_FILES   = 'errUploadNoFiles'; // 'No files found for upload.'
229
+	const ERROR_UPLOAD_TOTAL_SIZE = 'errUploadTotalSize'; // 'Data exceeds the maximum allowed size.'
230
+	const ERROR_UPLOAD_FILE_SIZE  = 'errUploadFileSize'; // 'File exceeds maximum allowed size.'
231
+	const ERROR_UPLOAD_FILE_MIME  = 'errUploadMime'; // 'File type not allowed.'
232
+	const ERROR_UPLOAD_TRANSFER   = 'errUploadTransfer'; // '"$1" transfer error.'
233
+	const ERROR_UPLOAD_TEMP       = 'errUploadTemp'; // 'Unable to make temporary file for upload.'
234 234
 	// const ERROR_ACCESS_DENIED     = 'errAccess';
235
-	const ERROR_NOT_REPLACE       = 'errNotReplace';       // Object "$1" already exists at this location and can not be replaced with object of another type.
235
+	const ERROR_NOT_REPLACE       = 'errNotReplace'; // Object "$1" already exists at this location and can not be replaced with object of another type.
236 236
 	const ERROR_SAVE              = 'errSave';
237 237
 	const ERROR_EXTRACT           = 'errExtract';
238 238
 	const ERROR_ARCHIVE           = 'errArchive';
@@ -247,17 +247,17 @@  discard block
 block discarded – undo
247 247
 	const ERROR_NETMOUNT          = 'errNetMount';
248 248
 	const ERROR_NETUNMOUNT        = 'errNetUnMount';
249 249
 	const ERROR_NETMOUNT_NO_DRIVER = 'errNetMountNoDriver';
250
-	const ERROR_NETMOUNT_FAILED       = 'errNetMountFailed';
250
+	const ERROR_NETMOUNT_FAILED = 'errNetMountFailed';
251 251
 
252
-	const ERROR_SESSION_EXPIRES 	= 'errSessionExpires';
252
+	const ERROR_SESSION_EXPIRES = 'errSessionExpires';
253 253
 
254 254
 	const ERROR_CREATING_TEMP_DIR 	= 'errCreatingTempDir';
255 255
 	const ERROR_FTP_DOWNLOAD_FILE 	= 'errFtpDownloadFile';
256
-	const ERROR_FTP_UPLOAD_FILE 	= 'errFtpUploadFile';
257
-	const ERROR_FTP_MKDIR 		= 'errFtpMkdir';
256
+	const ERROR_FTP_UPLOAD_FILE = 'errFtpUploadFile';
257
+	const ERROR_FTP_MKDIR = 'errFtpMkdir';
258 258
 	const ERROR_ARCHIVE_EXEC 	= 'errArchiveExec';
259 259
 	const ERROR_EXTRACT_EXEC 	= 'errExtractExec';
260
-	const ERROR_SEARCH_TIMEOUT    = 'errSearchTimeout';    // 'Timed out while searching "$1". Search result is partial.'
260
+	const ERROR_SEARCH_TIMEOUT = 'errSearchTimeout'; // 'Timed out while searching "$1". Search result is partial.'
261 261
 
262 262
 	/**
263 263
 	 * Constructor
@@ -284,17 +284,17 @@  discard block
 block discarded – undo
284 284
 		
285 285
 		$this->time  = $this->utime();
286 286
 		$this->debug = (isset($opts['debug']) && $opts['debug'] ? true : false);
287
-		$this->sessionCloseEarlier = isset($opts['sessionCloseEarlier'])? (bool)$opts['sessionCloseEarlier'] : true;
287
+		$this->sessionCloseEarlier = isset($opts['sessionCloseEarlier']) ? (bool) $opts['sessionCloseEarlier'] : true;
288 288
 		$this->sessionUseCmds = array_flip($sessionUseCmds);
289 289
 		$this->timeout = (isset($opts['timeout']) ? $opts['timeout'] : 0);
290 290
 		$this->uploadTempPath = (isset($opts['uploadTempPath']) ? $opts['uploadTempPath'] : '');
291
-		$this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey'])? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
291
+		$this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey']) ? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
292 292
 		$this->callbackWindowURL = (isset($opts['callbackWindowURL']) ? $opts['callbackWindowURL'] : '');
293 293
 		self::$sessionCacheKey = !empty($opts['sessionCacheKey']) ? $opts['sessionCacheKey'] : 'elFinderCaches';
294 294
 		
295 295
 		// check session cache
296 296
 		$_optsMD5 = md5(json_encode($opts['roots']));
297
-		if (! isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) {
297
+		if (!isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) {
298 298
 			$_SESSION[self::$sessionCacheKey] = array(
299 299
 				'_optsMD5' => $_optsMD5
300 300
 			);
@@ -313,20 +313,20 @@  discard block
 block discarded – undo
313 313
 			$_reqCmd = isset($_req['cmd']) ? $_req['cmd'] : '';
314 314
 			foreach ($opts['bind'] as $cmd => $handlers) {
315 315
 				$doRegist = (strpos($cmd, '*') !== false);
316
-				if (! $doRegist) {
316
+				if (!$doRegist) {
317 317
 					$_getcmd = create_function('$cmd', 'list($ret) = explode(\'.\', $cmd);return trim($ret);');
318 318
 					$doRegist = ($_reqCmd && in_array($_reqCmd, array_map($_getcmd, explode(' ', $cmd))));
319 319
 				}
320 320
 				if ($doRegist) {
321
-					if (! is_array($handlers) || is_object($handlers[0])) {
321
+					if (!is_array($handlers) || is_object($handlers[0])) {
322 322
 						$handlers = array($handlers);
323 323
 					}
324
-					foreach($handlers as $handler) {
324
+					foreach ($handlers as $handler) {
325 325
 						if ($handler) {
326 326
 							if (is_string($handler) && strpos($handler, '.')) {
327 327
 								list($_domain, $_name, $_method) = array_pad(explode('.', $handler), 3, '');
328 328
 								if (strcasecmp($_domain, 'plugin') === 0) {
329
-									if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name])? $opts['plugin'][$_name] : array())
329
+									if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name]) ? $opts['plugin'][$_name] : array())
330 330
 											and method_exists($plugin, $_method)) {
331 331
 										$this->bind($cmd, array($plugin, $_method));
332 332
 									}
@@ -413,13 +413,13 @@  discard block
 block discarded – undo
413 413
 	public function bind($cmd, $handler) {
414 414
 		$allCmds = array_keys($this->commands);
415 415
 		$cmds = array();
416
-		foreach(explode(' ', $cmd) as $_cmd) {
416
+		foreach (explode(' ', $cmd) as $_cmd) {
417 417
 			if ($_cmd !== '') {
418 418
 				if ($all = strpos($_cmd, '*') !== false) {
419 419
 					list(, $sub) = array_pad(explode('.', $_cmd), 2, '');
420 420
 					if ($sub) {
421 421
 						$sub = str_replace('\'', '\\\'', $sub);
422
-						$addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\'' . $sub . '\');');
422
+						$addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\''.$sub.'\');');
423 423
 						$cmds = array_merge($cmds, array_map($addSub, $allCmds));
424 424
 					} else {
425 425
 						$cmds = array_merge($cmds, $allCmds);
@@ -499,16 +499,16 @@  discard block
 block discarded – undo
499 499
 
500 500
 	private function session_expires() {
501 501
 		
502
-		if (!isset($_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'])) {
503
-			$_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time();
502
+		if (!isset($_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'])) {
503
+			$_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time();
504 504
 			return false;
505 505
 		}
506 506
 
507
-		if ( ($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] > $this->timeout) ) {
507
+		if (($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] > $this->timeout)) {
508 508
 			return true;
509 509
 		}
510 510
 
511
-		$_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time();
511
+		$_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time();
512 512
 		return false;	
513 513
 	}
514 514
 	
@@ -541,9 +541,9 @@  discard block
 block discarded – undo
541 541
 		}
542 542
 
543 543
 		// call pre handlers for this command
544
-		$args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd])? false : $this->sessionCloseEarlier;
544
+		$args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd]) ? false : $this->sessionCloseEarlier;
545 545
 		if (!empty($this->listeners[$cmd.'.pre'])) {
546
-			$volume = isset($args['target'])? $this->volume($args['target']) : false;
546
+			$volume = isset($args['target']) ? $this->volume($args['target']) : false;
547 547
 			foreach ($this->listeners[$cmd.'.pre'] as $handler) {
548 548
 				call_user_func_array($handler, array($cmd, &$args, $this, $volume));
549 549
 			}
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 		// unlock session data for multiple access
553 553
 		$this->sessionCloseEarlier && $args['sessionCloseEarlier'] && session_id() && session_write_close();
554 554
 		
555
-		if (substr(PHP_OS,0,3) === 'WIN') {
555
+		if (substr(PHP_OS, 0, 3) === 'WIN') {
556 556
 			// set time out
557 557
 			if (($_max_execution_time = ini_get('max_execution_time')) && $_max_execution_time < 300) {
558 558
 				@set_time_limit(300);
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 		// call handlers for this command
572 572
 		if (!empty($this->listeners[$cmd])) {
573 573
 			foreach ($this->listeners[$cmd] as $handler) {
574
-				if (call_user_func_array($handler,array($cmd,&$result,$args,$this))) {
574
+				if (call_user_func_array($handler, array($cmd, &$result, $args, $this))) {
575 575
 					// handler return true to force sync client after command completed
576 576
 					$result['sync'] = true;
577 577
 				}
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 	 * @return string
631 631
 	 * @author Dmitry (dio) Levashov
632 632
 	 **/
633
-	public function realpath($hash)	{
633
+	public function realpath($hash) {
634 634
 		if (($volume = $this->volume($hash)) == false) {
635 635
 			return false;
636 636
 		}
@@ -686,11 +686,11 @@  discard block
 block discarded – undo
686 686
 	 */
687 687
 	protected function getPluginInstance($name, $opts = array()) {
688 688
 		$key = strtolower($name);
689
-		if (! isset($this->plugins[$key])) {
690
-			$p_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'plugin.php';
689
+		if (!isset($this->plugins[$key])) {
690
+			$p_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.'plugin.php';
691 691
 			if (is_file($p_file)) {
692 692
 				require_once $p_file;
693
-				$class = 'elFinderPlugin' . $name;
693
+				$class = 'elFinderPlugin'.$name;
694 694
 				$this->plugins[$key] = new $class($opts);
695 695
 			} else {
696 696
 				$this->plugins[$key] = false;
@@ -787,8 +787,8 @@  discard block
 block discarded – undo
787 787
 		
788 788
 		$netVolumes = $this->getNetVolumes();
789 789
 		if ($volume->mount($options)) {
790
-			if (! $key = @ $volume->netMountKey) {
791
-				$key = md5($protocol . '-' . join('-', $options));
790
+			if (!$key = @ $volume->netMountKey) {
791
+				$key = md5($protocol.'-'.join('-', $options));
792 792
 			}
793 793
 			$options['driver'] = $driver;
794 794
 			$options['netkey'] = $key;
@@ -857,14 +857,14 @@  discard block
 block discarded – undo
857 857
 		}
858 858
 		// long polling mode
859 859
 		if ($args['compare']) {
860
-			$sleep = max(1, (int)$volume->getOption('lsPlSleep'));
861
-			$limit = max(1, (int)$volume->getOption('plStandby') / $sleep) + 1;
860
+			$sleep = max(1, (int) $volume->getOption('lsPlSleep'));
861
+			$limit = max(1, (int) $volume->getOption('plStandby')/$sleep) + 1;
862 862
 			$timelimit = ini_get('max_execution_time');
863 863
 			$compare = $args['compare'];
864 864
 			do {
865 865
 				$timelimit && @ set_time_limit($timelimit + $sleep);
866 866
 				$_mtime = 0;
867
-				foreach($ls as $_f) {
867
+				foreach ($ls as $_f) {
868 868
 					$_mtime = max($_mtime, $_f['ts']);
869 869
 				}
870 870
 				$compare = strval(count($ls)).':'.strval($_mtime);
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 						break;
879 879
 					}
880 880
 				}
881
-			} while($limit);
881
+			} while ($limit);
882 882
 			if ($ls === false) {
883 883
 				return array('error' => $this->error(self::ERROR_OPEN, $cwd['name'], $volume->error()));
884 884
 			}
@@ -1021,24 +1021,24 @@  discard block
 block discarded – undo
1021 1021
 		}
1022 1022
 
1023 1023
 		// allow change MIME type by 'file.pre' callback functions
1024
-		$mime = isset($args['mime'])? $args['mime'] : $file['mime'];
1024
+		$mime = isset($args['mime']) ? $args['mime'] : $file['mime'];
1025 1025
 		if ($download) {
1026 1026
 			$disp = 'attachment';
1027 1027
 		} else {
1028 1028
 			$dispInlineRegex = $volume->getOption('dispInlineRegex');
1029 1029
 			$inlineRegex = false;
1030 1030
 			if ($dispInlineRegex) {
1031
-				$inlineRegex = '#' . str_replace('#', '\\#', $dispInlineRegex) . '#';
1031
+				$inlineRegex = '#'.str_replace('#', '\\#', $dispInlineRegex).'#';
1032 1032
 				try {
1033 1033
 					preg_match($inlineRegex, '');
1034
-				} catch(Exception $e) {
1034
+				} catch (Exception $e) {
1035 1035
 					$inlineRegex = false;
1036 1036
 				}
1037 1037
 			}
1038 1038
 			if (!$inlineRegex) {
1039 1039
 				$inlineRegex = '#^(?:(?:image|text)|application/x-shockwave-flash$)#';
1040 1040
 			}
1041
-			$disp  = preg_match($inlineRegex, $mime)? 'inline' : 'attachment';
1041
+			$disp = preg_match($inlineRegex, $mime) ? 'inline' : 'attachment';
1042 1042
 		}
1043 1043
 		
1044 1044
 		$filenameEncoded = rawurlencode($file['name']);
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 		$name   = $args['name'];
1148 1148
 		
1149 1149
 		if (($volume = $this->volume($target)) == false
1150
-		||  ($rm  = $volume->file($target)) == false) {
1150
+		||  ($rm = $volume->file($target)) == false) {
1151 1151
 			return array('error' => $this->error(self::ERROR_RENAME, '#'.$target, self::ERROR_FILE_NOT_FOUND));
1152 1152
 		}
1153 1153
 		$rm['realpath'] = $volume->realpath($target);
@@ -1225,9 +1225,9 @@  discard block
 block discarded – undo
1225 1225
 	* @retval false  error
1226 1226
 	* @author Naoki Sawada
1227 1227
 	**/
1228
-	protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) {
1229
-		$method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; 
1230
-		return $this->$method( $url, $timeout, $redirect_max, $ua, $fp );
1228
+	protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) {
1229
+		$method = (function_exists('curl_exec') && !ini_get('safe_mode')) ? 'curl_get_contents' : 'fsock_get_contents'; 
1230
+		return $this->$method($url, $timeout, $redirect_max, $ua, $fp);
1231 1231
 	}
1232 1232
 	
1233 1233
 	/**
@@ -1243,26 +1243,26 @@  discard block
 block discarded – undo
1243 1243
 	 * @retval false  error
1244 1244
 	 * @author Naoki Sawada
1245 1245
 	 **/
1246
-	 protected function curl_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ){
1246
+	 protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1247 1247
 		$ch = curl_init();
1248
-		curl_setopt( $ch, CURLOPT_URL, $url );
1249
-		curl_setopt( $ch, CURLOPT_HEADER, false );
1248
+		curl_setopt($ch, CURLOPT_URL, $url);
1249
+		curl_setopt($ch, CURLOPT_HEADER, false);
1250 1250
 		if ($outfp) {
1251
-			curl_setopt( $ch, CURLOPT_FILE, $outfp );
1251
+			curl_setopt($ch, CURLOPT_FILE, $outfp);
1252 1252
 		} else {
1253
-			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
1254
-			curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true );
1255
-		}
1256
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 );
1257
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_TIME, $timeout );
1258
-		curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
1259
-		curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
1260
-		curl_setopt( $ch, CURLOPT_MAXREDIRS, $redirect_max);
1261
-		curl_setopt( $ch, CURLOPT_USERAGENT, $ua);
1262
-		$result = curl_exec( $ch );
1253
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1254
+			curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
1255
+		}
1256
+		curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1);
1257
+		curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout);
1258
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1259
+		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
1260
+		curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max);
1261
+		curl_setopt($ch, CURLOPT_USERAGENT, $ua);
1262
+		$result = curl_exec($ch);
1263 1263
 		$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
1264
-		curl_close( $ch );
1265
-		return $outfp? $outfp : $result;
1264
+		curl_close($ch);
1265
+		return $outfp ? $outfp : $result;
1266 1266
 	}
1267 1267
 	
1268 1268
 	/**
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 	 * @retval false  error
1279 1279
 	 * @author Naoki Sawada
1280 1280
 	 */
1281
-	protected function fsock_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ) {
1281
+	protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1282 1282
 
1283 1283
 		$connect_timeout = 3;
1284 1284
 		$connect_try = 3;
@@ -1289,7 +1289,7 @@  discard block
 block discarded – undo
1289 1289
 		$headers = '';
1290 1290
 		
1291 1291
 		$arr = parse_url($url);
1292
-		if (!$arr){
1292
+		if (!$arr) {
1293 1293
 			// Bad request
1294 1294
 			return false;
1295 1295
 		}
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 		// query
1298 1298
 		$arr['query'] = isset($arr['query']) ? '?'.$arr['query'] : '';
1299 1299
 		// port
1300
-		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https'])? 443 : 80);
1300
+		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https']) ? 443 : 80);
1301 1301
 		
1302 1302
 		$url_base = $arr['scheme'].'://'.$arr['host'].':'.$arr['port'];
1303 1303
 		$url_path = isset($arr['path']) ? $arr['path'] : '/';
@@ -1306,21 +1306,21 @@  discard block
 block discarded – undo
1306 1306
 		$query = $method.' '.$uri." HTTP/1.0\r\n";
1307 1307
 		$query .= "Host: ".$arr['host']."\r\n";
1308 1308
 		if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n";
1309
-		if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n";
1309
+		if (!is_null($getSize)) $query .= 'Range: bytes=0-'.($getSize - 1)."\r\n";
1310 1310
 		
1311 1311
 		$query .= $headers;
1312 1312
 
1313 1313
 		$query .= "\r\n";
1314 1314
 
1315 1315
 		$fp = $connect_try_count = 0;
1316
-		while( !$fp && $connect_try_count < $connect_try ) {
1316
+		while (!$fp && $connect_try_count < $connect_try) {
1317 1317
 	
1318 1318
 			$errno = 0;
1319 1319
 			$errstr = "";
1320 1320
 			$fp = @ fsockopen(
1321 1321
 			$arr['https'].$arr['host'],
1322 1322
 			$arr['port'],
1323
-			$errno,$errstr,$connect_timeout);
1323
+			$errno, $errstr, $connect_timeout);
1324 1324
 			if ($fp) break;
1325 1325
 			$connect_try_count++;
1326 1326
 			if (connection_aborted()) {
@@ -1345,13 +1345,13 @@  discard block
 block discarded – undo
1345 1345
 		
1346 1346
 		$_response = '';
1347 1347
 		$header = '';
1348
-		while($_response !== "\r\n"){
1348
+		while ($_response !== "\r\n") {
1349 1349
 			$_response = fgets($fp, $readsize);
1350 1350
 			$header .= $_response;
1351 1351
 		};
1352 1352
 		
1353
-		$rccd = array_pad(explode(' ',$header,3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1354
-		$rc = (int)$rccd[1];
1353
+		$rccd = array_pad(explode(' ', $header, 3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1354
+		$rc = (int) $rccd[1];
1355 1355
 		
1356 1356
 		// Redirect
1357 1357
 		switch ($rc) {
@@ -1360,19 +1360,19 @@  discard block
 block discarded – undo
1360 1360
 			case 302: // Moved Temporarily
1361 1361
 			case 301: // Moved Permanently
1362 1362
 				$matches = array();
1363
-				if (preg_match('/^Location: (.+?)(#.+)?$/im',$header,$matches) && --$redirect_max > 0) {
1363
+				if (preg_match('/^Location: (.+?)(#.+)?$/im', $header, $matches) && --$redirect_max > 0) {
1364 1364
 					$url = trim($matches[1]);
1365
-					$hash = isset($matches[2])? trim($matches[2]) : '';
1366
-					if (!preg_match('/^https?:\//',$url)) { // no scheme
1365
+					$hash = isset($matches[2]) ? trim($matches[2]) : '';
1366
+					if (!preg_match('/^https?:\//', $url)) { // no scheme
1367 1367
 						if ($url{0} != '/') { // Relative path
1368 1368
 							// to Absolute path
1369
-							$url = substr($url_path,0,strrpos($url_path,'/')).'/'.$url;
1369
+							$url = substr($url_path, 0, strrpos($url_path, '/')).'/'.$url;
1370 1370
 						}
1371 1371
 						// add sheme,host
1372 1372
 						$url = $url_base.$url;
1373 1373
 					}
1374 1374
 					fclose($fp);
1375
-					return $this->fsock_get_contents( $url, $timeout, $redirect_max, $ua, $outfp );
1375
+					return $this->fsock_get_contents($url, $timeout, $redirect_max, $ua, $outfp);
1376 1376
 				}
1377 1377
 		}
1378 1378
 		
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 			$outfp = fopen('php://temp', 'rwb');
1382 1382
 			$body = true;
1383 1383
 		}
1384
-		while(fwrite($outfp, fread($fp, $readsize))) {
1384
+		while (fwrite($outfp, fread($fp, $readsize))) {
1385 1385
 			if ($timeout) {
1386 1386
 				$_status = socket_get_status($fp);
1387 1387
 				if ($_status['timed_out']) {
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 		
1401 1401
 		fclose($fp);
1402 1402
 		
1403
-		return $outfp? $outfp : $body; // Data
1403
+		return $outfp ? $outfp : $body; // Data
1404 1404
 	}
1405 1405
 	
1406 1406
 	/**
@@ -1411,13 +1411,13 @@  discard block
 block discarded – undo
1411 1411
 	 * @return array
1412 1412
 	 * @author Naoki Sawada
1413 1413
 	 */
1414
-	protected function parse_data_scheme( $str, $extTable ) {
1414
+	protected function parse_data_scheme($str, $extTable) {
1415 1415
 		$data = $name = '';
1416 1416
 		if ($fp = fopen('data://'.substr($str, 5), 'rb')) {
1417 1417
 			if ($data = stream_get_contents($fp)) {
1418 1418
 				$meta = stream_get_meta_data($fp);
1419
-				$ext = isset($extTable[$meta['mediatype']])? '.' . $extTable[$meta['mediatype']] : '';
1420
-				$name = substr(md5($data), 0, 8) . $ext;
1419
+				$ext = isset($extTable[$meta['mediatype']]) ? '.'.$extTable[$meta['mediatype']] : '';
1420
+				$name = substr(md5($data), 0, 8).$ext;
1421 1421
 			}
1422 1422
 			fclose($fp);
1423 1423
 		}
@@ -1481,7 +1481,7 @@  discard block
 block discarded – undo
1481 1481
 			}
1482 1482
 		}
1483 1483
 		
1484
-		return ($mime && isset($extTable[$mime]))? ('.' . $extTable[$mime]) : '';
1484
+		return ($mime && isset($extTable[$mime])) ? ('.'.$extTable[$mime]) : '';
1485 1485
 	}
1486 1486
 	
1487 1487
 	/**
@@ -1503,12 +1503,12 @@  discard block
 block discarded – undo
1503 1503
 			$testDirs[] = sys_get_temp_dir();
1504 1504
 		}
1505 1505
 		$tempDir = '';
1506
-		foreach($testDirs as $testDir) {
1506
+		foreach ($testDirs as $testDir) {
1507 1507
 			if (!$testDir || !is_dir($testDir)) continue;
1508 1508
 			if (is_writable($testDir)) {
1509 1509
 				$tempDir = $testDir;
1510 1510
 				$gc = time() - 3600;
1511
-				foreach(glob($tempDir . DIRECTORY_SEPARATOR .'ELF*') as $cf) {
1511
+				foreach (glob($tempDir.DIRECTORY_SEPARATOR.'ELF*') as $cf) {
1512 1512
 					if (filemtime($cf) < $gc) {
1513 1513
 						@unlink($cf);
1514 1514
 					}
@@ -1528,7 +1528,7 @@  discard block
 block discarded – undo
1528 1528
 	 **/
1529 1529
 	protected function chmod($args) {
1530 1530
 		$targets = $args['targets'];
1531
-		$mode    = intval((string)$args['mode'], 8);
1531
+		$mode    = intval((string) $args['mode'], 8);
1532 1532
 
1533 1533
 		if (!is_array($targets)) {
1534 1534
 			$targets = array($targets);
@@ -1543,10 +1543,10 @@  discard block
 block discarded – undo
1543 1543
 
1544 1544
 		$files = array();
1545 1545
 		$errors = array();
1546
-		foreach($targets as $target) {
1546
+		foreach ($targets as $target) {
1547 1547
 			$file = $volume->chmod($target, $mode);
1548 1548
 			if ($file) {
1549
-				$files = array_merge($files, is_array($file)? $file : array($file));
1549
+				$files = array_merge($files, is_array($file) ? $file : array($file));
1550 1550
 			} else {
1551 1551
 				$errors = array_merge($errors, $volume->error());
1552 1552
 			}
@@ -1577,26 +1577,26 @@  discard block
 block discarded – undo
1577 1577
 	private function checkChunkedFile($tmpname, $chunk, $cid, $tempDir, $volume = null) {
1578 1578
 		if (preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m)) {
1579 1579
 			$fname = $m[1];
1580
-			$encname = md5($cid . '_' . $fname);
1581
-			$base = $tempDir . DIRECTORY_SEPARATOR . 'ELF' . $encname;
1580
+			$encname = md5($cid.'_'.$fname);
1581
+			$base = $tempDir.DIRECTORY_SEPARATOR.'ELF'.$encname;
1582 1582
 			$clast = intval($m[3]);
1583 1583
 			if (is_null($tmpname)) {
1584 1584
 				ignore_user_abort(true);
1585 1585
 				sleep(10); // wait 10 sec
1586 1586
 				// chunked file upload fail
1587
-				foreach(glob($base . '*') as $cf) {
1587
+				foreach (glob($base.'*') as $cf) {
1588 1588
 					@unlink($cf);
1589 1589
 				}
1590 1590
 				ignore_user_abort(false);
1591 1591
 				return;
1592 1592
 			}
1593 1593
 			
1594
-			$range = isset($_POST['range'])? trim($_POST['range']) : '';
1594
+			$range = isset($_POST['range']) ? trim($_POST['range']) : '';
1595 1595
 			if ($range && preg_match('/^(\d+),(\d+),(\d+)$/', $range, $ranges)) {
1596 1596
 				$start = $ranges[1];
1597 1597
 				$len   = $ranges[2];
1598 1598
 				$size  = $ranges[3];
1599
-				$tmp = $base . '.part';
1599
+				$tmp = $base.'.part';
1600 1600
 				$csize = filesize($tmpname);
1601 1601
 				
1602 1602
 				$tmpExists = is_file($tmp);
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
 				} else {
1623 1623
 					// wait until makeing temp file (for anothor session)
1624 1624
 					$cnt = 1200; // Time limit 120 sec
1625
-					while(!is_file($base) && --$cnt) {
1625
+					while (!is_file($base) && --$cnt) {
1626 1626
 						usleep(100000); // wait 100ms
1627 1627
 					}
1628 1628
 					if (!$cnt) {
@@ -1657,13 +1657,13 @@  discard block
 block discarded – undo
1657 1657
 				}
1658 1658
 			} else {
1659 1659
 				// old way
1660
-				$part = $base . $m[2];
1660
+				$part = $base.$m[2];
1661 1661
 				if (move_uploaded_file($tmpname, $part)) {
1662 1662
 					@chmod($part, 0600);
1663
-					if ($clast < count(glob($base . '*'))) {
1663
+					if ($clast < count(glob($base.'*'))) {
1664 1664
 						$parts = array();
1665 1665
 						for ($i = 0; $i <= $clast; $i++) {
1666
-							$name = $base . '.' . $i . '_' . $clast;
1666
+							$name = $base.'.'.$i.'_'.$clast;
1667 1667
 							if (is_readable($name)) {
1668 1668
 								$parts[] = $name;
1669 1669
 							} else {
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
 								touch($base);
1677 1677
 								if ($resfile = tempnam($tempDir, 'ELF')) {
1678 1678
 									$target = fopen($resfile, 'wb');
1679
-									foreach($parts as $f) {
1679
+									foreach ($parts as $f) {
1680 1680
 										$fp = fopen($f, 'rb');
1681 1681
 										while (!feof($fp)) {
1682 1682
 											fwrite($target, fread($fp, 8192));
@@ -1712,15 +1712,15 @@  discard block
 block discarded – undo
1712 1712
 		$files  = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array();
1713 1713
 		$header = empty($args['html']) ? array() : array('header' => 'Content-Type: text/html; charset=utf-8');
1714 1714
 		$result = array_merge(array('added' => array()), $header);
1715
-		$paths  = $args['upload_path']? $args['upload_path'] : array();
1716
-		$chunk  = $args['chunk']? $args['chunk'] : '';
1717
-		$cid    = $args['cid']? (int)$args['cid'] : '';
1715
+		$paths  = $args['upload_path'] ? $args['upload_path'] : array();
1716
+		$chunk  = $args['chunk'] ? $args['chunk'] : '';
1717
+		$cid    = $args['cid'] ? (int) $args['cid'] : '';
1718 1718
 		
1719
-		$renames= array();
1719
+		$renames = array();
1720 1720
 		$suffix = '~';
1721 1721
 		if ($args['renames'] && is_array($args['renames'])) {
1722 1722
 			$renames = array_flip($args['renames']);
1723
-			if (is_string($args['suffix']) && ! preg_match($ngReg, $args['suffix'])) {
1723
+			if (is_string($args['suffix']) && !preg_match($ngReg, $args['suffix'])) {
1724 1724
 				$suffix = $args['suffix'];
1725 1725
 			}
1726 1726
 		}
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 			if (!$args['upload'] && $args['name'] && is_array($args['name'])) {
1754 1754
 				$error = '';
1755 1755
 				$result['name'] = array();
1756
-				foreach($args['name'] as $_i => $_name) {
1756
+				foreach ($args['name'] as $_i => $_name) {
1757 1757
 					if (!$volume->isUploadableByName($_name)) {
1758 1758
 						$error = $this->error(self::ERROR_UPLOAD_FILE, $_name, self::ERROR_UPLOAD_FILE_MIME);
1759 1759
 						break;
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 			}
1775 1775
 			if (isset($args['upload']) && is_array($args['upload']) && ($tempDir = $this->getTempDir($volume->getTempPath()))) {
1776 1776
 				$names = array();
1777
-				foreach($args['upload'] as $i => $url) {
1777
+				foreach ($args['upload'] as $i => $url) {
1778 1778
 					// check chunked file upload commit
1779 1779
 					if ($args['chunk']) {
1780 1780
 						if ($url === 'chunkfail' && $args['mimes'] === 'chunkfail') {
@@ -1784,7 +1784,7 @@  discard block
 block discarded – undo
1784 1784
 							}
1785 1785
 							return $result;
1786 1786
 						} else {
1787
-							$tmpfname = $tempDir . '/' . $args['chunk'];
1787
+							$tmpfname = $tempDir.'/'.$args['chunk'];
1788 1788
 							$files['tmp_name'][$i] = $tmpfname;
1789 1789
 							$files['name'][$i] = $url;
1790 1790
 							$files['error'][$i] = 0;
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
 						}
1794 1794
 					}
1795 1795
 					
1796
-					$tmpfname = $tempDir . DIRECTORY_SEPARATOR . 'ELF_FATCH_' . md5($url.microtime(true));
1796
+					$tmpfname = $tempDir.DIRECTORY_SEPARATOR.'ELF_FATCH_'.md5($url.microtime(true));
1797 1797
 					
1798 1798
 					$_name = '';
1799 1799
 					// check is data:
@@ -1829,8 +1829,8 @@  discard block
 block discarded – undo
1829 1829
 								list($_a, $_b) = array_pad(explode('.', $_name, 2), 2, '');
1830 1830
 								if ($_b === '') {
1831 1831
 									if ($_ext) {
1832
-										rename($tmpfname, $tmpfname . $_ext);
1833
-										$tmpfname = $tmpfname . $_ext;
1832
+										rename($tmpfname, $tmpfname.$_ext);
1833
+										$tmpfname = $tmpfname.$_ext;
1834 1834
 									}
1835 1835
 									$_b = $this->detectFileExtension($tmpfname);
1836 1836
 									$_name = $_a.$_b;
@@ -1865,7 +1865,7 @@  discard block
 block discarded – undo
1865 1865
 			}
1866 1866
 			
1867 1867
 			$tmpname = $files['tmp_name'][$i];
1868
-			$path = ($paths && !empty($paths[$i]))? $paths[$i] : '';
1868
+			$path = ($paths && !empty($paths[$i])) ? $paths[$i] : '';
1869 1869
 			if ($name === 'blob') {
1870 1870
 				if ($chunk) {
1871 1871
 					if ($tempDir = $this->getTempDir($volume->getTempPath())) {
@@ -1875,7 +1875,7 @@  discard block
 block discarded – undo
1875 1875
 								preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m);
1876 1876
 								$result['error'] = $this->error(self::ERROR_UPLOAD_FILE, $m[1], $tmpname);
1877 1877
 								$result['_chunkfailure'] = true;
1878
-								$this->uploadDebug = 'Upload error: ' . $tmpname;
1878
+								$this->uploadDebug = 'Upload error: '.$tmpname;
1879 1879
 							} else if ($name) {
1880 1880
 								$result['_chunkmerged'] = basename($tmpname);
1881 1881
 								$result['_name'] = $name;
@@ -1889,14 +1889,14 @@  discard block
 block discarded – undo
1889 1889
 				} else {
1890 1890
 					// for form clipboard with Google Chrome
1891 1891
 					$type = $files['type'][$i];
1892
-					$ext = isset($extTable[$type])? '.' . $extTable[$type] : '';
1893
-					$name = substr(md5(basename($tmpname)), 0, 8) . $ext;
1892
+					$ext = isset($extTable[$type]) ? '.'.$extTable[$type] : '';
1893
+					$name = substr(md5(basename($tmpname)), 0, 8).$ext;
1894 1894
 				}
1895 1895
 			}
1896 1896
 			
1897 1897
 			// do hook function 'upload.presave'
1898
-			if (! empty($this->listeners['upload.presave'])) {
1899
-				foreach($this->listeners['upload.presave'] as $handler) {
1898
+			if (!empty($this->listeners['upload.presave'])) {
1899
+				foreach ($this->listeners['upload.presave'] as $handler) {
1900 1900
 					call_user_func_array($handler, array(&$path, &$name, $tmpname, $this, $volume));
1901 1901
 				}
1902 1902
 			}
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
 			if (($fp = fopen($tmpname, 'rb')) == false) {
1905 1905
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER);
1906 1906
 				$this->uploadDebug = 'Upload error: unable open tmp file';
1907
-				if (! is_uploaded_file($tmpname)) {
1907
+				if (!is_uploaded_file($tmpname)) {
1908 1908
 					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]);
1909 1909
 					continue;
1910 1910
 				}
@@ -1926,18 +1926,18 @@  discard block
 block discarded – undo
1926 1926
 					}
1927 1927
 				}
1928 1928
 			}
1929
-			if (! $_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1929
+			if (!$_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1930 1930
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error());
1931 1931
 				fclose($fp);
1932
-				if (! is_uploaded_file($tmpname)) {
1933
-					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);;
1932
+				if (!is_uploaded_file($tmpname)) {
1933
+					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]); ;
1934 1934
 					continue;
1935 1935
 				}
1936 1936
 				break;
1937 1937
 			}
1938 1938
 			
1939 1939
 			is_resource($fp) && fclose($fp);
1940
-			if (! is_uploaded_file($tmpname)){
1940
+			if (!is_uploaded_file($tmpname)) {
1941 1941
 				clearstatcache();
1942 1942
 				if (!is_file($tmpname) || @ unlink($tmpname)) {
1943 1943
 					unset($GLOBALS['elFinderTempFiles'][$tmpname]);
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
 			}
1950 1950
 		}
1951 1951
 		if ($GLOBALS['elFinderTempFiles']) {
1952
-			foreach(array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1952
+			foreach (array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1953 1953
 				@ unlink($_temp);
1954 1954
 			}
1955 1955
 		}
@@ -1986,7 +1986,7 @@  discard block
 block discarded – undo
1986 1986
 		$suffix = '~';
1987 1987
 		if (!empty($args['renames'])) {
1988 1988
 			$renames = array_flip($args['renames']);
1989
-			if (is_string($args['suffix']) && ! preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1989
+			if (is_string($args['suffix']) && !preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1990 1990
 				$suffix = $args['suffix'];
1991 1991
 			}
1992 1992
 		}
@@ -2044,9 +2044,9 @@  discard block
 block discarded – undo
2044 2044
 		}
2045 2045
 		
2046 2046
 		if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
2047
-			$mime = isset($file['mime'])? $file['mime'] : '';
2047
+			$mime = isset($file['mime']) ? $file['mime'] : '';
2048 2048
 			if ($mime && strtolower(substr($mime, 0, 4)) === 'text') {
2049
-				if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) {
2049
+				if ($enc = mb_detect_encoding($content, mb_detect_order(), true)) {
2050 2050
 					if (strtolower($enc) !== 'utf-8') {
2051 2051
 						$content = mb_convert_encoding($content, 'UTF-8', $enc);
2052 2052
 					}
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
 
2059 2059
 		if ($json === false || strlen($json) < strlen($content)) {
2060 2060
 			if ($args['conv']) {
2061
-				return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
2061
+				return array('error' => $this->error(self::ERROR_CONV_UTF8, self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
2062 2062
 			} else {
2063 2063
 				return array('doconv' => true);
2064 2064
 			}
@@ -2100,7 +2100,7 @@  discard block
 block discarded – undo
2100 2100
 		$target = $args['target'];
2101 2101
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2102 2102
 		$error  = array(self::ERROR_EXTRACT, '#'.$target);
2103
-		$makedir = isset($args['makedir'])? (bool)$args['makedir'] : null;
2103
+		$makedir = isset($args['makedir']) ? (bool) $args['makedir'] : null;
2104 2104
 
2105 2105
 		if (($volume = $this->volume($target)) == false
2106 2106
 		|| ($file = $volume->file($target)) == false) {
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
 		}  
2109 2109
 
2110 2110
 		return ($file = $volume->extract($target, $makedir))
2111
-			? array('added' => isset($file['read'])? array($file) : $file)
2111
+			? array('added' => isset($file['read']) ? array($file) : $file)
2112 2112
 			: array('error' => $this->error(self::ERROR_EXTRACT, $volume->path($target), $volume->error()));
2113 2113
 	}
2114 2114
 	
@@ -2123,7 +2123,7 @@  discard block
 block discarded – undo
2123 2123
 	protected function archive($args) {
2124 2124
 		$type    = $args['type'];
2125 2125
 		$targets = isset($args['targets']) && is_array($args['targets']) ? $args['targets'] : array();
2126
-		$name    = isset($args['name'])? $args['name'] : '';
2126
+		$name    = isset($args['name']) ? $args['name'] : '';
2127 2127
 	
2128 2128
 		if (($volume = $this->volume($targets[0])) == false) {
2129 2129
 			return $this->error(self::ERROR_ARCHIVE, self::ERROR_TRGDIR_NOT_FOUND);
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
 	protected function search($args) {
2145 2145
 		$q      = trim($args['q']);
2146 2146
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2147
-		$target = !empty($args['target'])? $args['target'] : null;
2147
+		$target = !empty($args['target']) ? $args['target'] : null;
2148 2148
 		$result = array();
2149 2149
 		$errors = array();
2150 2150
 
@@ -2183,7 +2183,7 @@  discard block
 block discarded – undo
2183 2183
 			$compare = intval($args['compare']);
2184 2184
 			$hash = $args['targets'][0];
2185 2185
 			if ($volume = $this->volume($hash)) {
2186
-				$standby = (int)$volume->getOption('plStandby');
2186
+				$standby = (int) $volume->getOption('plStandby');
2187 2187
 				$_compare = false;
2188 2188
 				if (($syncCheckFunc = $volume->getOption('syncCheckFunc')) && is_callable($syncCheckFunc)) {
2189 2189
 					$_compare = call_user_func_array($syncCheckFunc, array($volume->realpath($hash), $standby, $compare, $volume, $this));
@@ -2191,8 +2191,8 @@  discard block
 block discarded – undo
2191 2191
 				if ($_compare !== false) {
2192 2192
 					$compare = $_compare;
2193 2193
 				} else {
2194
-					$sleep = max(1, (int)$volume->getOption('tsPlSleep'));
2195
-					$limit = max(1, $standby / $sleep) + 1;
2194
+					$sleep = max(1, (int) $volume->getOption('tsPlSleep'));
2195
+					$limit = max(1, $standby/$sleep) + 1;
2196 2196
 					$timelimit = ini_get('max_execution_time');
2197 2197
 					do {
2198 2198
 						$timelimit && @ set_time_limit($timelimit + $sleep);
@@ -2209,7 +2209,7 @@  discard block
 block discarded – undo
2209 2209
 						if (--$limit) {
2210 2210
 							sleep($sleep);
2211 2211
 						}
2212
-					} while($limit);
2212
+					} while ($limit);
2213 2213
 				}
2214 2214
 			}
2215 2215
 		} else {
@@ -2257,12 +2257,12 @@  discard block
 block discarded – undo
2257 2257
 		$target = $args['target'];
2258 2258
 		$width  = $args['width'];
2259 2259
 		$height = $args['height'];
2260
-		$x      = (int)$args['x'];
2261
-		$y      = (int)$args['y'];
2260
+		$x      = (int) $args['x'];
2261
+		$y      = (int) $args['y'];
2262 2262
 		$mode   = $args['mode'];
2263 2263
 		$bg     = null;
2264
-		$degree = (int)$args['degree'];
2265
-		$quality= (int)$args['quality'];
2264
+		$degree = (int) $args['degree'];
2265
+		$quality = (int) $args['quality'];
2266 2266
 		
2267 2267
 		if (($volume = $this->volume($target)) == false
2268 2268
 		|| ($file = $volume->file($target)) == false) {
@@ -2283,7 +2283,7 @@  discard block
 block discarded – undo
2283 2283
 	**/
2284 2284
 	protected function url($args) {
2285 2285
 		$target = $args['target'];
2286
-		$options = isset($args['options'])? $args['options'] : array();
2286
+		$options = isset($args['options']) ? $args['options'] : array();
2287 2287
 		if (($volume = $this->volume($target)) != false) {
2288 2288
 			$url = $volume->getContentUrl($target, $options);
2289 2289
 			return $url ? array('url' => $url) : array();
@@ -2300,18 +2300,18 @@  discard block
 block discarded – undo
2300 2300
 	 */
2301 2301
 	protected function callback($args) {
2302 2302
 		$checkReg = '/[^a-zA-Z0-9;._-]/';
2303
-		$node = (isset($args['node']) && !preg_match($checkReg, $args['node']))? $args['node'] : '';
2304
-		$json = (isset($args['json']) && @json_decode($args['json']))? $args['json'] : '{}';
2305
-		$bind  = (isset($args['bind']) && !preg_match($checkReg, $args['bind']))? $args['bind'] : '';
2303
+		$node = (isset($args['node']) && !preg_match($checkReg, $args['node'])) ? $args['node'] : '';
2304
+		$json = (isset($args['json']) && @json_decode($args['json'])) ? $args['json'] : '{}';
2305
+		$bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind'])) ? $args['bind'] : '';
2306 2306
 		$done = (!empty($args['done']));
2307 2307
 		
2308
-		while( ob_get_level() ) {
2309
-			if (! ob_end_clean()) {
2308
+		while (ob_get_level()) {
2309
+			if (!ob_end_clean()) {
2310 2310
 				break;
2311 2311
 			}
2312 2312
 		}
2313 2313
 		
2314
-		if ($done || ! $this->callbackWindowURL) {
2314
+		if ($done || !$this->callbackWindowURL) {
2315 2315
 			$script = '';
2316 2316
 			if ($node) {
2317 2317
 				$script .= '
@@ -2353,13 +2353,13 @@  discard block
 block discarded – undo
2353 2353
 			
2354 2354
 		} else {
2355 2355
 			$url = $this->callbackWindowURL;
2356
-			$url .= ((strpos($url, '?') === false)? '?' : '&')
2357
-				 . '&node=' . rawurlencode($node)
2358
-				 . (($json !== '{}')? ('&json=' . rawurlencode($json)) : '')
2359
-				 . ($bind? ('&bind=' .  rawurlencode($bind)) : '')
2356
+			$url .= ((strpos($url, '?') === false) ? '?' : '&')
2357
+				 . '&node='.rawurlencode($node)
2358
+				 . (($json !== '{}') ? ('&json='.rawurlencode($json)) : '')
2359
+				 . ($bind ? ('&bind='.rawurlencode($bind)) : '')
2360 2360
 				 . '&done=1';
2361 2361
 			
2362
-			header('Location: ' . $url);
2362
+			header('Location: '.$url);
2363 2363
 			
2364 2364
 		}
2365 2365
 		exit();
@@ -2429,7 +2429,7 @@  discard block
 block discarded – undo
2429 2429
 	
2430 2430
 	protected function utime() {
2431 2431
 		$time = explode(" ", microtime());
2432
-		return (double)$time[1] + (double)$time[0];
2432
+		return (double) $time[1] + (double) $time[0];
2433 2433
 	}
2434 2434
 	
2435 2435
 	
@@ -2455,7 +2455,7 @@  discard block
 block discarded – undo
2455 2455
 		$imgcnt = 0;
2456 2456
 		$fp = fopen($path, 'rb');
2457 2457
 		@fread($fp, 4);
2458
-		$c = @fread($fp,1);
2458
+		$c = @fread($fp, 1);
2459 2459
 		if (ord($c) != 0x39) {  // GIF89a
2460 2460
 			return false;
2461 2461
 		}
@@ -2463,13 +2463,13 @@  discard block
 block discarded – undo
2463 2463
 		while (!feof($fp)) {
2464 2464
 			do {
2465 2465
 				$c = fread($fp, 1);
2466
-			} while(ord($c) != 0x21 && !feof($fp));
2466
+			} while (ord($c) != 0x21 && !feof($fp));
2467 2467
 	
2468 2468
 			if (feof($fp)) {
2469 2469
 				break;
2470 2470
 			}
2471 2471
 	
2472
-			$c2 = fread($fp,2);
2472
+			$c2 = fread($fp, 2);
2473 2473
 			if (bin2hex($c2) == "f904") {
2474 2474
 				$imgcnt++;
2475 2475
 			}
Please login to merge, or discard this patch.
php/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   +68 added lines, -69 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		
139 139
 		if ($options['user'] === 'init') {
140 140
 
141
-			if (! $this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) {
141
+			if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) {
142 142
 				return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}');
143 143
 			}
144 144
 			
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 				if (class_exists('OAuth', false)) {
149 149
 					$this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']);
150 150
 				} else {
151
-					if (! class_exists('HTTP_OAuth_Consumer', false)) {
151
+					if (!class_exists('HTTP_OAuth_Consumer', false)) {
152 152
 						// We're going to try to load in manually
153 153
 						include 'HTTP/OAuth/Consumer.php';
154 154
 					}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 				}
159 159
 			}
160 160
 			
161
-			if (! $this->oauth) {
161
+			if (!$this->oauth) {
162 162
 				return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}');
163 163
 			}
164 164
 
@@ -179,25 +179,25 @@  discard block
 block discarded – undo
179 179
 						unset($_SESSION['elFinderDropboxTokens']);
180 180
 					}
181 181
 				}
182
-				if (! $html) {
182
+				if (!$html) {
183 183
 					// get customdata
184 184
 					$cdata = '';
185 185
 					$innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user');
186
-					$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET;
187
-					foreach($this->ARGS as $k => $v) {
188
-						if (! in_array($k, $innerKeys)) {
189
-							$cdata .= '&' . $k . '=' . rawurlencode($v);
186
+					$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
187
+					foreach ($this->ARGS as $k => $v) {
188
+						if (!in_array($k, $innerKeys)) {
189
+							$cdata .= '&'.$k.'='.rawurlencode($v);
190 190
 						}
191 191
 					}
192
-					if (strpos($options['url'], 'http') !== 0 ) {
192
+					if (strpos($options['url'], 'http') !== 0) {
193 193
 						$options['url'] = $this->getConnectorUrl();
194 194
 					}
195
-					$callback  = $options['url']
195
+					$callback = $options['url']
196 196
 					           . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata;
197 197
 					
198 198
 					try {
199 199
 						$tokens = $this->oauth->getRequestToken();
200
-						$url= $this->oauth->getAuthorizeUrl(rawurlencode($callback));
200
+						$url = $this->oauth->getAuthorizeUrl(rawurlencode($callback));
201 201
 					} catch (Dropbox_Exception $e) {
202 202
 						return array('exit' => true, 'body' => '{msg:errAccess}');
203 203
 					}
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 		if (isset($netVolumes[$key])) {
245 245
 			$dropboxUid = $netVolumes[$key]['dropboxUid'];
246 246
 		}
247
-		foreach($netVolumes as $volume) {
247
+		foreach ($netVolumes as $volume) {
248 248
 			if (@$volume['host'] === 'dropbox' && @$volume['dropboxUid'] === $dropboxUid) {
249 249
 				$count++;
250 250
 			}
251 251
 		}
252 252
 		if ($count === 1) {
253 253
 			$this->DB->exec('drop table '.$this->DB_TableName);
254
-			foreach(glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) {
254
+			foreach (glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) {
255 255
 				unlink($tmb);
256 256
 			}
257 257
 		}
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 	 * @author Naoki Sawada
266 266
 	 */
267 267
 	private function getConnectorUrl() {
268
-		$url  = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://')
268
+		$url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://')
269 269
 		       . $_SERVER['SERVER_NAME']                                              // host
270
-		      . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT'])  // port
271
-		       . $_SERVER['REQUEST_URI'];                                             // path & query
270
+		      . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT'])  // port
271
+		       . $_SERVER['REQUEST_URI']; // path & query
272 272
 		list($url) = explode('?', $url);
273 273
 		return $url;
274 274
 	}
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
 		// make net mount key
305 305
 		$this->netMountKey = md5(join('-', array('dropbox', $this->options['path'])));
306 306
 
307
-		if (! $this->oauth) {
307
+		if (!$this->oauth) {
308 308
 			if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) {
309 309
 				$this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']);
310 310
 			} else {
311 311
 				if (class_exists('OAuth', false)) {
312 312
 					$this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']);
313 313
 				} else {
314
-					if (! class_exists('HTTP_OAuth_Consumer', false)) {
314
+					if (!class_exists('HTTP_OAuth_Consumer', false)) {
315 315
 						// We're going to try to load in manually
316 316
 						include 'HTTP/OAuth/Consumer.php';
317 317
 					}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			}
323 323
 		}
324 324
 		
325
-		if (! $this->oauth) {
325
+		if (!$this->oauth) {
326 326
 			return $this->setError('OAuth extension not loaded.');
327 327
 		}
328 328
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 		$this->root = $this->options['path'] = $this->_normpath($this->options['path']);
331 331
 
332 332
 		if (empty($this->options['alias'])) {
333
-			$this->options['alias'] = ($this->options['path'] === '/')? 'Dropbox.com'  : 'Dropbox'.$this->options['path'];
333
+			$this->options['alias'] = ($this->options['path'] === '/') ? 'Dropbox.com' : 'Dropbox'.$this->options['path'];
334 334
 		}
335 335
 
336 336
 		$this->rootName = $this->options['alias'];
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 		}
386 386
 		
387 387
 		// setup PDO
388
-		if (! $this->options['PDO_DSN']) {
388
+		if (!$this->options['PDO_DSN']) {
389 389
 			$this->options['PDO_DSN'] = 'sqlite:'.$this->metaCache.DIRECTORY_SEPARATOR.'.elFinder_dropbox_db_'.md5($this->dropboxUid.$this->options['consumerSecret']);
390 390
 		}
391 391
 		// DataBase table name
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 		// DataBase check or make table
394 394
 		try {
395 395
 			$this->DB = new PDO($this->options['PDO_DSN'], $this->options['PDO_User'], $this->options['PDO_Pass'], $this->options['PDO_Options']);
396
-			if (! $this->checkDB()) {
396
+			if (!$this->checkDB()) {
397 397
 				return $this->setError('Can not make DB table');
398 398
 			}
399 399
 		} catch (PDOException $e) {
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 				$res = false;
456 456
 			}
457 457
 		}
458
-		if (! $res) {
458
+		if (!$res) {
459 459
 			try {
460 460
 				$this->DB->exec('CREATE TABLE '.$this->DB_TableName.'(path text, fname text, dat blob, isdir integer);');
461 461
 				$this->DB->exec('CREATE UNIQUE INDEX nameidx ON '.$this->DB_TableName.'(path, fname)');
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 	 */
506 506
 	private function updateDBdat($path, $dat) {
507 507
 		return $this->query('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($dat))
508
-				. ', isdir=' . ($dat['is_dir']? 1 : 0)
508
+				. ', isdir='.($dat['is_dir'] ? 1 : 0)
509 509
 				. ' where path='.$this->DB->quote(strtolower($this->_dirname($path))).' and fname='.$this->DB->quote(strtolower(basename($path))));
510 510
 	}
511 511
 	/*********************************************************************/
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 	 */
531 531
 	protected function deltaCheck($refresh = true) {
532 532
 		$chk = false;
533
-		if (! $refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) {
533
+		if (!$refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) {
534 534
 			$chk = unserialize($chk[0]);
535 535
 		}
536 536
 		if ($chk && ($chk['mtime'] + $this->options['metaCacheTime']) > $_SERVER['REQUEST_TIME']) {
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 			do {
555 555
 				@ ini_set('max_execution_time', 120);
556 556
 				$_info = $this->dropbox->delta($cursor);
557
-				if (! empty($_info['reset'])) {
557
+				if (!empty($_info['reset'])) {
558 558
 					$this->DB->exec('TRUNCATE table '.$this->DB_TableName);
559 559
 					$this->DB->exec('insert into '.$this->DB_TableName.' values(\'\', \'\', \''.serialize(array('cursor' => '', 'mtime' => 0)).'\', 0);');
560 560
 					$this->DB->exec('insert into '.$this->DB_TableName.' values(\'/\', \'\', \''.serialize(array(
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 				}
568 568
 				$cursor = $_info['cursor'];
569 569
 				
570
-				foreach($_info['entries'] as $entry) {
570
+				foreach ($_info['entries'] as $entry) {
571 571
 					$key = strtolower($entry[0]);
572 572
 					$pkey = strtolower($this->_dirname($key));
573 573
 					
@@ -576,22 +576,22 @@  discard block
 block discarded – undo
576 576
 					$where = 'where path='.$path.' and fname='.$fname;
577 577
 					
578 578
 					if (empty($entry[1])) {
579
-						$ptimes[$pkey] = isset($ptimes[$pkey])? max(array($now, $ptimes[$pkey])) : $now;
579
+						$ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($now, $ptimes[$pkey])) : $now;
580 580
 						$this->DB->exec('delete from '.$this->DB_TableName.' '.$where);
581
-						! $delete && $delete = true;
581
+						!$delete && $delete = true;
582 582
 						continue;
583 583
 					}
584 584
 
585
-					$_itemTime = strtotime(isset($entry[1]['client_mtime'])? $entry[1]['client_mtime'] : $entry[1]['modified']);
586
-					$ptimes[$pkey] = isset($ptimes[$pkey])? max(array($_itemTime, $ptimes[$pkey])) : $_itemTime;
585
+					$_itemTime = strtotime(isset($entry[1]['client_mtime']) ? $entry[1]['client_mtime'] : $entry[1]['modified']);
586
+					$ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($_itemTime, $ptimes[$pkey])) : $_itemTime;
587 587
 					$sql = 'select path from '.$this->DB_TableName.' '.$where.' limit 1';
588
-					if (! $reset && $this->query($sql)) {
589
-						$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir']? 1 : 0).' ' .$where);
588
+					if (!$reset && $this->query($sql)) {
589
+						$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir'] ? 1 : 0).' '.$where);
590 590
 					} else {
591
-						$this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int)$entry[1]['is_dir'].')');
591
+						$this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int) $entry[1]['is_dir'].')');
592 592
 					}
593 593
 				}
594
-			} while (! empty($_info['has_more']));
594
+			} while (!empty($_info['has_more']));
595 595
 			
596 596
 			// update time stamp of parent holder
597 597
 			foreach ($ptimes as $_p => $_t) {
@@ -613,14 +613,14 @@  discard block
 block discarded – undo
613 613
 			}
614 614
 			
615 615
 			$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize(array('cursor'=>$cursor, 'mtime'=>$_SERVER['REQUEST_TIME']))).' where path=\'\' and fname=\'\'');
616
-			if (! $this->DB->commit()) {
616
+			if (!$this->DB->commit()) {
617 617
 				$e = $this->DB->errorInfo();
618 618
 				return $e[2];
619 619
 			}
620 620
 			if ($delete) {
621 621
 				$this->DB->exec('vacuum');
622 622
 			}
623
-		} catch(Dropbox_Exception $e) {
623
+		} catch (Dropbox_Exception $e) {
624 624
 			return $e->getMessage();
625 625
 		}
626 626
 		return true;
@@ -636,15 +636,14 @@  discard block
 block discarded – undo
636 636
 	protected function parseRaw($raw) {
637 637
 		$stat = array();
638 638
 
639
-		$stat['rev']   = isset($raw['rev'])? $raw['rev'] : 'root';
639
+		$stat['rev']   = isset($raw['rev']) ? $raw['rev'] : 'root';
640 640
 		$stat['name']  = basename($raw['path']);
641
-		$stat['mime']  = $raw['is_dir']? 'directory' : $raw['mime_type'];
641
+		$stat['mime']  = $raw['is_dir'] ? 'directory' : $raw['mime_type'];
642 642
 		$stat['size']  = $stat['mime'] == 'directory' ? 0 : $raw['bytes'];
643
-		$stat['ts']    = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) :
644
-		                (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']);
643
+		$stat['ts']    = isset($raw['client_mtime']) ? strtotime($raw['client_mtime']) : (isset($raw['modified']) ? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']);
645 644
 		$stat['dirs'] = 0;
646 645
 		if ($raw['is_dir']) {
647
-			$stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path'])));
646
+			$stat['dirs'] = (int) (bool) $this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path'])));
648 647
 		}
649 648
 		
650 649
 		if (!empty($raw['url'])) {
@@ -670,7 +669,7 @@  discard block
 block discarded – undo
670 669
 		$res = $this->query('select dat from '.$this->DB_TableName.' where path='.$this->DB->quote(strtolower($path)));
671 670
 		
672 671
 		if ($res) {
673
-			foreach($res as $raw) {
672
+			foreach ($res as $raw) {
674 673
 				$raw = unserialize($raw);
675 674
 				if ($stat = $this->parseRaw($raw)) {
676 675
 					$stat = $this->updateCache($raw['path'], $stat);
@@ -695,12 +694,12 @@  discard block
 block discarded – undo
695 694
 	protected function doSearch($path, $q, $mimes) {
696 695
 		$result = array();
697 696
 		$sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?');
698
-		$sth->execute(array((($path === '/')? '' : strtolower($path)).'%', '%'.strtolower($q).'%'));
697
+		$sth->execute(array((($path === '/') ? '' : strtolower($path)).'%', '%'.strtolower($q).'%'));
699 698
 		$res = $sth->fetchAll(PDO::FETCH_COLUMN);
700
-		$timeout = $this->options['searchTimeout']? $this->searchStart + $this->options['searchTimeout'] : 0;
699
+		$timeout = $this->options['searchTimeout'] ? $this->searchStart + $this->options['searchTimeout'] : 0;
701 700
 		
702 701
 		if ($res) {
703
-			foreach($res as $raw) {
702
+			foreach ($res as $raw) {
704 703
 				if ($timeout && $timeout < time()) {
705 704
 					$this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode($path)));
706 705
 					break;
@@ -798,10 +797,10 @@  discard block
 block discarded – undo
798 797
 		$tmb  = $this->tmbPath.DIRECTORY_SEPARATOR.$name;
799 798
 	
800 799
 		// copy image into tmbPath so some drivers does not store files on local fs
801
-		if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) {
800
+		if (!$data = $this->getThumbnail($path, $this->options['getTmbSize'])) {
802 801
 			return false;
803 802
 		}
804
-		if (! file_put_contents($tmb, $data)) {
803
+		if (!file_put_contents($tmb, $data)) {
805 804
 			return false;
806 805
 		}
807 806
 	
@@ -814,15 +813,15 @@  discard block
 block discarded – undo
814 813
 		}
815 814
 	
816 815
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
817
-		if ($s[0] <= $tmbSize && $s[1]  <= $tmbSize) {
818
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
816
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
817
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
819 818
 	
820 819
 		} else {
821 820
 	
822 821
 			if ($this->options['tmbCrop']) {
823 822
 	
824 823
 				/* Resize and crop if image bigger than thumbnail */
825
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
824
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
826 825
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
827 826
 				}
828 827
 	
@@ -836,7 +835,7 @@  discard block
 block discarded – undo
836 835
 				$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png');
837 836
 			}
838 837
 		
839
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
838
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
840 839
 		}
841 840
 		
842 841
 		if (!$result) {
@@ -893,7 +892,7 @@  discard block
 block discarded – undo
893 892
 					}
894 893
 				}
895 894
 			}
896
-			if (! $url) {
895
+			if (!$url) {
897 896
 				try {
898 897
 					$res = $this->dropbox->share($path, null, false);
899 898
 					$url = $res['url'];
@@ -905,7 +904,7 @@  discard block
 block discarded – undo
905 904
 					}
906 905
 					list($url) = explode('?', $url);
907 906
 					$url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url);
908
-					if (! isset($cache['share']) || $cache['share'] !== $url) {
907
+					if (!isset($cache['share']) || $cache['share'] !== $url) {
909 908
 						$cache['share'] = $url;
910 909
 						$this->updateDBdat($path, $cache);
911 910
 					}
@@ -929,12 +928,12 @@  discard block
 block discarded – undo
929 928
 		if (function_exists('curl_exec')) {
930 929
 
931 930
 			$c = curl_init();
932
-			curl_setopt( $c, CURLOPT_RETURNTRANSFER, true );
933
-			curl_setopt( $c, CURLOPT_CUSTOMREQUEST, 'HEAD' );
934
-			curl_setopt( $c, CURLOPT_HEADER, 1 );
935
-			curl_setopt( $c, CURLOPT_NOBODY, true );
936
-			curl_setopt( $c, CURLOPT_URL, $url );
937
-			$res = curl_exec( $c );
931
+			curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
932
+			curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD');
933
+			curl_setopt($c, CURLOPT_HEADER, 1);
934
+			curl_setopt($c, CURLOPT_NOBODY, true);
935
+			curl_setopt($c, CURLOPT_URL, $url);
936
+			$res = curl_exec($c);
938 937
 			
939 938
 		} else {
940 939
 			
@@ -950,13 +949,13 @@  discard block
 block discarded – undo
950 949
 				$result = $request2->send();
951 950
 				$res = array();
952 951
 				$res[] = 'HTTP/'.$result->getVersion().' '.$result->getStatus().' '.$result->getReasonPhrase();
953
-				foreach($result->getHeader() as $key => $val) {
954
-					$res[] = $key . ': ' . $val;
952
+				foreach ($result->getHeader() as $key => $val) {
953
+					$res[] = $key.': '.$val;
955 954
 				}
956 955
 				$res = join("\r\n", $res);
957
-			} catch( HTTP_Request2_Exception $e ){
956
+			} catch (HTTP_Request2_Exception $e) {
958 957
 				$res = '';
959
-			} catch (Exception $e){
958
+			} catch (Exception $e) {
960 959
 				$res = '';
961 960
 			}
962 961
 		
@@ -1008,7 +1007,7 @@  discard block
 block discarded – undo
1008 1007
 	 * @author Troex Nevelin
1009 1008
 	 **/
1010 1009
 	protected function _normpath($path) {
1011
-		$path = '/' . ltrim($path, '/');
1010
+		$path = '/'.ltrim($path, '/');
1012 1011
 		return $path;
1013 1012
 	}
1014 1013
 
@@ -1042,7 +1041,7 @@  discard block
 block discarded – undo
1042 1041
 	 * @author Dmitry (dio) Levashov
1043 1042
 	 **/
1044 1043
 	protected function _path($path) {
1045
-		return $this->rootName . $this->_normpath(substr($path, strlen($this->root)));
1044
+		return $this->rootName.$this->_normpath(substr($path, strlen($this->root)));
1046 1045
 	}
1047 1046
 
1048 1047
 	/**
@@ -1151,7 +1150,7 @@  discard block
 block discarded – undo
1151 1150
 	 * @return resource|false
1152 1151
 	 * @author Dmitry (dio) Levashov
1153 1152
 	 **/
1154
-	protected function _fopen($path, $mode='rb') {
1153
+	protected function _fopen($path, $mode = 'rb') {
1155 1154
 
1156 1155
 		if (($mode == 'rb' || $mode == 'r')) {
1157 1156
 			try {
@@ -1161,7 +1160,7 @@  discard block
 block discarded – undo
1161 1160
  				fputs($fp, "GET {$url['path']} HTTP/1.0\r\n");
1162 1161
  				fputs($fp, "Host: {$url['host']}\r\n");
1163 1162
  				fputs($fp, "\r\n");
1164
- 				while(trim(fgets($fp)) !== ''){};
1163
+ 				while (trim(fgets($fp)) !== '') {};
1165 1164
  				return $fp;
1166 1165
 			} catch (Dropbox_Exception $e) {
1167 1166
 				return false;
@@ -1192,7 +1191,7 @@  discard block
 block discarded – undo
1192 1191
 	 * @return bool
1193 1192
 	 * @author Dmitry (dio) Levashov
1194 1193
 	 **/
1195
-	protected function _fclose($fp, $path='') {
1194
+	protected function _fclose($fp, $path = '') {
1196 1195
 		@fclose($fp);
1197 1196
 		if ($path) {
1198 1197
 			@unlink($this->getTempFile($path));
Please login to merge, or discard this patch.
php/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   +53 added lines, -53 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
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
 		if ($this->encoding) {
240 240
 			@ftp_exec($this->connect, 'OPTS UTF8 OFF');
241 241
 		} else {
242
-			@ftp_exec($this->connect, 'OPTS UTF8 ON' );
242
+			@ftp_exec($this->connect, 'OPTS UTF8 ON');
243 243
 		}
244 244
 		
245 245
 		// switch off extended passive mode - may be usefull for some servers
246
-		@ftp_exec($this->connect, 'epsv4 off' );
246
+		@ftp_exec($this->connect, 'epsv4 off');
247 247
 		// enter passive mode if required
248 248
 		ftp_pasv($this->connect, $this->options['mode'] == 'passive');
249 249
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 		$name = $info[8];
312 312
 		
313 313
 		if (preg_match('|(.+)\-\>(.+)|', $name, $m)) {
314
-			$name   = trim($m[1]);
314
+			$name = trim($m[1]);
315 315
 			// check recursive processing
316 316
 			if ($this->cacheDirTarget && $this->_joinPath($base, $name) !== $this->cacheDirTarget) {
317 317
 				return array();
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 			$stat['owner'] = $info[2];
348 348
 			$stat['group'] = $info[3];
349 349
 			$stat['perm']  = substr($info[0], 1);
350
-			$stat['isowner'] = $stat['owner']? ($stat['owner'] == $this->options['user']) : $this->options['owner'];
350
+			$stat['isowner'] = $stat['owner'] ? ($stat['owner'] == $this->options['user']) : $this->options['owner'];
351 351
 		}
352 352
 		
353 353
 		$perm = $this->parsePermissions($info[0], $stat['owner']);
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 			$info[4] = 0;
380 380
 			$info[0] = 'drwxr-xr-x';
381 381
 		} else {
382
-			$info[4] = (int)$size;
382
+			$info[4] = (int) $size;
383 383
 			$info[0] = '-rw-r--r--';
384 384
 		}
385 385
 		return $info;
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	protected function parsePermissions($perm, $user = '') {
396 396
 		$res   = array();
397 397
 		$parts = array();
398
-		$owner = $user? ($user == $this->options['user']) : $this->options['owner'];
398
+		$owner = $user ? ($user == $this->options['user']) : $this->options['owner'];
399 399
 		for ($i = 0, $l = strlen($perm); $i < $l; $i++) {
400 400
 			$parts[] = substr($perm, $i, 1);
401 401
 		}
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
 			}
427 427
 		}
428 428
 		$list = $this->convEncOut($list);
429
-		$prefix = ($path === $this->separator)? $this->separator : $path . $this->separator;
429
+		$prefix = ($path === $this->separator) ? $this->separator : $path.$this->separator;
430 430
 		$targets = array();
431
-		foreach($list as $stat) {
432
-			$p = $prefix . $stat['name'];
431
+		foreach ($list as $stat) {
432
+			$p = $prefix.$stat['name'];
433 433
 			if (isset($stat['target'])) {
434 434
 				// stat later
435 435
 				$targets[$stat['name']] = $stat['target'];
@@ -441,10 +441,10 @@  discard block
 block discarded – undo
441 441
 			}
442 442
 		}
443 443
 		// stat link targets
444
-		foreach($targets as $name => $target) {
444
+		foreach ($targets as $name => $target) {
445 445
 			$stat = array();
446 446
 			$stat['name'] = $name;
447
-			$p = $prefix . $name;
447
+			$p = $prefix.$name;
448 448
 			$cacheDirTarget = $this->cacheDirTarget;
449 449
 			$this->cacheDirTarget = $this->convEncIn($target, true);
450 450
 			if ($tstat = $this->stat($target)) {
@@ -453,12 +453,12 @@  discard block
 block discarded – undo
453 453
 				$stat['thash'] = $tstat['hash'];
454 454
 				$stat['mime']  = $tstat['mime'];
455 455
 				$stat['read']  = $tstat['read'];
456
-				$stat['write']  = $tstat['write'];
456
+				$stat['write'] = $tstat['write'];
457 457
 				
458
-				if (isset($tstat['ts']))      { $stat['ts']      = $tstat['ts']; }
459
-				if (isset($tstat['owner']))   { $stat['owner']   = $tstat['owner']; }
460
-				if (isset($tstat['group']))   { $stat['group']   = $tstat['group']; }
461
- 				if (isset($tstat['perm']))    { $stat['perm']    = $tstat['perm']; }
458
+				if (isset($tstat['ts'])) { $stat['ts']      = $tstat['ts']; }
459
+				if (isset($tstat['owner'])) { $stat['owner']   = $tstat['owner']; }
460
+				if (isset($tstat['group'])) { $stat['group']   = $tstat['group']; }
461
+ 				if (isset($tstat['perm'])) { $stat['perm']    = $tstat['perm']; }
462 462
  				if (isset($tstat['isowner'])) { $stat['isowner'] = $tstat['isowner']; }
463 463
 			} else {
464 464
 				
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 		$comps = $new_comps;
572 572
 		$path = implode($this->separator, $comps);
573 573
 		if ($initial_slashes) {
574
-			$path = str_repeat($this->separator, $initial_slashes) . $path;
574
+			$path = str_repeat($this->separator, $initial_slashes).$path;
575 575
 		}
576 576
 		
577 577
 		return $path ? $path : '.';
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 	 * @author Dmitry (dio) Levashov
638 638
 	 **/
639 639
 	protected function _inpath($path, $parent) {
640
-		return $path == $parent || strpos($path, $parent. $this->separator) === 0;
640
+		return $path == $parent || strpos($path, $parent.$this->separator) === 0;
641 641
 	}
642 642
 	
643 643
 	/***************** file stat ********************/
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 		}
670 670
 		if (!$this->MLSTsupprt) {
671 671
 			//if ($path == $this->root && (empty($this->ARGS['reload']) || !isset($this->ARGS['target']) || strpos($this->ARGS['target'], $this->id) !== 0)) {
672
-			if ($path == $this->root && ! $this->isMyReload()) {
672
+			if ($path == $this->root && !$this->isMyReload()) {
673 673
 				return array(
674 674
 					'name' => $this->root,
675 675
 					'mime' => 'directory',
@@ -677,9 +677,9 @@  discard block
 block discarded – undo
677 677
 				);
678 678
 			}
679 679
 			$this->cacheDir($this->convEncOut($this->_dirname($path)));
680
-			return $this->convEncIn(isset($this->cache[$outPath])? $this->cache[$outPath] : array());
680
+			return $this->convEncIn(isset($this->cache[$outPath]) ? $this->cache[$outPath] : array());
681 681
 		}
682
-		$raw = ftp_raw($this->connect, 'MLST ' . $path);
682
+		$raw = ftp_raw($this->connect, 'MLST '.$path);
683 683
 		if (is_array($raw) && count($raw) > 1 && substr(trim($raw[0]), 0, 1) == 2) {
684 684
 			$parts = explode(';', trim($raw[1]));
685 685
 			array_pop($parts);
@@ -709,8 +709,8 @@  discard block
 block discarded – undo
709 709
 
710 710
 					case 'perm':
711 711
 						$val = strtolower($val);
712
-						$stat['read']  = (int)preg_match('/e|l|r/', $val);
713
-						$stat['write'] = (int)preg_match('/w|m|c/', $val);
712
+						$stat['read']  = (int) preg_match('/e|l|r/', $val);
713
+						$stat['write'] = (int) preg_match('/w|m|c/', $val);
714 714
 						if (!preg_match('/f|d/', $val)) {
715 715
 							$stat['locked'] = 1;
716 716
 						}
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 			if (!$this->ftpOsUnix) {
796 796
 				$info = $this->normalizeRawWindows($str);
797 797
 			}
798
-			$name = isset($info[8])? trim($info[8]) : '';
798
+			$name = isset($info[8]) ? trim($info[8]) : '';
799 799
 			if ($name && $name !== '.' && $name !== '..' && substr(strtolower($info[0]), 0, 1) === 'd') {
800 800
 				return true;
801 801
 			}
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 	 * @return resource|false
851 851
 	 * @author Dmitry (dio) Levashov
852 852
 	 **/
853
-	protected function _fopen($path, $mode='rb') {
853
+	protected function _fopen($path, $mode = 'rb') {
854 854
 		// try ftp stream wrapper
855 855
 		if (ini_get('allow_url_fopen')) {
856 856
 			$url = 'ftp://'.$this->options['user'].':'.$this->options['pass'].'@'.$this->options['host'].':'.$this->options['port'].$path;
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	 * @return bool
888 888
 	 * @author Dmitry (dio) Levashov
889 889
 	 **/
890
-	protected function _fclose($fp, $path='') {
890
+	protected function _fclose($fp, $path = '') {
891 891
 		@fclose($fp);
892 892
 		if ($path) {
893 893
 			@unlink($this->getTempFile($path));
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
 			if (@file_put_contents($local, $content, LOCK_EX) !== false
1063 1063
 			&& ($fp = @fopen($local, 'rb'))) {
1064 1064
 				clearstatcache();
1065
-				$res  = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path));
1065
+				$res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path));
1066 1066
 				@fclose($fp);
1067 1067
 			}
1068 1068
 			file_exists($local) && @unlink($local);
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 	 * @return bool
1088 1088
 	 **/
1089 1089
 	protected function _chmod($path, $mode) {
1090
-		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode));
1090
+		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode));
1091 1091
 		return @ftp_chmod($this->connect, $modeOct, $path);
1092 1092
 	}
1093 1093
 
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 		}
1141 1141
 
1142 1142
 		$basename = $this->_basename($path);
1143
-		$localPath = $dir . DIRECTORY_SEPARATOR . $basename;
1143
+		$localPath = $dir.DIRECTORY_SEPARATOR.$basename;
1144 1144
 
1145 1145
 		if (!ftp_get($this->connect, $localPath, $path, FTP_BINARY)) {
1146 1146
 			//cleanup
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 		
1178 1178
 		// archive contains one item - extract in archive dir
1179 1179
 		$name = '';
1180
-		$src = $dir . DIRECTORY_SEPARATOR . $filesToProcess[0];
1180
+		$src = $dir.DIRECTORY_SEPARATOR.$filesToProcess[0];
1181 1181
 		if (($extractTo === 'auto' || !$extractTo) && count($filesToProcess) === 1 && is_file($src)) {
1182 1182
 			$name = $filesToProcess[0];
1183 1183
 		} else if ($extractTo === 'auto' || $extractTo) {
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 			$src = $dir;
1187 1187
 			$name = basename($path);
1188 1188
 			if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
1189
-				$name = substr($name, 0,  strlen($name)-strlen($m[0]));
1189
+				$name = substr($name, 0, strlen($name) - strlen($m[0]));
1190 1190
 			}
1191 1191
 			$test = $this->_joinPath(dirname($path), $name);
1192 1192
 			if ($this->stat($test)) {
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 		if ($name !== '' && is_file($src)) {
1198 1198
 			$result = $this->_joinPath(dirname($path), $name);
1199 1199
 
1200
-			if (! ftp_put($this->connect, $result, $src, FTP_BINARY)) {
1200
+			if (!ftp_put($this->connect, $result, $src, FTP_BINARY)) {
1201 1201
 				$this->rmdirRecursive($dir);
1202 1202
 				return false;
1203 1203
 			}
@@ -1211,19 +1211,19 @@  discard block
 block discarded – undo
1211 1211
 				}
1212 1212
 				$result[] = $dstDir;
1213 1213
 			}
1214
-			foreach($filesToProcess as $name) {
1214
+			foreach ($filesToProcess as $name) {
1215 1215
 				$name = rtrim($name, DIRECTORY_SEPARATOR);
1216
-				$src = $dir . DIRECTORY_SEPARATOR . $name;
1216
+				$src = $dir.DIRECTORY_SEPARATOR.$name;
1217 1217
 				if (is_dir($src)) {
1218 1218
 					$p = dirname($name);
1219 1219
 					$name = basename($name);
1220
-					if (! $target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) {
1220
+					if (!$target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) {
1221 1221
 						$this->rmdirRecursive($dir);
1222 1222
 						return false;
1223 1223
 					}
1224 1224
 				} else {
1225 1225
 					$target = $this->_joinPath($dstDir, $name);
1226
-					if (! ftp_put($this->connect, $target, $src, FTP_BINARY)) {
1226
+					if (!ftp_put($this->connect, $target, $src, FTP_BINARY)) {
1227 1227
 						$this->rmdirRecursive($dir);
1228 1228
 						return false;
1229 1229
 					}
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
 		is_dir($dir) && $this->rmdirRecursive($dir);
1240 1240
 		
1241 1241
 		$this->clearcache();
1242
-		return $result? $result : false;
1242
+		return $result ? $result : false;
1243 1243
 	}
1244 1244
 
1245 1245
 	/**
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
 		}
1280 1280
 
1281 1281
 		//cleanup
1282
-		if(!$this->rmdirRecursive($tmpDir)) {
1282
+		if (!$this->rmdirRecursive($tmpDir)) {
1283 1283
 			return false;
1284 1284
 		}
1285 1285
 
@@ -1383,7 +1383,7 @@  discard block
 block discarded – undo
1383 1383
 		$remoteDirLen = strlen($remote_directory);
1384 1384
 		foreach ($contents as $item) {
1385 1385
 			$relative_path = substr($item['path'], $remoteDirLen);
1386
-			$local_path = $dest_local_directory . DIRECTORY_SEPARATOR . $relative_path;
1386
+			$local_path = $dest_local_directory.DIRECTORY_SEPARATOR.$relative_path;
1387 1387
 			switch ($item['type']) {
1388 1388
 				case 'd':
1389 1389
 					$success = mkdir($local_path);
@@ -1414,8 +1414,8 @@  discard block
 block discarded – undo
1414 1414
 		} else {
1415 1415
 			$success = true;
1416 1416
 			foreach (array_reverse(elFinderVolumeFTP::listFilesInDirectory($dirPath, false)) as $path) {
1417
-				$path = $dirPath . DIRECTORY_SEPARATOR . $path;
1418
-				if(is_link($path)) {
1417
+				$path = $dirPath.DIRECTORY_SEPARATOR.$path;
1418
+				if (is_link($path)) {
1419 1419
 					unlink($path);
1420 1420
 				} else if (is_dir($path)) {
1421 1421
 					$success = rmdir($path);
@@ -1426,11 +1426,11 @@  discard block
 block discarded – undo
1426 1426
 					break;
1427 1427
 				}
1428 1428
 			}
1429
-			if($success) {
1429
+			if ($success) {
1430 1430
 				$success = rmdir($dirPath);
1431 1431
 			}
1432 1432
 		}
1433
-		if(!$success) {
1433
+		if (!$success) {
1434 1434
 			$this->setError(elFinder::ERROR_RM, $dirPath);
1435 1435
 			return false;
1436 1436
 		}
@@ -1452,25 +1452,25 @@  discard block
 block discarded – undo
1452 1452
 		if (!is_dir($dir)) {
1453 1453
 			return false;
1454 1454
 		}
1455
-		$excludes = array(".","..");
1455
+		$excludes = array(".", "..");
1456 1456
 		$result = array();
1457 1457
 		$files = scandir($dir);
1458
-		if(!$files) {
1458
+		if (!$files) {
1459 1459
 			return array();
1460 1460
 		}
1461
-		foreach($files as $file) {
1462
-			if(!in_array($file, $excludes)) {
1461
+		foreach ($files as $file) {
1462
+			if (!in_array($file, $excludes)) {
1463 1463
 				$path = $dir.DIRECTORY_SEPARATOR.$file;
1464
-				if(is_link($path)) {
1465
-					if($omitSymlinks) {
1464
+				if (is_link($path)) {
1465
+					if ($omitSymlinks) {
1466 1466
 						continue;
1467 1467
 					} else {
1468 1468
 						$result[] = $prefix.$file;
1469 1469
 					}
1470
-				} else if(is_dir($path)) {
1470
+				} else if (is_dir($path)) {
1471 1471
 					$result[] = $prefix.$file.DIRECTORY_SEPARATOR;
1472 1472
 					$subs = elFinderVolumeFTP::listFilesInDirectory($path, $omitSymlinks, $prefix.$file.DIRECTORY_SEPARATOR);
1473
-					if($subs) {
1473
+					if ($subs) {
1474 1474
 						$result = array_merge($result, $subs);
1475 1475
 					}
1476 1476
 					
Please login to merge, or discard this patch.
php/elFinderVolumeLocalFileSystem.class.php 3 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.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -5,19 +5,19 @@
 block discarded – undo
5 5
 if (! class_exists('RecursiveCallbackFilterIterator', false)) {
6 6
 	class RecursiveCallbackFilterIterator extends RecursiveFilterIterator {
7 7
 	   
8
-	    public function __construct ( RecursiveIterator $iterator, $callback ) {
9
-	        $this->callback = $callback;
10
-	        parent::__construct($iterator);
11
-	    }
8
+		public function __construct ( RecursiveIterator $iterator, $callback ) {
9
+			$this->callback = $callback;
10
+			parent::__construct($iterator);
11
+		}
12 12
 	   
13
-	    public function accept () {
14
-	        $callback = $this->callback;
15
-	        return $callback(parent::current(), parent::key(), parent::getInnerIterator());
16
-	    }
13
+		public function accept () {
14
+			$callback = $this->callback;
15
+			return $callback(parent::current(), parent::key(), parent::getInnerIterator());
16
+		}
17 17
 	   
18
-	    public function getChildren () {
19
-	        return new self($this->getInnerIterator()->getChildren(), $this->callback);
20
-	    }
18
+		public function getChildren () {
19
+			return new self($this->getInnerIterator()->getChildren(), $this->callback);
20
+		}
21 21
 	}
22 22
 }
23 23
 
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -2,20 +2,20 @@  discard block
 block discarded – undo
2 2
 
3 3
 // Implement similar functionality in PHP 5.2 or 5.3
4 4
 // http://php.net/manual/class.recursivecallbackfilteriterator.php#110974
5
-if (! class_exists('RecursiveCallbackFilterIterator', false)) {
5
+if (!class_exists('RecursiveCallbackFilterIterator', false)) {
6 6
 	class RecursiveCallbackFilterIterator extends RecursiveFilterIterator {
7 7
 	   
8
-	    public function __construct ( RecursiveIterator $iterator, $callback ) {
8
+	    public function __construct(RecursiveIterator $iterator, $callback) {
9 9
 	        $this->callback = $callback;
10 10
 	        parent::__construct($iterator);
11 11
 	    }
12 12
 	   
13
-	    public function accept () {
13
+	    public function accept() {
14 14
 	        $callback = $this->callback;
15 15
 	        return $callback(parent::current(), parent::key(), parent::getInnerIterator());
16 16
 	    }
17 17
 	   
18
-	    public function getChildren () {
18
+	    public function getChildren() {
19 19
 	        return new self($this->getInnerIterator()->getChildren(), $this->callback);
20 20
 	    }
21 21
 	}
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	 * @author Dmitry (dio) Levashov
61 61
 	 **/
62 62
 	public function __construct() {
63
-		$this->options['alias']    = '';              // alias to replace root dir name
64
-		$this->options['dirMode']  = 0755;            // new dirs mode
65
-		$this->options['fileMode'] = 0644;            // new files mode
66
-		$this->options['quarantine'] = '.quarantine';  // quarantine folder name - required to check archive (must be hidden)
67
-		$this->options['maxArcFilesSize'] = 0;        // max allowed archive files size (0 - no limit)
63
+		$this->options['alias']    = ''; // alias to replace root dir name
64
+		$this->options['dirMode']  = 0755; // new dirs mode
65
+		$this->options['fileMode'] = 0644; // new files mode
66
+		$this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden)
67
+		$this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit)
68 68
 		$this->options['rootCssClass'] = 'elfinder-navbar-root-local';
69 69
 	}
70 70
 	
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	protected function init() {
82 82
 		// Normalize directory separator for windows
83 83
 		if (DIRECTORY_SEPARATOR !== '/') {
84
-			foreach(array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) {
84
+			foreach (array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) {
85 85
 				if (!empty($this->options[$key])) {
86 86
 					$this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]);
87 87
 				}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		// if no thumbnails url - try detect it
146 146
 		if ($root['read'] && !$this->tmbURL && $this->URL) {
147 147
 			if (strpos($this->tmbPath, $this->root) === 0) {
148
-				$this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1));
148
+				$this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1));
149 149
 				if (preg_match("|[^/?&=]$|", $this->tmbURL)) {
150 150
 					$this->tmbURL .= '/';
151 151
 				}
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 		if ($mtime != $compare) {
204 204
 			return $mtime;
205 205
 		}
206
-		$inotifywait = defined('ELFINER_INOTIFYWAIT_PATH')? ELFINER_INOTIFYWAIT_PATH : 'inotifywait';
206
+		$inotifywait = defined('ELFINER_INOTIFYWAIT_PATH') ? ELFINER_INOTIFYWAIT_PATH : 'inotifywait';
207 207
 		$path = escapeshellarg($path);
208 208
 		$standby = max(1, intval($standby));
209 209
 		$cmd = $inotifywait.' '.$path.' -t '.$standby.' -e moved_to,moved_from,move,create,delete,delete_self';
210
-		$this->procExec($cmd , $o, $r);
210
+		$this->procExec($cmd, $o, $r);
211 211
 		if ($r === 0) {
212 212
 			// changed
213 213
 			clearstatcache();
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	 * @author Dmitry (dio) Levashov
265 265
 	 **/
266 266
 	protected function _joinPath($dir, $name) {
267
-		return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name;
267
+		return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name;
268 268
 	}
269 269
 	
270 270
 	/**
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 		$comps = $new_comps;
317 317
 		$path = implode('/', $comps);
318 318
 		if ($initial_slashes) {
319
-			$path = str_repeat('/', $initial_slashes) . $path;
319
+			$path = str_repeat('/', $initial_slashes).$path;
320 320
 		}
321 321
 		
322 322
 		if ($changeSep) {
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 **/
388 388
 	protected function _inpath($path, $parent) {
389 389
 		$cwd = getcwd();
390
-		$real_path   = $this->getFullPath($path,   $cwd);
390
+		$real_path   = $this->getFullPath($path, $cwd);
391 391
 		$real_parent = $this->getFullPath($parent, $cwd);
392 392
 		if ($real_path && $real_parent) {
393 393
 			return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0;
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 					$stat = array();
447 447
 					return $stat;
448 448
 				} else {
449
-					$stat['mime']  = 'symlink-broken';
449
+					$stat['mime'] = 'symlink-broken';
450 450
 					$target = readlink($path);
451 451
 					$lstat = lstat($path);
452 452
 					$ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']);
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 			$fstat = stat($path);
463 463
 			$uid = $fstat['uid'];
464 464
 			$gid = $fstat['gid'];
465
-			$stat['perm'] = substr((string)decoct($fstat['mode']), -4);
465
+			$stat['perm'] = substr((string) decoct($fstat['mode']), -4);
466 466
 			$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
467 467
 		}
468 468
 		
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 			$stat['mime'] = $dir ? 'directory' : $this->mimetype($path);
473 473
 		}
474 474
 		//logical rights first
475
-		$stat['read'] = ($linkreadable || is_readable($path))? null : false;
476
-		$stat['write'] = is_writable($path)? null : false;
475
+		$stat['read'] = ($linkreadable || is_readable($path)) ? null : false;
476
+		$stat['write'] = is_writable($path) ? null : false;
477 477
 
478 478
 		if (is_null($stat['read'])) {
479 479
 			$stat['size'] = $dir ? 0 : $size;
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 			$dirItr = new ParentIterator(
547 547
 				new RecursiveDirectoryIterator($path,
548 548
 					FilesystemIterator::SKIP_DOTS |
549
-					(defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS')?
549
+					(defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') ?
550 550
 						RecursiveDirectoryIterator::FOLLOW_SYMLINKS : 0)
551 551
 				)
552 552
 			);
@@ -554,8 +554,8 @@  discard block
 block discarded – undo
554 554
 			if ($dirItr->hasChildren()) {
555 555
 				$dirs = true;
556 556
 				$name = $dirItr->getSubPathName();
557
-				while($name) {
558
-					if (!$this->attr($path . DIRECTORY_SEPARATOR . $name, 'read', null, true)) {
557
+				while ($name) {
558
+					if (!$this->attr($path.DIRECTORY_SEPARATOR.$name, 'read', null, true)) {
559 559
 						$dirs = false;
560 560
 						$dirItr->next();
561 561
 						$name = $dirItr->getSubPathName();
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 							$br = true;
646 646
 						} else {
647 647
 							$_path = $fpath;
648
-							$stat['mime']  = 'symlink-broken';
648
+							$stat['mime'] = 'symlink-broken';
649 649
 							$target = readlink($_path);
650 650
 							$lstat = lstat($_path);
651 651
 							$ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']);
@@ -670,13 +670,13 @@  discard block
 block discarded – undo
670 670
 					if ($statOwner && !$linkreadable) {
671 671
 						$uid = $file->getOwner();
672 672
 						$gid = $file->getGroup();
673
-						$stat['perm'] = substr((string)decoct($file->getPerms()), -4);
673
+						$stat['perm'] = substr((string) decoct($file->getPerms()), -4);
674 674
 						$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
675 675
 					}
676 676
 					
677 677
 					//logical rights first
678
-					$stat['read'] = ($linkreadable || $file->isReadable())? null : false;
679
-					$stat['write'] = $file->isWritable()? null : false;
678
+					$stat['read'] = ($linkreadable || $file->isReadable()) ? null : false;
679
+					$stat['write'] = $file->isWritable() ? null : false;
680 680
 					
681 681
 					if (is_null($stat['read'])) {
682 682
 						$stat['size'] = $dir ? 0 : $size;
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 		
693 693
 		if ($cache) {
694 694
 			$cache = $this->convEncOut($cache, false);
695
-			foreach($cache as $d) {
695
+			foreach ($cache as $d) {
696 696
 				$this->updateCache($d[0], $d[1]);
697 697
 			}
698 698
 		}
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 	 * @return resource|false
709 709
 	 * @author Dmitry (dio) Levashov
710 710
 	 **/
711
-	protected function _fopen($path, $mode='rb') {
711
+	protected function _fopen($path, $mode = 'rb') {
712 712
 		return @fopen($path, $mode);
713 713
 	}
714 714
 	
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 	 * @return bool
720 720
 	 * @author Dmitry (dio) Levashov
721 721
 	 **/
722
-	protected function _fclose($fp, $path='') {
722
+	protected function _fclose($fp, $path = '') {
723 723
 		return @fclose($fp);
724 724
 	}
725 725
 	
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 		$path = $this->_joinPath($dir, $name);
852 852
 
853 853
 		$meta = stream_get_meta_data($fp);
854
-		$uri = isset($meta['uri'])? $meta['uri'] : '';
854
+		$uri = isset($meta['uri']) ? $meta['uri'] : '';
855 855
 		if ($uri && @is_file($uri)) {
856 856
 			fclose($fp);
857 857
 			$isCmdPaste = ($this->ARGS['cmd'] === 'paste');
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 	 * @return bool
916 916
 	 **/
917 917
 	protected function _chmod($path, $mode) {
918
-		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode));
918
+		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode));
919 919
 		$ret = @chmod($path, $modeOct);
920 920
 		$ret && clearstatcache();
921 921
 		return  $ret;
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 				$src = $dir;
1034 1034
 				$name = basename($path);
1035 1035
 				if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
1036
-					$name = substr($name, 0,  strlen($name)-strlen($m[0]));
1036
+					$name = substr($name, 0, strlen($name) - strlen($m[0]));
1037 1037
 				}
1038 1038
 				$test = dirname($path).DIRECTORY_SEPARATOR.$name;
1039 1039
 				if (file_exists($test) || is_link($test)) {
@@ -1042,9 +1042,9 @@  discard block
 block discarded – undo
1042 1042
 			}
1043 1043
 			
1044 1044
 			if ($name !== '') {
1045
-				$result  = dirname($path).DIRECTORY_SEPARATOR.$name;
1045
+				$result = dirname($path).DIRECTORY_SEPARATOR.$name;
1046 1046
 
1047
-				if (! @rename($src, $result)) {
1047
+				if (!@rename($src, $result)) {
1048 1048
 					$this->delTree($dir);
1049 1049
 					return false;
1050 1050
 				}
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 				$dstDir = dirname($path);
1053 1053
 				$res = false;
1054 1054
 				$result = array();
1055
-				foreach($ls as $name) {
1055
+				foreach ($ls as $name) {
1056 1056
 					$target = $dstDir.DIRECTORY_SEPARATOR.$name;
1057 1057
 					if (is_dir($target)) {
1058 1058
 						$this->delTree($target);
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
 					new RecursiveDirectoryIterator($path,
1139 1139
 						FilesystemIterator::KEY_AS_PATHNAME |
1140 1140
 						FilesystemIterator::SKIP_DOTS |
1141
-						(defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS')?
1141
+						(defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') ?
1142 1142
 							RecursiveDirectoryIterator::FOLLOW_SYMLINKS : 0)
1143 1143
 					),
1144 1144
 					array($this, 'localFileSystemSearchIteratorFilter')
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 		$result = array();
1161 1161
 		
1162 1162
 		if ($match) {
1163
-			foreach($match as $p) {
1163
+			foreach ($match as $p) {
1164 1164
 				$stat = $this->stat($p);
1165 1165
 		
1166 1166
 				if (!$stat) { // invalid links
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 					$stat['path'] = $this->path($stat['hash']);
1178 1178
 					if ($this->URL && !isset($stat['url'])) {
1179 1179
 						$path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1));
1180
-						$stat['url'] = $this->URL . $path;
1180
+						$stat['url'] = $this->URL.$path;
1181 1181
 					}
1182 1182
 		
1183 1183
 					$result[] = $stat;
@@ -1192,9 +1192,9 @@  discard block
 block discarded – undo
1192 1192
 
1193 1193
 	public function localFileSystemSearchIteratorFilter($file, $key, $iterator) {
1194 1194
 		if ($iterator->hasChildren()) {
1195
-			return (bool)$this->attr($key, 'read', null, true);
1195
+			return (bool) $this->attr($key, 'read', null, true);
1196 1196
 		}
1197
-		return ($this->stripos($file->getFilename(), $this->doSearchCurrentQuery) === false)? false : true;
1197
+		return ($this->stripos($file->getFilename(), $this->doSearchCurrentQuery) === false) ? false : true;
1198 1198
 	}
1199 1199
 	
1200 1200
 } // END class 
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   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
 	 **/
310 310
 	protected function doSearch($path, $q, $mimes) {
311 311
 		$dirs = array();
312
-		$timeout = $this->options['searchTimeout']? $this->searchStart + $this->options['searchTimeout'] : 0;
312
+		$timeout = $this->options['searchTimeout'] ? $this->searchStart + $this->options['searchTimeout'] : 0;
313 313
 		
314 314
 		if ($path != $this->root) {
315 315
 			$inpath = array(intval($path));
316
-			while($inpath) {
316
+			while ($inpath) {
317 317
 				$in = '('.join(',', $inpath).')';
318 318
 				$inpath = array();
319 319
 				$sql = 'SELECT f.id FROM %s AS f WHERE f.parent_id IN '.$in.' AND `mime` = \'directory\'';
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 		
333 333
 		if ($mimes) {
334 334
 			$whrs = array();
335
-			foreach($mimes as $mime) {
335
+			foreach ($mimes as $mime) {
336 336
 				if (strpos($mime, '/') === false) {
337 337
 					$whrs[] = sprintf('f.mime LIKE "%s/%%"', $this->db->real_escape_string($mime));
338 338
 				} else {
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 			$whr = sprintf('f.name RLIKE "%s"', $this->db->real_escape_string($q));
345 345
 		}
346 346
 		if ($dirs) {
347
-			$whr = '(' . $whr . ') AND (`parent_id` IN (' . join(',', $dirs) . '))';
347
+			$whr = '('.$whr.') AND (`parent_id` IN ('.join(',', $dirs).'))';
348 348
 		}
349 349
 		
350 350
 		$sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, 0 AS dirs 
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 	 * @return resource|false
596 596
 	 * @author Dmitry (dio) Levashov
597 597
 	 **/
598
-	protected function _fopen($path, $mode='rb') {
598
+	protected function _fopen($path, $mode = 'rb') {
599 599
 		$fp = $this->tmbPath
600 600
 			? @fopen($this->getTempFile($path), 'w+')
601 601
 			: @tmpfile();
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 	 * @return bool
623 623
 	 * @author Dmitry (dio) Levashov
624 624
 	 **/
625
-	protected function _fclose($fp, $path='') {
625
+	protected function _fclose($fp, $path = '') {
626 626
 		@fclose($fp);
627 627
 		if ($path) {
628 628
 			@unlink($this->getTempFile($path));
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 		$this->clearcache();
755 755
 		
756 756
 		$mime = $stat['mime'];
757
-		$w = !empty($stat['width'])  ? $stat['width']  : 0;
757
+		$w = !empty($stat['width']) ? $stat['width'] : 0;
758 758
 		$h = !empty($stat['height']) ? $stat['height'] : 0;
759 759
 		
760 760
 		$id = $this->_joinPath($dir, $name);
Please login to merge, or discard this patch.
php/plugins/AutoResize/plugin.php 3 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   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 
53 53
 	public function __construct($opts) {
54 54
 		$defaults = array(
55
-			'enable'         => true,       // For control by volume driver
56
-			'maxWidth'       => 1024,       // Path to Water mark image
57
-			'maxHeight'      => 1024,       // Margin right pixel
58
-			'quality'        => 95,         // JPEG image save quality
59
-			'preserveExif'   => false,      // Preserve EXIF data (Imagick only)
60
-			'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field )
55
+			'enable'         => true, // For control by volume driver
56
+			'maxWidth'       => 1024, // Path to Water mark image
57
+			'maxHeight'      => 1024, // Margin right pixel
58
+			'quality'        => 95, // JPEG image save quality
59
+			'preserveExif'   => false, // Preserve EXIF data (Imagick only)
60
+			'targetType'     => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP // Target image formats ( bit-field )
61 61
 		);
62 62
 
63 63
 		$this->opts = array_merge($defaults, $opts);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			$opts = array_merge($this->opts, $volOpts);
72 72
 		}
73 73
 		
74
-		if (! $opts['enable']) {
74
+		if (!$opts['enable']) {
75 75
 			return false;
76 76
 		}
77 77
 		
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 				IMAGETYPE_PNG => IMG_PNG,
88 88
 				IMAGETYPE_WBMP => IMG_WBMP,
89 89
 		);
90
-		if (! ($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) {
90
+		if (!($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) {
91 91
 			return false;
92 92
 		}
93 93
 		
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	}
100 100
 	
101 101
 	private function resize($src, $srcImgInfo, $maxWidth, $maxHeight, $quality, $preserveExif) {
102
-		$zoom = min(($maxWidth/$srcImgInfo[0]),($maxHeight/$srcImgInfo[1]));
103
-		$width = round($srcImgInfo[0] * $zoom);
104
-		$height = round($srcImgInfo[1] * $zoom);
102
+		$zoom = min(($maxWidth/$srcImgInfo[0]), ($maxHeight/$srcImgInfo[1]));
103
+		$width = round($srcImgInfo[0]*$zoom);
104
+		$height = round($srcImgInfo[1]*$zoom);
105 105
 		
106 106
 		if (class_exists('Imagick', false)) {
107 107
 			return $this->resize_imagick($src, $width, $height, $quality, $preserveExif);
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
 				break;
122 122
 			case 'image/jpeg':
123 123
 				if (@imagetypes() & IMG_JPG) {
124
-					$oSrcImg = @imagecreatefromjpeg($src) ;
124
+					$oSrcImg = @imagecreatefromjpeg($src);
125 125
 				} else {
126 126
 					$ermsg = 'JPEG images are not supported';
127 127
 				}
128 128
 				break;
129 129
 			case 'image/png':
130 130
 				if (@imagetypes() & IMG_PNG) {
131
-					$oSrcImg = @imagecreatefrompng($src) ;
131
+					$oSrcImg = @imagecreatefrompng($src);
132 132
 				} else {
133 133
 					$ermsg = 'PNG images are not supported';
134 134
 				}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 				break;
147 147
 		}
148 148
 		
149
-		if ($oSrcImg &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
149
+		if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) {
150 150
 			
151 151
 			if (!imagecopyresampled($tmp, $oSrcImg, 0, 0, 0, 0, $width, $height, $srcImgInfo[0], $srcImgInfo[1])) {
152 152
 				return false;
Please login to merge, or discard this patch.
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -1,51 +1,51 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * elFinder Plugin AutoResize
4
- *
5
- * Auto resize on file upload.
6
- *
7
- * ex. binding, configure on connector options
8
- *	$opts = array(
9
- *		'bind' => array(
10
- *			'upload.presave' => array(
11
- *				'Plugin.AutoResize.onUpLoadPreSave'
12
- *			)
13
- *		),
14
- *		// global configure (optional)
15
- *		'plugin' => array(
16
- *			'AutoResize' => array(
17
- *				'enable'         => true,       // For control by volume driver
18
- *				'maxWidth'       => 1024,       // Path to Water mark image
19
- *				'maxHeight'      => 1024,       // Margin right pixel
20
- *				'quality'        => 95,         // JPEG image save quality
21
- *				'preserveExif'   => false,      // Preserve EXIF data (Imagick only)
22
- *				'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field )
23
- *			)
24
- *		),
25
- *		// each volume configure (optional)
26
- *		'roots' => array(
27
- *			array(
28
- *				'driver' => 'LocalFileSystem',
29
- *				'path'   => '/path/to/files/',
30
- *				'URL'    => 'http://localhost/to/files/'
31
- *				'plugin' => array(
32
- *					'AutoResize' => array(
33
- *						'enable'         => true,       // For control by volume driver
34
- *						'maxWidth'       => 1024,       // Path to Water mark image
35
- *						'maxHeight'      => 1024,       // Margin right pixel
36
- *						'quality'        => 95,         // JPEG image save quality
37
- *						'preserveExif'   => false,      // Preserve EXIF data (Imagick only)
38
- *						'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field )
39
- *					)
40
- *				)
41
- *			)
42
- *		)
43
- *	);
44
- *
45
- * @package elfinder
46
- * @author Naoki Sawada
47
- * @license New BSD
48
- */
3
+	 * elFinder Plugin AutoResize
4
+	 *
5
+	 * Auto resize on file upload.
6
+	 *
7
+	 * ex. binding, configure on connector options
8
+	 *	$opts = array(
9
+	 *		'bind' => array(
10
+	 *			'upload.presave' => array(
11
+	 *				'Plugin.AutoResize.onUpLoadPreSave'
12
+	 *			)
13
+	 *		),
14
+	 *		// global configure (optional)
15
+	 *		'plugin' => array(
16
+	 *			'AutoResize' => array(
17
+	 *				'enable'         => true,       // For control by volume driver
18
+	 *				'maxWidth'       => 1024,       // Path to Water mark image
19
+	 *				'maxHeight'      => 1024,       // Margin right pixel
20
+	 *				'quality'        => 95,         // JPEG image save quality
21
+	 *				'preserveExif'   => false,      // Preserve EXIF data (Imagick only)
22
+	 *				'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field )
23
+	 *			)
24
+	 *		),
25
+	 *		// each volume configure (optional)
26
+	 *		'roots' => array(
27
+	 *			array(
28
+	 *				'driver' => 'LocalFileSystem',
29
+	 *				'path'   => '/path/to/files/',
30
+	 *				'URL'    => 'http://localhost/to/files/'
31
+	 *				'plugin' => array(
32
+	 *					'AutoResize' => array(
33
+	 *						'enable'         => true,       // For control by volume driver
34
+	 *						'maxWidth'       => 1024,       // Path to Water mark image
35
+	 *						'maxHeight'      => 1024,       // Margin right pixel
36
+	 *						'quality'        => 95,         // JPEG image save quality
37
+	 *						'preserveExif'   => false,      // Preserve EXIF data (Imagick only)
38
+	 *						'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field )
39
+	 *					)
40
+	 *				)
41
+	 *			)
42
+	 *		)
43
+	 *	);
44
+	 *
45
+	 * @package elfinder
46
+	 * @author Naoki Sawada
47
+	 * @license New BSD
48
+	 */
49 49
 class elFinderPluginAutoResize {
50 50
 
51 51
 	private $opts = array();
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.
php/elFinderConnector.class.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @return void
35 35
 	 * @author Dmitry (dio) Levashov
36 36
 	 **/
37
-	public function __construct($elFinder, $debug=false) {
37
+	public function __construct($elFinder, $debug = false) {
38 38
 		
39 39
 		$this->elFinder = $elFinder;
40 40
 		if ($debug) {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		if ($isPost && !$src && $rawPostData = @file_get_contents('php://input')) {
55 55
 			// for support IE XDomainRequest()
56 56
 			$parts = explode('&', $rawPostData);
57
-			foreach($parts as $part) {
57
+			foreach ($parts as $part) {
58 58
 				list($key, $value) = array_pad(explode('=', $part), 2, '');
59 59
 				$key = rawurldecode($key);
60 60
 				if (substr($key, -2) === '[]') {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 **/
122 122
 	protected function output(array $data) {
123 123
 		// clear output buffer
124
-		while(@ob_get_level()){ @ob_end_clean(); }
124
+		while (@ob_get_level()) { @ob_end_clean(); }
125 125
 		
126 126
 		$header = isset($data['header']) ? $data['header'] : $this->header;
127 127
 		unset($data['header']);
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
 							$psize = $end - $start + 1;
163 163
 							
164 164
 							header('HTTP/1.1 206 Partial Content');
165
-							header('Content-Length: ' . $psize);
166
-							header('Content-Range: bytes ' . $start . '-' . $end . '/' . $size);
165
+							header('Content-Length: '.$psize);
166
+							header('Content-Range: bytes '.$start.'-'.$end.'/'.$size);
167 167
 							
168 168
 							fseek($fp, $start);
169 169
 						}
170 170
 					}
171 171
 				}
172
-				if (is_null($psize)){
172
+				if (is_null($psize)) {
173 173
 					rewind($fp);
174 174
 				}
175 175
 			} else {
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -212,8 +212,9 @@
 block discarded – undo
212 212
 	protected function input_filter($args) {
213 213
 		static $magic_quotes_gpc = NULL;
214 214
 		
215
-		if ($magic_quotes_gpc === NULL)
216
-			$magic_quotes_gpc = (version_compare(PHP_VERSION, '5.4', '<') && get_magic_quotes_gpc());
215
+		if ($magic_quotes_gpc === NULL) {
216
+					$magic_quotes_gpc = (version_compare(PHP_VERSION, '5.4', '<') && get_magic_quotes_gpc());
217
+		}
217 218
 		
218 219
 		if (is_array($args)) {
219 220
 			return array_map(array(& $this, 'input_filter'), $args);
Please login to merge, or discard this patch.
php/elFinderVolumeDriver.class.php 4 patches
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.
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
 		'mimefile'        => '',
201 201
 		// mime type normalize map : Array '[ext]:[detected mime type]' => '[normalized mime]'
202 202
 		'mimeMap'         => array(
203
-		                     'md:application/x-genesis-rom' => 'text/x-markdown',
204
-		                     'md:text/plain'                => 'text/x-markdown',
205
-		                     'markdown:text/plain'          => 'text/x-markdown',
206
-		                     'css:text/x-asm'               => 'text/css'
207
-		                    ),
203
+							 'md:application/x-genesis-rom' => 'text/x-markdown',
204
+							 'md:text/plain'                => 'text/x-markdown',
205
+							 'markdown:text/plain'          => 'text/x-markdown',
206
+							 'css:text/x-asm'               => 'text/css'
207
+							),
208 208
 		// directory for thumbnails
209 209
 		'tmbPath'         => '.tmb',
210 210
 		// mode to create thumbnails dir
@@ -4070,14 +4070,14 @@  discard block
 block discarded – undo
4070 4070
 	// }
4071 4071
 
4072 4072
 	/**
4073
-	* Find position of first occurrence of string in a string with multibyte support
4074
-	*
4075
-	* @param  string  $haystack  The string being checked.
4076
-	* @param  string  $needle    The string to find in haystack.
4077
-	* @param  int     $offset    The search offset. If it is not specified, 0 is used.
4078
-	* @return int|bool
4079
-	* @author Alexey Sukhotin
4080
-	**/
4073
+	 * Find position of first occurrence of string in a string with multibyte support
4074
+	 *
4075
+	 * @param  string  $haystack  The string being checked.
4076
+	 * @param  string  $needle    The string to find in haystack.
4077
+	 * @param  int     $offset    The search offset. If it is not specified, 0 is used.
4078
+	 * @return int|bool
4079
+	 * @author Alexey Sukhotin
4080
+	 **/
4081 4081
 	protected function stripos($haystack , $needle , $offset = 0) {
4082 4082
 		if (function_exists('mb_stripos')) {
4083 4083
 			return mb_stripos($haystack , $needle , $offset);
Please login to merge, or discard this patch.
Doc Comments   +17 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1238,7 +1238,6 @@  discard block
 block discarded – undo
1238 1238
 	 * Return file info or false on error
1239 1239
 	 *
1240 1240
 	 * @param  string   $hash      file hash
1241
-	 * @param  bool     $realpath  add realpath field to file info
1242 1241
 	 * @return array|false
1243 1242
 	 * @author Dmitry (dio) Levashov
1244 1243
 	 **/
@@ -1259,7 +1258,6 @@  discard block
 block discarded – undo
1259 1258
 	 * Return folder info
1260 1259
 	 *
1261 1260
 	 * @param  string   $hash  folder hash
1262
-	 * @param  bool     $hidden  return hidden file info
1263 1261
 	 * @return array|false
1264 1262
 	 * @author Dmitry (dio) Levashov
1265 1263
 	 **/
@@ -1592,7 +1590,6 @@  discard block
 block discarded – undo
1592 1590
 	 *
1593 1591
 	 * @param  Resource $fp      file pointer
1594 1592
 	 * @param  string   $dst     destination folder hash
1595
-	 * @param  string   $src     file name
1596 1593
 	 * @param  string   $tmpname file tmp name - required to detect mime type
1597 1594
 	 * @return array|false
1598 1595
 	 * @author Dmitry (dio) Levashov
@@ -1678,7 +1675,6 @@  discard block
 block discarded – undo
1678 1675
 	 * Paste files
1679 1676
 	 *
1680 1677
 	 * @param  Object  $volume  source volume
1681
-	 * @param  string  $source  file hash
1682 1678
 	 * @param  string  $dst     destination dir hash
1683 1679
 	 * @param  bool    $rmSrc   remove source after copy?
1684 1680
 	 * @return array|false
@@ -2301,7 +2297,6 @@  discard block
 block discarded – undo
2301 2297
 	 * Open file and return file pointer (with convert encording)
2302 2298
 	 *
2303 2299
 	 * @param  string  $path  file path
2304
-	 * @param  bool    $write open file for writing
2305 2300
 	 * @return resource|false
2306 2301
 	 * @author Naoki Sawada
2307 2302
 	 **/
@@ -2432,7 +2427,8 @@  discard block
 block discarded – undo
2432 2427
 	 * Not implemented
2433 2428
 	 *
2434 2429
 	 * @param  string  path
2435
-	 * @return mixed
2430
+	 * @param string $path
2431
+	 * @return string
2436 2432
 	 * @author Dmitry (dio) Levashov
2437 2433
 	 **/
2438 2434
 	protected function crypt($path) {
@@ -2444,7 +2440,8 @@  discard block
 block discarded – undo
2444 2440
 	 * Not implemented
2445 2441
 	 *
2446 2442
 	 * @param  mixed  hash
2447
-	 * @return mixed
2443
+	 * @param string $hash
2444
+	 * @return string
2448 2445
 	 * @author Dmitry (dio) Levashov
2449 2446
 	 **/
2450 2447
 	protected function uncrypt($hash) {
@@ -2477,7 +2474,6 @@  discard block
 block discarded – undo
2477 2474
 	/**
2478 2475
 	 * Return new unique name based on file name and suffix
2479 2476
 	 *
2480
-	 * @param  string  $path    file path
2481 2477
 	 * @param  string  $suffix  suffix append to name
2482 2478
 	 * @return string
2483 2479
 	 * @author Dmitry (dio) Levashov
@@ -2545,6 +2541,7 @@  discard block
 block discarded – undo
2545 2541
 	 * @param  string $to      to character encoding
2546 2542
 	 * @param  string $locale  local locale
2547 2543
 	 * @param  string $unknown replaces character for unknown
2544
+	 * @param boolean $restoreLocale
2548 2545
 	 * @return mixed
2549 2546
 	 */
2550 2547
 	protected function convEnc($var, $from, $to, $locale, $restoreLocale, $unknown = '_') {
@@ -2726,6 +2723,7 @@  discard block
 block discarded – undo
2726 2723
 	 *
2727 2724
 	 * @param string $dir  parent dir path
2728 2725
 	 * @param string $name new file name
2726
+	 * @param boolean $isDir
2729 2727
 	 * @return bool
2730 2728
 	 * @author Dmitry (dio) Levashov
2731 2729
 	 **/
@@ -3279,7 +3277,7 @@  discard block
 block discarded – undo
3279 3277
 	 * @param  string  $src   source path
3280 3278
 	 * @param  string  $dst   destination dir path
3281 3279
 	 * @param  string  $name  new file name (optionaly)
3282
-	 * @return string|false
3280
+	 * @return boolean|string
3283 3281
 	 * @author Dmitry (dio) Levashov
3284 3282
 	 **/
3285 3283
 	protected function copy($src, $dst, $name) {
@@ -3332,7 +3330,7 @@  discard block
 block discarded – undo
3332 3330
 	 * @param  string  $src   source path
3333 3331
 	 * @param  string  $dst   destination dir path
3334 3332
 	 * @param  string  $name  new file name 
3335
-	 * @return string|false
3333
+	 * @return string|boolean
3336 3334
 	 * @author Dmitry (dio) Levashov
3337 3335
 	 **/
3338 3336
 	protected function move($src, $dst, $name) {
@@ -3358,7 +3356,7 @@  discard block
 block discarded – undo
3358 3356
 	 * @param  string  $src          source file hash
3359 3357
 	 * @param  string  $destination  destination dir path
3360 3358
 	 * @param  string  $name         file name
3361
-	 * @return string|false
3359
+	 * @return boolean|string
3362 3360
 	 * @author Dmitry (dio) Levashov
3363 3361
 	 **/
3364 3362
 	protected function copyFrom($volume, $src, $destination, $name) {
@@ -3506,7 +3504,7 @@  discard block
 block discarded – undo
3506 3504
 	 * @param  string  $path  thumnbnail path 
3507 3505
 	 * @param  array   $stat  file stat
3508 3506
 	 * @param  bool    $checkTmbPath
3509
-	 * @return string|bool
3507
+	 * @return boolean
3510 3508
 	 * @author Dmitry (dio) Levashov
3511 3509
 	 **/
3512 3510
 	protected function canCreateTmb($path, $stat, $checkTmbPath = true) {
@@ -3523,7 +3521,7 @@  discard block
 block discarded – undo
3523 3521
 	 *
3524 3522
 	 * @param  string  $path  thumnbnail path 
3525 3523
 	 * @param  array   $stat  file stat
3526
-	 * @return string|bool
3524
+	 * @return boolean
3527 3525
 	 * @author Dmitry (dio) Levashov
3528 3526
 	 **/
3529 3527
 	protected function canResize($path, $stat) {
@@ -3534,7 +3532,6 @@  discard block
 block discarded – undo
3534 3532
 	 * Create thumnbnail and return it's URL on success
3535 3533
 	 *
3536 3534
 	 * @param  string  $path  file path
3537
-	 * @param  string  $mime  file mime type
3538 3535
 	 * @return string|false
3539 3536
 	 * @author Dmitry (dio) Levashov
3540 3537
 	 **/
@@ -4013,7 +4010,7 @@  discard block
 block discarded – undo
4013 4010
 	 *
4014 4011
 	 * @param  string  $command       command line
4015 4012
 	 * @param  array   $output        stdout strings
4016
-	 * @param  array   $return_var    process exit code
4013
+	 * @param  integer   $return_var    process exit code
4017 4014
 	 * @param  array   $error_output  stderr strings
4018 4015
 	 * @return int     exit code
4019 4016
 	 * @author Alexey Sukhotin
@@ -4225,7 +4222,7 @@  discard block
 block discarded – undo
4225 4222
 	* @param  string  $haystack  The string being checked.
4226 4223
 	* @param  string  $needle    The string to find in haystack.
4227 4224
 	* @param  int     $offset    The search offset. If it is not specified, 0 is used.
4228
-	* @return int|bool
4225
+	* @return integer
4229 4226
 	* @author Alexey Sukhotin
4230 4227
 	**/
4231 4228
 	protected function stripos($haystack , $needle , $offset = 0) {
@@ -4450,7 +4447,7 @@  discard block
 block discarded – undo
4450 4447
 	 * @param  array   $files  files names list
4451 4448
 	 * @param  string  $name   archive name
4452 4449
 	 * @param  array   $arc    archiver options
4453
-	 * @return string|bool
4450
+	 * @return string|false
4454 4451
 	 * @author Dmitry (dio) Levashov, 
4455 4452
 	 * @author Alexey Sukhotin
4456 4453
 	 * @author Naoki Sawada
@@ -4507,7 +4504,7 @@  discard block
 block discarded – undo
4507 4504
 	 * @param  string        $dir      target dir
4508 4505
 	 * @param  array         $files    files names list
4509 4506
 	 * @param  string|object $zipPath  Zip archive name
4510
-	 * @return void
4507
+	 * @return boolean
4511 4508
 	 * @author Naoki Sawada
4512 4509
 	 */
4513 4510
 	protected static function zipArchiveZip($dir, $files, $zipPath) {
@@ -4763,7 +4760,7 @@  discard block
 block discarded – undo
4763 4760
 	 * Copy file into another file (only inside one volume)
4764 4761
 	 *
4765 4762
 	 * @param  string  $source  source file path
4766
-	 * @param  string  $target  target dir path
4763
+	 * @param  string  $targetDir  target dir path
4767 4764
 	 * @param  string  $name    file name
4768 4765
 	 * @return bool
4769 4766
 	 * @author Dmitry (dio) Levashov
@@ -4775,7 +4772,7 @@  discard block
 block discarded – undo
4775 4772
 	 * Return new file path or false.
4776 4773
 	 *
4777 4774
 	 * @param  string  $source  source file path
4778
-	 * @param  string  $target  target dir path
4775
+	 * @param  string  $targetDir  target dir path
4779 4776
 	 * @param  string  $name    file name
4780 4777
 	 * @return string|bool
4781 4778
 	 * @author Dmitry (dio) Levashov
Please login to merge, or discard this patch.
Spacing   +140 added lines, -141 removed lines patch added patch discarded remove patch
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 		'utf8fix'      => false,
302 302
 		 //                           й                 ё              Й               Ё              Ø         Å
303 303
 		'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"),
304
-		'utf8replace'  => array("\u0439",        "\u0451",       "\u0419",       "\u0401",       "\u00d8", "\u00c5")
304
+		'utf8replace'  => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5")
305 305
 	);
306 306
 
307 307
 	/**
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 	 **/
605 605
 	protected function configure() {
606 606
 		// set ARGS
607
-		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET;
607
+		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
608 608
 		// set thumbnails path
609 609
 		$path = $this->options['tmbPath'];
610 610
 		if ($path) {
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 		
636 636
 		// check 'statOwner' for command `chmod`
637 637
 		if (empty($this->options['statOwner'])) {
638
-			$this->disabled[] ='chmod';
638
+			$this->disabled[] = 'chmod';
639 639
 		}
640 640
 		
641 641
 		// check 'mimeMap'
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 	 **/
767 767
 	public function mount(array $opts) {
768 768
 		if (!isset($opts['path']) || $opts['path'] === '') {
769
-			return $this->setError('Path undefined.');;
769
+			return $this->setError('Path undefined.'); ;
770 770
 		}
771 771
 		
772 772
 		$this->options = array_merge($this->options, $opts);
@@ -785,14 +785,14 @@  discard block
 block discarded – undo
785 785
 		$argInit = !empty($this->ARGS['init']);
786 786
 		
787 787
 		// session cache
788
-		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
788
+		if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
789 789
 			$_SESSION[elFinder::$sessionCacheKey][$this->id] = array();
790 790
 		}
791 791
 		$this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id];
792 792
 		
793 793
 		// default file attribute
794 794
 		$this->defaults = array(
795
-			'read'    => isset($this->options['defaults']['read'])  ? !!$this->options['defaults']['read']  : true,
795
+			'read'    => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true,
796 796
 			'write'   => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true,
797 797
 			'locked'  => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false,
798 798
 			'hidden'  => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false
@@ -819,8 +819,8 @@  discard block
 block discarded – undo
819 819
 			$this->access = $this->options['accessControl'];
820 820
 		}
821 821
 		
822
-		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y'));
823
-		$this->yesterday = $this->today-86400;
822
+		$this->today     = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
823
+		$this->yesterday = $this->today - 86400;
824 824
 		
825 825
 		// debug($this->attributes);
826 826
 		if (!$this->init()) {
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 				foreach ($mimecf as $line_num => $line) {
920 920
 					if (!preg_match('/^\s*#/', $line)) {
921 921
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
922
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
922
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
923 923
 							if (!isset(self::$mimetypes[$mime[$i]])) {
924 924
 								self::$mimetypes[$mime[$i]] = $mime[0];
925 925
 							}
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
 		
949 949
 		if ($root['read']) {
950 950
 			// check startPath - path to open by default instead of root
951
-			$startPath = $this->options['startPath']? $this->normpathCE($this->options['startPath']) : '';
951
+			$startPath = $this->options['startPath'] ? $this->normpathCE($this->options['startPath']) : '';
952 952
 			if ($startPath) {
953 953
 				$start = $this->stat($startPath);
954 954
 				if (!empty($start)
@@ -972,8 +972,8 @@  discard block
 block discarded – undo
972 972
 				'read'    => false
973 973
 			));
974 974
 		}
975
-		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1;
976
-		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48;
975
+		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1;
976
+		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48;
977 977
 		$this->URL      = $this->options['URL'];
978 978
 		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) {
979 979
 			$this->URL .= '/';
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 		
1028 1028
 		// fix sync interval
1029 1029
 		if ($this->options['syncMinMs'] !== 0) {
1030
-			$this->options['syncMinMs'] = max($this->options[$this->options['syncChkAsTs']? 'tsPlSleep' : 'lsPlSleep'] * 1000, intval($this->options['syncMinMs']));
1030
+			$this->options['syncMinMs'] = max($this->options[$this->options['syncChkAsTs'] ? 'tsPlSleep' : 'lsPlSleep']*1000, intval($this->options['syncMinMs']));
1031 1031
 		}
1032 1032
 
1033 1033
 		return $this->mounted = true;
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
 	public function options($hash) {
1132 1132
 		$create = $createext = array();
1133 1133
 		if (isset($this->archivers['create']) && is_array($this->archivers['create'])) {
1134
-			foreach($this->archivers['create'] as $m => $v) {
1134
+			foreach ($this->archivers['create'] as $m => $v) {
1135 1135
 				$create[] = $m;
1136 1136
 				$createext[$m] = $v['ext'];
1137 1137
 			}
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 				'extract'   => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(),
1153 1153
 				'createext' => $createext
1154 1154
 			),
1155
-			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(),
1155
+			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(),
1156 1156
 			'syncChkAsTs'     => intval($this->options['syncChkAsTs']),
1157 1157
 			'syncMinMs'       => intval($this->options['syncMinMs'])
1158 1158
 		);
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 	 * @author Naoki Sawada
1167 1167
 	 */
1168 1168
 	public function getOption($name) {
1169
-		return isset($this->options[$name])? $this->options[$name] : null;
1169
+		return isset($this->options[$name]) ? $this->options[$name] : null;
1170 1170
 	}
1171 1171
 	
1172 1172
 	/**
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
 	 */
1179 1179
 	public function getOptionsPlugin($name = '') {
1180 1180
 		if ($name) {
1181
-			return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array();
1181
+			return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array();
1182 1182
 		} else {
1183 1183
 			return $this->options['plugin'];
1184 1184
 		}
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
 		$file = $this->stat($path);
1310 1310
 		
1311 1311
 		if ($isRoot) {
1312
-			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array();
1312
+			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array();
1313 1313
 			$file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON
1314 1314
 			if (isset($this->options['netkey'])) {
1315 1315
 				$file['netkey'] = $this->options['netkey'];
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 	 * @return array|false
1328 1328
 	 * @author Dmitry (dio) Levashov
1329 1329
 	 **/
1330
-	public function dir($hash, $resolveLink=false) {
1330
+	public function dir($hash, $resolveLink = false) {
1331 1331
 		if (($dir = $this->file($hash)) == false) {
1332 1332
 			return $this->setError(elFinder::ERROR_DIR_NOT_FOUND);
1333 1333
 		}
@@ -1391,14 +1391,14 @@  discard block
 block discarded – undo
1391 1391
 	 * @return array|false
1392 1392
 	 * @author Dmitry (dio) Levashov
1393 1393
 	 **/
1394
-	public function tree($hash='', $deep=0, $exclude='') {
1394
+	public function tree($hash = '', $deep = 0, $exclude = '') {
1395 1395
 		$path = $hash ? $this->decode($hash) : $this->root;
1396 1396
 		
1397 1397
 		if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') {
1398 1398
 			return false;
1399 1399
 		}
1400 1400
 		
1401
-		$dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null);
1401
+		$dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null);
1402 1402
 		array_unshift($dirs, $dir);
1403 1403
 		return $dirs;
1404 1404
 	}
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
 	 * @return array|false
1629 1629
 	 * @author Dmitry (dio) Levashov
1630 1630
 	 **/
1631
-	public function duplicate($hash, $suffix='copy') {
1631
+	public function duplicate($hash, $suffix = 'copy') {
1632 1632
 		if ($this->commandDisabled('duplicate')) {
1633 1633
 			return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED);
1634 1634
 		}
@@ -1704,7 +1704,7 @@  discard block
 block discarded – undo
1704 1704
 		
1705 1705
 		if ($file) { // file exists
1706 1706
 			// check POST data `overwrite` for 3rd party uploader
1707
-			$overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite'];
1707
+			$overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite'];
1708 1708
 			if ($overwrite) {
1709 1709
 				if (!$file['write']) {
1710 1710
 					return $this->setError(elFinder::ERROR_PERM_DENIED);
@@ -1775,7 +1775,7 @@  discard block
 block discarded – undo
1775 1775
 		if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) {
1776 1776
 			return $rmSrc
1777 1777
 				? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test))
1778
-				: $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1778
+				: $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1779 1779
 		}
1780 1780
 
1781 1781
 		$test = $this->joinPathCE($destination, $name);
@@ -1938,7 +1938,7 @@  discard block
 block discarded – undo
1938 1938
 			return $this->setError(elFinder::ERROR_PERM_DENIED);
1939 1939
 		}
1940 1940
 		$this->clearcache();
1941
-		$this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir;
1941
+		$this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir;
1942 1942
 		
1943 1943
 		if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) {
1944 1944
 			if (is_array($path)) {
@@ -1996,9 +1996,9 @@  discard block
 block discarded – undo
1996 1996
 		if ($name === '') {
1997 1997
 			$name = count($files) == 1 ? $files[0] : 'Archive';
1998 1998
 		} else {
1999
-			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name));
1999
+			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name));
2000 2000
 		}
2001
-		$name .='.' . $archiver['ext'];
2001
+		$name .= '.'.$archiver['ext'];
2002 2002
 		$name = $this->uniqueName($dir, $name, '');
2003 2003
 		$this->clearcache();
2004 2004
 		return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false;
@@ -2037,7 +2037,7 @@  discard block
 block discarded – undo
2037 2037
 		
2038 2038
 		$path = $this->decode($hash);
2039 2039
 		
2040
-		$work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path);
2040
+		$work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path);
2041 2041
 
2042 2042
 		if (!$work_path || !is_writable($work_path)) {
2043 2043
 			if ($work_path && $path !== $work_path && is_file($work_path)) {
@@ -2052,7 +2052,7 @@  discard block
 block discarded – undo
2052 2052
 			}
2053 2053
 		}
2054 2054
 
2055
-		switch($mode) {
2055
+		switch ($mode) {
2056 2056
 			
2057 2057
 			case 'propresize':
2058 2058
 				$result = $this->imgResize($work_path, $width, $height, true, true, null, $jpgQuality);
@@ -2149,7 +2149,7 @@  discard block
 block discarded – undo
2149 2149
 		$this->searchStart = time();
2150 2150
 		return ($q === '' || $this->commandDisabled('search'))
2151 2151
 			? array()
2152
-			: $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes);
2152
+			: $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes);
2153 2153
 	}
2154 2154
 	
2155 2155
 	/**
@@ -2221,9 +2221,9 @@  discard block
 block discarded – undo
2221 2221
 		$path = ltrim($path, $this->separator);
2222 2222
 		$dirs = explode($this->separator, $path);
2223 2223
 		array_pop($dirs);
2224
-		foreach($dirs as $dir) {
2224
+		foreach ($dirs as $dir) {
2225 2225
 			$targetPath = $this->joinPathCE($base, $dir);
2226
-			if (! $_realpath = $this->realpath($this->encode($targetPath))) {
2226
+			if (!$_realpath = $this->realpath($this->encode($targetPath))) {
2227 2227
 				if ($stat = $this->mkdir($targetHash, $dir)) {
2228 2228
 					$result['added'][] = $stat;
2229 2229
 					$targetHash = $stat['hash'];
@@ -2290,7 +2290,7 @@  discard block
 block discarded – undo
2290 2290
 	 * @author Naoki Sawada
2291 2291
 	 **/
2292 2292
 	protected function dirnameCE($path) {
2293
-		return (!$this->encoding)? $this->_dirname($path) :	$this->convEncOut($this->_dirname($this->convEncIn($path)));
2293
+		return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path)));
2294 2294
 	}
2295 2295
 	
2296 2296
 	/**
@@ -2301,7 +2301,7 @@  discard block
 block discarded – undo
2301 2301
 	 * @author Naoki Sawada
2302 2302
 	 **/
2303 2303
 	protected function basenameCE($path) {
2304
-		return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2304
+		return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2305 2305
 	}
2306 2306
 	
2307 2307
 	/**
@@ -2314,7 +2314,7 @@  discard block
 block discarded – undo
2314 2314
 	 * @author Naoki Sawada
2315 2315
 	 **/
2316 2316
 	protected function joinPathCE($dir, $name) {
2317
-		return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2317
+		return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2318 2318
 	}
2319 2319
 	
2320 2320
 	/**
@@ -2325,7 +2325,7 @@  discard block
 block discarded – undo
2325 2325
 	 * @author Naoki Sawada
2326 2326
 	 **/
2327 2327
 	protected function normpathCE($path) {
2328
-		return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2328
+		return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2329 2329
 	}
2330 2330
 	
2331 2331
 	/**
@@ -2336,7 +2336,7 @@  discard block
 block discarded – undo
2336 2336
 	 * @author Naoki Sawada
2337 2337
 	 **/
2338 2338
 	protected function relpathCE($path) {
2339
-		return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2339
+		return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2340 2340
 	}
2341 2341
 	
2342 2342
 	/**
@@ -2347,7 +2347,7 @@  discard block
 block discarded – undo
2347 2347
 	 * @author Naoki Sawada
2348 2348
 	 **/
2349 2349
 	protected function abspathCE($path) {
2350
-		return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path)));
2350
+		return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path)));
2351 2351
 	}
2352 2352
 	
2353 2353
 	/**
@@ -2359,7 +2359,7 @@  discard block
 block discarded – undo
2359 2359
 	 * @author Naoki Sawada
2360 2360
 	 **/
2361 2361
 	protected function inpathCE($path, $parent) {
2362
-		return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2362
+		return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2363 2363
 	}
2364 2364
 	
2365 2365
 	/**
@@ -2370,8 +2370,8 @@  discard block
 block discarded – undo
2370 2370
 	 * @return resource|false
2371 2371
 	 * @author Naoki Sawada
2372 2372
 	 **/
2373
-	protected function fopenCE($path, $mode='rb') {
2374
-		return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2373
+	protected function fopenCE($path, $mode = 'rb') {
2374
+		return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2375 2375
 	}
2376 2376
 	
2377 2377
 	/**
@@ -2382,8 +2382,8 @@  discard block
 block discarded – undo
2382 2382
 	 * @return bool
2383 2383
 	 * @author Naoki Sawada
2384 2384
 	 **/
2385
-	protected function fcloseCE($fp, $path='') {
2386
-		return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2385
+	protected function fcloseCE($fp, $path = '') {
2386
+		return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2387 2387
 	}
2388 2388
 	
2389 2389
 	/**
@@ -2398,7 +2398,7 @@  discard block
 block discarded – undo
2398 2398
 	 * @author Naoki Sawada
2399 2399
 	 **/
2400 2400
 	protected function saveCE($fp, $dir, $name, $stat) {
2401
-		return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2401
+		return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2402 2402
 	}
2403 2403
 	
2404 2404
 	/**
@@ -2410,7 +2410,7 @@  discard block
 block discarded – undo
2410 2410
 	 **/
2411 2411
 	protected function subdirsCE($path) {
2412 2412
 		if (!isset($this->subdirsCache[$path])) {
2413
-			$this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2413
+			$this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2414 2414
 		}
2415 2415
 		return $this->subdirsCache[$path];
2416 2416
 	}
@@ -2423,7 +2423,7 @@  discard block
 block discarded – undo
2423 2423
 	 * @author Naoki Sawada
2424 2424
 	 **/
2425 2425
 	protected function scandirCE($path) {
2426
-		return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2426
+		return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2427 2427
 	}
2428 2428
 	
2429 2429
 	/**
@@ -2436,7 +2436,7 @@  discard block
 block discarded – undo
2436 2436
 	 * @author Naoki Sawada
2437 2437
 	 **/
2438 2438
 	protected function symlinkCE($source, $targetDir, $name) {
2439
-		return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2439
+		return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2440 2440
 	}
2441 2441
 	
2442 2442
 	/***************** paths *******************/
@@ -2455,7 +2455,7 @@  discard block
 block discarded – undo
2455 2455
 			// cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root
2456 2456
 			$p = $this->relpathCE($path);
2457 2457
 			// if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt
2458
-			if ($p === '')	{
2458
+			if ($p === '') {
2459 2459
 				$p = DIRECTORY_SEPARATOR;
2460 2460
 			}
2461 2461
 
@@ -2488,7 +2488,7 @@  discard block
 block discarded – undo
2488 2488
 			// TODO uncrypt hash and return path
2489 2489
 			$path = $this->uncrypt($h); 
2490 2490
 			// append ROOT to path after it was cut in encode
2491
-			return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2491
+			return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2492 2492
 		}
2493 2493
 	}
2494 2494
 	
@@ -2548,21 +2548,21 @@  discard block
 block discarded – undo
2548 2548
 	 * @author Dmitry (dio) Levashov
2549 2549
 	 **/
2550 2550
 	public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) {
2551
-		$ext  = '';
2551
+		$ext = '';
2552 2552
 
2553 2553
 		if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
2554 2554
 			$ext  = '.'.$m[1];
2555
-			$name = substr($name, 0,  strlen($name)-strlen($m[0]));
2555
+			$name = substr($name, 0, strlen($name) - strlen($m[0]));
2556 2556
 		} 
2557 2557
 		
2558 2558
 		if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) {
2559
-			$i    = (int)$m[2];
2560
-			$name = substr($name, 0, strlen($name)-strlen($m[2]));
2559
+			$i    = (int) $m[2];
2560
+			$name = substr($name, 0, strlen($name) - strlen($m[2]));
2561 2561
 		} else {
2562 2562
 			$i     = $start;
2563 2563
 			$name .= $suffix;
2564 2564
 		}
2565
-		$max = $i+100000;
2565
+		$max = $i + 100000;
2566 2566
 
2567 2567
 		while ($i <= $max) {
2568 2568
 			$n = $name.($i > 0 ? $i : '').$ext;
@@ -2586,7 +2586,7 @@  discard block
 block discarded – undo
2586 2586
 	 * @author Naoki Sawada
2587 2587
 	 */
2588 2588
 	public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') {
2589
-		return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2589
+		return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2590 2590
 	}
2591 2591
 	
2592 2592
 	/**
@@ -2599,7 +2599,7 @@  discard block
 block discarded – undo
2599 2599
 	 * @author Naoki Sawada
2600 2600
 	 */
2601 2601
 	public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') {
2602
-		return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2602
+		return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2603 2603
 	}
2604 2604
 	
2605 2605
 	/**
@@ -2619,7 +2619,7 @@  discard block
 block discarded – undo
2619 2619
 			}
2620 2620
 			if (is_array($var)) {
2621 2621
 				$_ret = array();
2622
-				foreach($var as $_k => $_v) {
2622
+				foreach ($var as $_k => $_v) {
2623 2623
 					$_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_');
2624 2624
 				}
2625 2625
 				$var = $_ret;
@@ -2631,7 +2631,7 @@  discard block
 block discarded – undo
2631 2631
 						$_var = str_replace('?', $unknown, $_var);
2632 2632
 					}
2633 2633
 				}
2634
-				if  ($_var !== false) {
2634
+				if ($_var !== false) {
2635 2635
 					$var = $_var;
2636 2636
 				}
2637 2637
 			}
@@ -2658,7 +2658,7 @@  discard block
 block discarded – undo
2658 2658
 		
2659 2659
 		$key = '';
2660 2660
 		if ($path !== '') {
2661
-			$key = $this->id . '#' . $path;
2661
+			$key = $this->id.'#'.$path;
2662 2662
 			if (isset($cache[$key])) {
2663 2663
 				return $cache[$key];
2664 2664
 			}
@@ -2690,7 +2690,7 @@  discard block
 block discarded – undo
2690 2690
 		if ($work = $this->getTempFile()) {
2691 2691
 			if ($wfp = fopen($work, 'wb')) {
2692 2692
 				if ($fp = $this->_fopen($path)) {
2693
-					while(!feof($fp)) {
2693
+					while (!feof($fp)) {
2694 2694
 						fwrite($wfp, fread($fp, 8192));
2695 2695
 					}
2696 2696
 					$this->_fclose($fp, $path);
@@ -2734,7 +2734,7 @@  discard block
 block discarded – undo
2734 2734
 			@set_time_limit(30);
2735 2735
 			$stat = $this->stat($this->convEncOut($p));
2736 2736
 			$this->convEncIn();
2737
-			($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p);
2737
+			($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p);
2738 2738
 		}
2739 2739
 		return $this->_rmdir($localpath);
2740 2740
 	}
@@ -2751,7 +2751,7 @@  discard block
 block discarded – undo
2751 2751
 	 * @return bool
2752 2752
 	 * @author Dmitry (dio) Levashov
2753 2753
 	 **/
2754
-	protected function attr($path, $name, $val=null, $isDir=null) {
2754
+	protected function attr($path, $name, $val = null, $isDir = null) {
2755 2755
 		if (!isset($this->defaults[$name])) {
2756 2756
 			return false;
2757 2757
 		}
@@ -2783,7 +2783,7 @@  discard block
 block discarded – undo
2783 2783
 			} 
2784 2784
 		}
2785 2785
 		
2786
-		return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm;
2786
+		return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm;
2787 2787
 	}
2788 2788
 	
2789 2789
 	/**
@@ -2827,7 +2827,7 @@  discard block
 block discarded – undo
2827 2827
 	protected function allowPutMime($mime) {
2828 2828
 		// logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order
2829 2829
 		$allow  = $this->mimeAccepted($mime, $this->uploadAllow, null);
2830
-		$deny   = $this->mimeAccepted($mime, $this->uploadDeny,  null);
2830
+		$deny   = $this->mimeAccepted($mime, $this->uploadDeny, null);
2831 2831
 		$res = true; // default to allow
2832 2832
 		if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny'
2833 2833
 			$res = false; // default is deny
@@ -2860,7 +2860,7 @@  discard block
 block discarded – undo
2860 2860
 			if (!isset($this->sessionCache['rootstat'])) {
2861 2861
 				$this->sessionCache['rootstat'] = array();
2862 2862
 			}
2863
-			if (! $this->isMyReload()) {
2863
+			if (!$this->isMyReload()) {
2864 2864
 				// need $path as key for netmount/netunmount
2865 2865
 				if (isset($this->sessionCache['rootstat'][$rootKey])) {
2866 2866
 					if ($ret = elFinder::sessionDataDecode($this->sessionCache['rootstat'][$rootKey], 'array')) {
@@ -2901,10 +2901,10 @@  discard block
 block discarded – undo
2901 2901
 			if ($this->rootName) {
2902 2902
 				$stat['name'] = $this->rootName;
2903 2903
 			}
2904
-			if (! empty($this->options['icon'])) {
2904
+			if (!empty($this->options['icon'])) {
2905 2905
 				$stat['icon'] = $this->options['icon'];
2906 2906
 			}
2907
-			if (! empty($this->options['rootCssClass'])) {
2907
+			if (!empty($this->options['rootCssClass'])) {
2908 2908
 				$stat['csscls'] = $this->options['rootCssClass'];
2909 2909
 			}
2910 2910
 		} else {
@@ -2952,7 +2952,7 @@  discard block
 block discarded – undo
2952 2952
 			// lock when parent directory is not writable
2953 2953
 			if (!isset($stat['locked'])) {
2954 2954
 				$parent = $this->dirnameCE($path);
2955
-				$pstat = isset($this->cache[$parent])? $this->cache[$parent] : array();
2955
+				$pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array();
2956 2956
 				if (isset($pstat['write']) && !$pstat['write']) {
2957 2957
 					$stat['locked'] = true;
2958 2958
 				}
@@ -3010,7 +3010,7 @@  discard block
 block discarded – undo
3010 3010
 			}
3011 3011
 			if (!isset($stat['url']) && $this->URL && $this->encoding) {
3012 3012
 				$_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1));
3013
-				$stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN')? $_path : $this->convEncIn($_path, true)));
3013
+				$stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN') ? $_path : $this->convEncIn($_path, true)));
3014 3014
 			}
3015 3015
 		} else {
3016 3016
 			if ($isDir) {
@@ -3134,7 +3134,7 @@  discard block
 block discarded – undo
3134 3134
 				foreach ($mimecf as $line_num => $line) {
3135 3135
 					if (!preg_match('/^\s*#/', $line)) {
3136 3136
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
3137
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
3137
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
3138 3138
 							if (!isset(elFinderVolumeDriver::$mimetypes[$mime[$i]])) {
3139 3139
 								elFinderVolumeDriver::$mimetypes[$mime[$i]] = $mime[0];
3140 3140
 							}
@@ -3240,13 +3240,13 @@  discard block
 block discarded – undo
3240 3240
 	}
3241 3241
 	
3242 3242
 	protected function isMyReload($target = '', $ARGtarget = '') {
3243
-		if (! empty($this->ARGS['cmd']) && $this->ARGS['cmd'] === 'parents') {
3243
+		if (!empty($this->ARGS['cmd']) && $this->ARGS['cmd'] === 'parents') {
3244 3244
 			return true;
3245 3245
 		}
3246
-		if (! empty($this->ARGS['reload'])) {
3246
+		if (!empty($this->ARGS['reload'])) {
3247 3247
 			if ($ARGtarget === '') {
3248
-				$ARGtarget = isset($this->ARGS['target'])? $this->ARGS['target']
3249
-					: ((isset($this->ARGS['targets']) && is_array($this->ARGS['targets']) && count($this->ARGS['targets']) === 1)?
3248
+				$ARGtarget = isset($this->ARGS['target']) ? $this->ARGS['target']
3249
+					: ((isset($this->ARGS['targets']) && is_array($this->ARGS['targets']) && count($this->ARGS['targets']) === 1) ?
3250 3250
 						$this->ARGS['targets'][0] : '');
3251 3251
 			}
3252 3252
 			if ($ARGtarget !== '') {
@@ -3295,7 +3295,7 @@  discard block
 block discarded – undo
3295 3295
 	 * @return array
3296 3296
 	 * @author Dmitry (dio) Levashov
3297 3297
 	 **/
3298
-	protected function gettree($path, $deep, $exclude='') {
3298
+	protected function gettree($path, $deep, $exclude = '') {
3299 3299
 		$dirs = array();
3300 3300
 		
3301 3301
 		!isset($this->dirsCache[$path]) && $this->cacheDir($path);
@@ -3306,7 +3306,7 @@  discard block
 block discarded – undo
3306 3306
 			if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') {
3307 3307
 				$dirs[] = $stat;
3308 3308
 				if ($deep > 0 && !empty($stat['dirs'])) {
3309
-					$dirs = array_merge($dirs, $this->gettree($p, $deep-1));
3309
+					$dirs = array_merge($dirs, $this->gettree($p, $deep - 1));
3310 3310
 				}
3311 3311
 			}
3312 3312
 		}
@@ -3326,13 +3326,13 @@  discard block
 block discarded – undo
3326 3326
 	protected function doSearch($path, $q, $mimes) {
3327 3327
 		$result = array();
3328 3328
 		
3329
-		$timeout = $this->options['searchTimeout']? $this->searchStart + $this->options['searchTimeout'] : 0;
3329
+		$timeout = $this->options['searchTimeout'] ? $this->searchStart + $this->options['searchTimeout'] : 0;
3330 3330
 		if ($timeout && $timeout < time()) {
3331 3331
 			$this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode($path)));
3332 3332
 			return $result;
3333 3333
 		}
3334 3334
 		
3335
-		foreach($this->scandirCE($path) as $p) {
3335
+		foreach ($this->scandirCE($path) as $p) {
3336 3336
 			@set_time_limit($this->options['searchTimeout'] + 30);
3337 3337
 			
3338 3338
 			if ($timeout && ($this->error || $timeout < time())) {
@@ -3360,7 +3360,7 @@  discard block
 block discarded – undo
3360 3360
 					if ($this->encoding) {
3361 3361
 						$path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true)));
3362 3362
 					}
3363
-					$stat['url'] = $this->URL . $path;
3363
+					$stat['url'] = $this->URL.$path;
3364 3364
 				}
3365 3365
 				
3366 3366
 				$result[] = $stat;
@@ -3394,7 +3394,7 @@  discard block
 block discarded – undo
3394 3394
 			if (!$this->inpathCE($target, $this->root)) {
3395 3395
 				return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK);
3396 3396
 			}
3397
-			$stat   = $this->stat($target);
3397
+			$stat = $this->stat($target);
3398 3398
 			$this->clearcache();
3399 3399
 			return $stat && $this->symlinkCE($target, $dst, $name)
3400 3400
 				? $this->joinPathCE($dst, $name)
@@ -3675,15 +3675,15 @@  discard block
 block discarded – undo
3675 3675
 		}
3676 3676
 
3677 3677
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
3678
-		if ($s[0] <= $tmbSize && $s[1]	<= $tmbSize) {
3679
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3678
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
3679
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3680 3680
 		} else {
3681 3681
 		
3682 3682
 			if ($this->options['tmbCrop']) {
3683 3683
 		
3684 3684
 				$result = $tmb;
3685 3685
 				/* Resize and crop if image bigger than thumbnail */
3686
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3686
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3687 3687
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
3688 3688
 				}
3689 3689
 		
@@ -3700,7 +3700,7 @@  discard block
 block discarded – undo
3700 3700
 			}
3701 3701
 		
3702 3702
 			if ($result) {
3703
-				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3703
+				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3704 3704
 			}
3705 3705
 		}
3706 3706
 		
@@ -3746,18 +3746,18 @@  discard block
 block discarded – undo
3746 3746
 			/* Resizing by biggest side */
3747 3747
 			if ($resizeByBiggerSide) {
3748 3748
 				if ($orig_w > $orig_h) {
3749
-					$size_h = round($orig_h * $width / $orig_w);
3749
+					$size_h = round($orig_h*$width/$orig_w);
3750 3750
 					$size_w = $width;
3751 3751
 				} else {
3752
-					$size_w = round($orig_w * $height / $orig_h);
3752
+					$size_w = round($orig_w*$height/$orig_h);
3753 3753
 					$size_h = $height;
3754 3754
 				}
3755 3755
 			} else {
3756 3756
 				if ($orig_w > $orig_h) {
3757
-					$size_w = round($orig_w * $height / $orig_h);
3757
+					$size_w = round($orig_w*$height/$orig_h);
3758 3758
 					$size_h = $height;
3759 3759
 				} else {
3760
-					$size_h = round($orig_h * $width / $orig_w);
3760
+					$size_h = round($orig_h*$width/$orig_w);
3761 3761
 					$size_w = $width;
3762 3762
 				}
3763 3763
 			}
@@ -3775,7 +3775,7 @@  discard block
 block discarded – undo
3775 3775
 				// Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb
3776 3776
 				// resize bench: http://app-mgng.rhcloud.com/9
3777 3777
 				// resize sample: http://www.dylanbeattie.net/magick/filters/result.html
3778
-				$filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3778
+				$filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3779 3779
 				
3780 3780
 				$ani = ($img->getNumberImages() > 1);
3781 3781
 				if ($ani && is_null($destformat)) {
@@ -3800,11 +3800,11 @@  discard block
 block discarded – undo
3800 3800
 				break;
3801 3801
 
3802 3802
 			case 'gd':
3803
-				$img = $this->gdImageCreate($path,$s['mime']);
3803
+				$img = $this->gdImageCreate($path, $s['mime']);
3804 3804
 
3805
-				if ($img &&  false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3805
+				if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3806 3806
 				
3807
-					$this->gdImageBackground($tmp,$this->options['tmbBgColor']);
3807
+					$this->gdImageBackground($tmp, $this->options['tmbBgColor']);
3808 3808
 					
3809 3809
 					if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) {
3810 3810
 						return false;
@@ -3885,11 +3885,11 @@  discard block
 block discarded – undo
3885 3885
 				break;
3886 3886
 
3887 3887
 			case 'gd':
3888
-				$img = $this->gdImageCreate($path,$s['mime']);
3888
+				$img = $this->gdImageCreate($path, $s['mime']);
3889 3889
 
3890
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3890
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3891 3891
 					
3892
-					$this->gdImageBackground($tmp,$this->options['tmbBgColor']);
3892
+					$this->gdImageBackground($tmp, $this->options['tmbBgColor']);
3893 3893
 
3894 3894
 					$size_w = $width;
3895 3895
 					$size_h = $height;
@@ -3940,8 +3940,8 @@  discard block
 block discarded – undo
3940 3940
 		$result = false;
3941 3941
 
3942 3942
 		/* Coordinates for image over square aligning */
3943
-		$y = ceil(abs($height - $s[1]) / 2); 
3944
-		$x = ceil(abs($width - $s[0]) / 2);
3943
+		$y = ceil(abs($height - $s[1])/2); 
3944
+		$x = ceil(abs($width - $s[0])/2);
3945 3945
 
3946 3946
 		if (!$jpgQuality) {
3947 3947
 			$jpgQuality = $this->options['jpgQuality'];
@@ -3965,7 +3965,7 @@  discard block
 block discarded – undo
3965 3965
 						$gif->newImage($width, $height, new ImagickPixel($bgcolor));
3966 3966
 						$gif->setImageColorspace($img->getImageColorspace());
3967 3967
 						$gif->setImageFormat('gif');
3968
-						$gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3968
+						$gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3969 3969
 						$gif->setImageDelay($img->getImageDelay());
3970 3970
 						$gif->setImageIterations($img->getImageIterations());
3971 3971
 						$img1->addImage($gif);
@@ -3980,7 +3980,7 @@  discard block
 block discarded – undo
3980 3980
 					$img1 = new Imagick();
3981 3981
 					$img1->newImage($width, $height, new ImagickPixel($bgcolor));
3982 3982
 					$img1->setImageColorspace($img->getImageColorspace());
3983
-					$img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3983
+					$img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3984 3984
 					$result = $this->imagickImage($img, $path, $destformat, $jpgQuality);
3985 3985
 				}
3986 3986
 				
@@ -3991,11 +3991,11 @@  discard block
 block discarded – undo
3991 3991
 				break;
3992 3992
 
3993 3993
 			case 'gd':
3994
-				$img = $this->gdImageCreate($path,$s['mime']);
3994
+				$img = $this->gdImageCreate($path, $s['mime']);
3995 3995
 
3996
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3996
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3997 3997
 
3998
-					$this->gdImageBackground($tmp,$bgcolor);
3998
+					$this->gdImageBackground($tmp, $bgcolor);
3999 3999
 
4000 4000
 					if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) {
4001 4001
 						return false;
@@ -4027,15 +4027,15 @@  discard block
 block discarded – undo
4027 4027
 	 * @author Troex Nevelin
4028 4028
 	 **/
4029 4029
 	protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null, $jpgQuality = null) {
4030
-		if (($s = @getimagesize($path)) == false || $degree % 360 === 0) {
4030
+		if (($s = @getimagesize($path)) == false || $degree%360 === 0) {
4031 4031
 			return false;
4032 4032
 		}
4033 4033
 
4034 4034
 		$result = false;
4035 4035
 
4036 4036
 		// try lossless rotate
4037
-		if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
4038
-			$count = ($degree / 90) % 4;
4037
+		if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
4038
+			$count = ($degree/90)%4;
4039 4039
 			$exiftran = array(
4040 4040
 				1 => '-9',
4041 4041
 				2 => '-1',
@@ -4051,7 +4051,7 @@  discard block
 block discarded – undo
4051 4051
 				'exiftran -i '.$exiftran[$count].' '.$path,
4052 4052
 				'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath
4053 4053
 			);
4054
-			foreach($cmds as $cmd) {
4054
+			foreach ($cmds as $cmd) {
4055 4055
 				if ($this->procExec($cmd) === 0) {
4056 4056
 					$result = true;
4057 4057
 					break;
@@ -4091,12 +4091,12 @@  discard block
 block discarded – undo
4091 4091
 				break;
4092 4092
 
4093 4093
 			case 'gd':
4094
-				$img = $this->gdImageCreate($path,$s['mime']);
4094
+				$img = $this->gdImageCreate($path, $s['mime']);
4095 4095
 
4096 4096
 				$degree = 360 - $degree;
4097 4097
 				list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4098 4098
 				$bgcolor = imagecolorallocate($img, $r, $g, $b);
4099
-				$tmp = imageRotate($img, $degree, (int)$bgcolor);
4099
+				$tmp = imageRotate($img, $degree, (int) $bgcolor);
4100 4100
 
4101 4101
 				$result = $this->gdImage($tmp, $path, $destformat, $s['mime'], $jpgQuality);
4102 4102
 
@@ -4121,11 +4121,11 @@  discard block
 block discarded – undo
4121 4121
 	 * @return int     exit code
4122 4122
 	 * @author Alexey Sukhotin
4123 4123
 	 **/
4124
-	protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) {
4124
+	protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) {
4125 4125
 
4126 4126
 		$descriptorspec = array(
4127
-			0 => array("pipe", "r"),  // stdin
4128
-			1 => array("pipe", "w"),  // stdout
4127
+			0 => array("pipe", "r"), // stdin
4128
+			1 => array("pipe", "w"), // stdout
4129 4129
 			2 => array("pipe", "w")   // stderr
4130 4130
 		);
4131 4131
 
@@ -4182,8 +4182,8 @@  discard block
 block discarded – undo
4182 4182
 	 * @param string $mime
4183 4183
 	 * @return gd image resource identifier
4184 4184
 	 */
4185
-	protected function gdImageCreate($path,$mime){
4186
-		switch($mime){
4185
+	protected function gdImageCreate($path, $mime) {
4186
+		switch ($mime) {
4187 4187
 			case 'image/jpeg':
4188 4188
 			return imagecreatefromjpeg($path);
4189 4189
 
@@ -4208,7 +4208,7 @@  discard block
 block discarded – undo
4208 4208
 	 * @param string $mime The original image mime type
4209 4209
 	 * @param int    $jpgQuality  JEPG quality (1-100)
4210 4210
 	 */
4211
-	protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null ){
4211
+	protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null) {
4212 4212
 
4213 4213
 		if (!$jpgQuality) {
4214 4214
 			$jpgQuality = $this->options['jpgQuality'];
@@ -4232,7 +4232,7 @@  discard block
 block discarded – undo
4232 4232
 	 * @param string $destformat The Image type to use for $filename
4233 4233
 	 * @param int    $jpgQuality  JEPG quality (1-100)
4234 4234
 	 */
4235
-	protected function imagickImage($img, $filename, $destformat, $jpgQuality = null ){
4235
+	protected function imagickImage($img, $filename, $destformat, $jpgQuality = null) {
4236 4236
 
4237 4237
 		if (!$jpgQuality) {
4238 4238
 			$jpgQuality = $this->options['jpgQuality'];
@@ -4287,13 +4287,13 @@  discard block
 block discarded – undo
4287 4287
 	 * @param resource $image gd image resource
4288 4288
 	 * @param string $bgcolor background color in #rrggbb format
4289 4289
 	 */
4290
-	protected function gdImageBackground($image, $bgcolor){
4290
+	protected function gdImageBackground($image, $bgcolor) {
4291 4291
 
4292
-		if( $bgcolor == 'transparent' ){
4293
-			imagesavealpha($image,true);
4292
+		if ($bgcolor == 'transparent') {
4293
+			imagesavealpha($image, true);
4294 4294
 			$bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127);
4295 4295
 
4296
-		}else{
4296
+		} else {
4297 4297
 			list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4298 4298
 			$bgcolor1 = imagecolorallocate($image, $r, $g, $b);
4299 4299
 		}
@@ -4331,13 +4331,13 @@  discard block
 block discarded – undo
4331 4331
 	* @return int|bool
4332 4332
 	* @author Alexey Sukhotin
4333 4333
 	**/
4334
-	protected function stripos($haystack , $needle , $offset = 0) {
4334
+	protected function stripos($haystack, $needle, $offset = 0) {
4335 4335
 		if (function_exists('mb_stripos')) {
4336
-			return mb_stripos($haystack , $needle , $offset, 'UTF-8');
4336
+			return mb_stripos($haystack, $needle, $offset, 'UTF-8');
4337 4337
 		} else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) {
4338 4338
 			return mb_strpos(mb_strtolower($haystack, 'UTF-8'), mb_strtolower($needle, 'UTF-8'), $offset);
4339 4339
 		} 
4340
-		return stripos($haystack , $needle , $offset);
4340
+		return stripos($haystack, $needle, $offset);
4341 4341
 	}
4342 4342
 
4343 4343
 	/**
@@ -4387,22 +4387,22 @@  discard block
 block discarded – undo
4387 4387
 			unset($o);
4388 4388
 			$this->procExec('zip -v', $o, $c);
4389 4389
 			if ($c == 0) {
4390
-				$arcs['create']['application/zip']  = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4390
+				$arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4391 4391
 			}
4392 4392
 			unset($o);
4393 4393
 			$this->procExec('unzip --help', $o, $c);
4394 4394
 			if ($c == 0) {
4395
-				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '',  'ext' => 'zip');
4395
+				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip');
4396 4396
 			}
4397 4397
 			unset($o);
4398 4398
 			$this->procExec('rar --version', $o, $c);
4399 4399
 			if ($c == 0 || $c == 7) {
4400 4400
 				$arcs['create']['application/x-rar']  = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar');
4401
-				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y',    'ext' => 'rar');
4401
+				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar');
4402 4402
 			} else {
4403 4403
 				unset($o);
4404 4404
 				$test = $this->procExec('unrar', $o, $c);
4405
-				if ($c==0 || $c == 7) {
4405
+				if ($c == 0 || $c == 7) {
4406 4406
 					$arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar');
4407 4407
 				}
4408 4408
 			}
@@ -4424,7 +4424,7 @@  discard block
 block discarded – undo
4424 4424
 				if (empty($arcs['extract']['application/x-tar'])) {
4425 4425
 					$arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar');
4426 4426
 				}
4427
-			} else if (substr(PHP_OS,0,3) === 'WIN') {
4427
+			} else if (substr(PHP_OS, 0, 3) === 'WIN') {
4428 4428
 				// check `7z` for Windows server.
4429 4429
 				unset($o);
4430 4430
 				$this->procExec('7z', $o, $c);
@@ -4478,22 +4478,22 @@  discard block
 block discarded – undo
4478 4478
 
4479 4479
 		// normalize `/../`
4480 4480
 		$normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#';
4481
-		while(preg_match($normreg, $path)) {
4481
+		while (preg_match($normreg, $path)) {
4482 4482
 			$path = preg_replace($normreg, '$1', $path);
4483 4483
 		}
4484 4484
 		
4485 4485
 		// 'Here'
4486
-		if ($path === '' || $path === '.' . $separator) return $base;
4486
+		if ($path === '' || $path === '.'.$separator) return $base;
4487 4487
 		
4488 4488
 		// Absolute path
4489 4489
 		if ($path[0] === $separator || strpos($path, $systemroot) === 0) {
4490 4490
 			return $path;
4491 4491
 		}
4492 4492
 		
4493
-		$preg_separator = '#' . $sepquoted . '#';
4493
+		$preg_separator = '#'.$sepquoted.'#';
4494 4494
 		
4495 4495
 		// Relative path from 'Here'
4496
-		if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) {
4496
+		if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) {
4497 4497
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4498 4498
 			if ($arrn[0] !== '.') {
4499 4499
 				array_unshift($arrn, '.');
@@ -4507,12 +4507,11 @@  discard block
 block discarded – undo
4507 4507
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4508 4508
 			$arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY);
4509 4509
 		
4510
-			while (! empty($arrn) && $arrn[0] === '..') {
4510
+			while (!empty($arrn) && $arrn[0] === '..') {
4511 4511
 				array_shift($arrn);
4512 4512
 				array_pop($arrp);
4513 4513
 			}
4514
-			$path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) :
4515
-				(! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot);
4514
+			$path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot);
4516 4515
 		}
4517 4516
 		
4518 4517
 		return $path;
@@ -4530,7 +4529,7 @@  discard block
 block discarded – undo
4530 4529
 			@chmod($dir, 0777);
4531 4530
 			foreach (array_diff(scandir($dir), array('.', '..')) as $file) {
4532 4531
 				@set_time_limit(30);
4533
-				$path = $dir . DIRECTORY_SEPARATOR . $file;
4532
+				$path = $dir.DIRECTORY_SEPARATOR.$file;
4534 4533
 				if (!is_link($dir) && is_dir($path)) {
4535 4534
 					$this->rmdirRecursive($path);
4536 4535
 				} else {
@@ -4617,22 +4616,22 @@  discard block
 block discarded – undo
4617 4616
 		try {
4618 4617
 			if ($start = is_string($zipPath)) {
4619 4618
 				$zip = new ZipArchive();
4620
-				if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) {
4619
+				if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) {
4621 4620
 					$zip = false;
4622 4621
 				}
4623 4622
 			} else {
4624 4623
 				$zip = $zipPath;
4625 4624
 			}
4626 4625
 			if ($zip) {
4627
-				foreach($files as $file) {
4628
-					$path = $dir . DIRECTORY_SEPARATOR . $file;
4626
+				foreach ($files as $file) {
4627
+					$path = $dir.DIRECTORY_SEPARATOR.$file;
4629 4628
 					if (is_dir($path)) {
4630 4629
 						$zip->addEmptyDir($file);
4631 4630
 						$_files = array();
4632 4631
 						if ($handle = opendir($path)) {
4633 4632
 							while (false !== ($entry = readdir($handle))) {
4634 4633
 								if ($entry !== "." && $entry !== "..") {
4635
-									$_files[] = $file . DIRECTORY_SEPARATOR . $entry;
4634
+									$_files[] = $file.DIRECTORY_SEPARATOR.$entry;
4636 4635
 								}
4637 4636
 							}
4638 4637
 							closedir($handle);
@@ -4817,7 +4816,7 @@  discard block
 block discarded – undo
4817 4816
 	 * @return resource|false
4818 4817
 	 * @author Dmitry (dio) Levashov
4819 4818
 	 **/
4820
-	abstract protected function _fopen($path, $mode="rb");
4819
+	abstract protected function _fopen($path, $mode = "rb");
4821 4820
 	
4822 4821
 	/**
4823 4822
 	 * Close opened file
@@ -4827,7 +4826,7 @@  discard block
 block discarded – undo
4827 4826
 	 * @return bool
4828 4827
 	 * @author Dmitry (dio) Levashov
4829 4828
 	 **/
4830
-	abstract protected function _fclose($fp, $path='');
4829
+	abstract protected function _fclose($fp, $path = '');
4831 4830
 	
4832 4831
 	/********************  file/dir manipulations *************************/
4833 4832
 	
Please login to merge, or discard this patch.