Completed
Push — 16.1 ( 96aac5...d6bfd0 )
by Hadi
18:58 queued 02:33
created
api/src/Vfs/StreamWrapper.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -405,10 +405,10 @@  discard block
 block discarded – undo
405 405
  	 * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite!
406 406
  	 *
407 407
  	 * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<'))
408
-  	 * {
408
+ 	 * {
409 409
  	 * 		$eof = !$eof;
410 410
  	 * }
411
-  	 *
411
+ 	 *
412 412
  	 * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise
413 413
  	 */
414 414
 	function stream_eof ( )
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1));
907 907
 
908 908
 		while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) &&
909
-		       ($url = Vfs::dirname($url)))
909
+			   ($url = Vfs::dirname($url)))
910 910
 		{
911 911
 			if (($stat = $this->url_stat($url,0,true,false)))
912 912
 			{
Please login to merge, or discard this patch.
Spacing   +133 added lines, -134 removed lines patch added patch discarded remove patch
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 	 * @param array|boolean &$stat=null on return: stat of existing file or false for non-existing files
158 158
 	 * @return string|boolean false if the url cant be resolved, should not happen if fstab has a root entry
159 159
 	 */
160
-	function resolve_url_symlinks($_path,$file_exists=true,$resolve_last_symlink=true,&$stat=null)
160
+	function resolve_url_symlinks($_path, $file_exists = true, $resolve_last_symlink = true, &$stat = null)
161 161
 	{
162 162
 		$path = self::get_path($_path);
163 163
 
164
-		if (!($stat = $this->url_stat($path,$resolve_last_symlink?0:STREAM_URL_STAT_LINK)) && !$file_exists)
164
+		if (!($stat = $this->url_stat($path, $resolve_last_symlink ? 0 : STREAM_URL_STAT_LINK)) && !$file_exists)
165 165
 		{
166 166
 			$url = null;
167
-			$stat = self::check_symlink_components($path,0,$url);
167
+			$stat = self::check_symlink_components($path, 0, $url);
168 168
 			if (self::LOG_LEVEL > 1) $log = " (check_symlink_components('$path',0,'$url') = $stat)";
169 169
 		}
170 170
 		else
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 			$url = $stat['url'];
173 173
 		}
174 174
 		// if the url resolves to a symlink to the vfs, resolve this vfs:// url direct
175
-		if ($url && Vfs::parse_url($url,PHP_URL_SCHEME) == self::SCHEME)
175
+		if ($url && Vfs::parse_url($url, PHP_URL_SCHEME) == self::SCHEME)
176 176
 		{
177
-			$url = self::resolve_url(Vfs::parse_url($url,PHP_URL_PATH));
177
+			$url = self::resolve_url(Vfs::parse_url($url, PHP_URL_PATH));
178 178
 		}
179 179
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,file_exists=$file_exists,resolve_last_symlink=$resolve_last_symlink) = '$url'$log");
180 180
 		return $url;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @param boolean $fix_url_query =false true append relativ path to url query parameter, default not
198 198
 	 * @return string|boolean false if the url cant be resolved, should not happen if fstab has a root entry
199 199
 	 */
200
-	static function resolve_url($_path,$do_symlink=true,$use_symlinkcache=true,$replace_user_pass_host=true,$fix_url_query=false)
200
+	static function resolve_url($_path, $do_symlink = true, $use_symlinkcache = true, $replace_user_pass_host = true, $fix_url_query = false)
201 201
 	{
202 202
 		$path = self::get_path($_path);
203 203
 
@@ -210,52 +210,52 @@  discard block
 block discarded – undo
210 210
 		// check if we can already resolve path (or a part of it) with a known symlinks
211 211
 		if ($use_symlinkcache)
212 212
 		{
213
-			$path = self::symlinkCache_resolve($path,$do_symlink);
213
+			$path = self::symlinkCache_resolve($path, $do_symlink);
214 214
 		}
215 215
 		// setting default user, passwd and domain, if it's not contained int the url
216
-		static $defaults=null;
216
+		static $defaults = null;
217 217
 		if (is_null($defaults))
218 218
 		{
219 219
 			$defaults = array(
220 220
 				'user' => $GLOBALS['egw_info']['user']['account_lid'],
221 221
 				'pass' => urlencode($GLOBALS['egw_info']['user']['passwd']),
222 222
 				'host' => $GLOBALS['egw_info']['user']['domain'],
223
-				'home' => str_replace(array('\\\\','\\'),array('','/'),$GLOBALS['egw_info']['user']['homedirectory']),
223
+				'home' => str_replace(array('\\\\', '\\'), array('', '/'), $GLOBALS['egw_info']['user']['homedirectory']),
224 224
 			);
225 225
 		}
226
-		$parts = array_merge(Vfs::parse_url($path),$defaults);
227
-		if (!$parts['host']) $parts['host'] = 'default';	// otherwise we get an invalid url (scheme:///path/to/something)!
226
+		$parts = array_merge(Vfs::parse_url($path), $defaults);
227
+		if (!$parts['host']) $parts['host'] = 'default'; // otherwise we get an invalid url (scheme:///path/to/something)!
228 228
 
229 229
 		if (!empty($parts['scheme']) && $parts['scheme'] != self::SCHEME)
230 230
 		{
231 231
 			if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$path' (path is already an url)");
232
-			return $path;	// path is already a non-vfs url --> nothing to do
232
+			return $path; // path is already a non-vfs url --> nothing to do
233 233
 		}
234 234
 		if (empty($parts['path'])) $parts['path'] = '/';
235 235
 
236
-		foreach(array_reverse(self::$fstab) as $mounted => $url)
236
+		foreach (array_reverse(self::$fstab) as $mounted => $url)
237 237
 		{
238
-			if ($mounted == '/' || $mounted == $parts['path'] || $mounted.'/' == substr($parts['path'],0,strlen($mounted)+1))
238
+			if ($mounted == '/' || $mounted == $parts['path'] || $mounted.'/' == substr($parts['path'], 0, strlen($mounted) + 1))
239 239
 			{
240
-				$scheme = Vfs::parse_url($url,PHP_URL_SCHEME);
241
-				if (is_null(self::$wrappers) || !in_array($scheme,self::$wrappers))
240
+				$scheme = Vfs::parse_url($url, PHP_URL_SCHEME);
241
+				if (is_null(self::$wrappers) || !in_array($scheme, self::$wrappers))
242 242
 				{
243 243
 					self::load_wrapper($scheme);
244 244
 				}
245
-				if (($relative = substr($parts['path'],strlen($mounted))))
245
+				if (($relative = substr($parts['path'], strlen($mounted))))
246 246
 				{
247
-					$url = Vfs::concat($url,$relative);
247
+					$url = Vfs::concat($url, $relative);
248 248
 				}
249 249
 				// if url contains url parameter, eg. from filesystem streamwrapper, we need to append relative path here too
250 250
 				$matches = null;
251 251
 				if ($fix_url_query && preg_match('|([?&]url=)([^&]+)|', $url, $matches))
252 252
 				{
253
-					$url = str_replace($matches[0], $matches[1].Vfs::concat($matches[2], substr($parts['path'],strlen($mounted))), $url);
253
+					$url = str_replace($matches[0], $matches[1].Vfs::concat($matches[2], substr($parts['path'], strlen($mounted))), $url);
254 254
 				}
255 255
 
256 256
 				if ($replace_user_pass_host)
257 257
 				{
258
-					$url = str_replace(array('$user','$pass','$host','$home'),array($parts['user'],$parts['pass'],$parts['host'],$parts['home']),$url);
258
+					$url = str_replace(array('$user', '$pass', '$host', '$home'), array($parts['user'], $parts['pass'], $parts['host'], $parts['home']), $url);
259 259
 				}
260 260
 				if ($parts['query']) $url .= '?'.$parts['query'];
261 261
 				if ($parts['fragment']) $url .= '#'.$parts['fragment'];
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 			}
269 269
 		}
270 270
 		if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path') can't resolve path!\n");
271
-		trigger_error(__METHOD__."($path) can't resolve path!\n",E_USER_WARNING);
271
+		trigger_error(__METHOD__."($path) can't resolve path!\n", E_USER_WARNING);
272 272
 		return false;
273 273
 	}
274 274
 
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 	 */
281 281
 	static function mount_url($fullurl)
282 282
 	{
283
-		foreach(array_reverse(self::$fstab) as $url)
283
+		foreach (array_reverse(self::$fstab) as $url)
284 284
 		{
285
-			list($url_no_query) = explode('?',$url);
286
-			if (substr($fullurl,0,1+strlen($url_no_query)) === $url_no_query.'/')
285
+			list($url_no_query) = explode('?', $url);
286
+			if (substr($fullurl, 0, 1 + strlen($url_no_query)) === $url_no_query.'/')
287 287
 			{
288 288
 				return $url;
289 289
 			}
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
 	 * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set
304 304
 	 * @return boolean true if the ressource was opened successful, otherwise false
305 305
 	 */
306
-	function stream_open ( $path, $mode, $options, &$opened_path )
306
+	function stream_open($path, $mode, $options, &$opened_path)
307 307
 	{
308
-		unset($options,$opened_path);	// not used but required by function signature
308
+		unset($options, $opened_path); // not used but required by function signature
309 309
 		$this->opened_stream = null;
310 310
 
311 311
 		$stat = null;
312
-		if (!($url = $this->resolve_url_symlinks($path,$mode[0]=='r',true,$stat)))
312
+		if (!($url = $this->resolve_url_symlinks($path, $mode[0] == 'r', true, $stat)))
313 313
 		{
314 314
 			return false;
315 315
 		}
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	 *
346 346
 	 * VFS calls either "vfs_read", "vfs_added" or "vfs_modified" hook
347 347
 	 */
348
-	function stream_close ( )
348
+	function stream_close( )
349 349
 	{
350 350
 		$ret = fclose($this->opened_stream);
351 351
 		// clear PHP's stat cache, it contains wrong size of just closed file,
@@ -355,12 +355,11 @@  discard block
 block discarded – undo
355 355
 		if (!class_exists('setup_process', false))
356 356
 		{
357 357
 			Api\Hooks::process(array(
358
-				'location' => str_replace('b','',$this->opened_stream_mode) == 'r' ? 'vfs_read' :
359
-					($this->opened_stream_is_new ? 'vfs_added' : 'vfs_modified'),
358
+				'location' => str_replace('b', '', $this->opened_stream_mode) == 'r' ? 'vfs_read' : ($this->opened_stream_is_new ? 'vfs_added' : 'vfs_modified'),
360 359
 				'path' => $this->opened_stream_path,
361 360
 				'mode' => $this->opened_stream_mode,
362 361
 				'url'  => $this->opened_stream_url,
363
-			),'',true);
362
+			), '', true);
364 363
 		}
365 364
 		$this->opened_stream = $this->opened_stream_mode = $this->opened_stream_path = $this->opened_stream_url = $this->opened_stream_is_new = null;
366 365
 
@@ -378,9 +377,9 @@  discard block
 block discarded – undo
378 377
 	 * @param int $count
379 378
 	 * @return string/false up to count bytes read or false on EOF
380 379
 	 */
381
-	function stream_read ( $count )
380
+	function stream_read($count)
382 381
 	{
383
-		return fread($this->opened_stream,$count);
382
+		return fread($this->opened_stream, $count);
384 383
 	}
385 384
 
386 385
 	/**
@@ -394,9 +393,9 @@  discard block
 block discarded – undo
394 393
 	 * @param string $data
395 394
 	 * @return integer
396 395
 	 */
397
-	function stream_write ( $data )
396
+	function stream_write($data)
398 397
 	{
399
-		return fwrite($this->opened_stream,$data);
398
+		return fwrite($this->opened_stream, $data);
400 399
 	}
401 400
 
402 401
  	/**
@@ -411,7 +410,7 @@  discard block
 block discarded – undo
411 410
   	 *
412 411
  	 * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise
413 412
  	 */
414
-	function stream_eof ( )
413
+	function stream_eof( )
415 414
 	{
416 415
 		return feof($this->opened_stream);
417 416
 	}
@@ -421,7 +420,7 @@  discard block
 block discarded – undo
421 420
 	 *
422 421
 	 * @return integer current read/write position of the stream
423 422
 	 */
424
- 	function stream_tell ( )
423
+ 	function stream_tell( )
425 424
  	{
426 425
  		return ftell($this->opened_stream);
427 426
  	}
@@ -438,9 +437,9 @@  discard block
 block discarded – undo
438 437
  	 * 							SEEK_END - 2 - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.)
439 438
  	 * @return boolean TRUE if the position was updated, FALSE otherwise.
440 439
  	 */
441
-	function stream_seek ( $offset, $whence )
440
+	function stream_seek($offset, $whence)
442 441
 	{
443
-		return !fseek($this->opened_stream,$offset,$whence);	// fseek returns 0 on success and -1 on failure
442
+		return !fseek($this->opened_stream, $offset, $whence); // fseek returns 0 on success and -1 on failure
444 443
 	}
445 444
 
446 445
 	/**
@@ -450,7 +449,7 @@  discard block
 block discarded – undo
450 449
 	 *
451 450
 	 * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored.
452 451
 	 */
453
-	function stream_flush ( )
452
+	function stream_flush( )
454 453
 	{
455 454
 		return fflush($this->opened_stream);
456 455
 	}
@@ -469,7 +468,7 @@  discard block
 block discarded – undo
469 468
 	 *
470 469
 	 * @return array containing the same values as appropriate for the stream.
471 470
 	 */
472
-	function stream_stat ( )
471
+	function stream_stat( )
473 472
 	{
474 473
 		return fstat($this->opened_stream);
475 474
 	}
@@ -498,10 +497,10 @@  discard block
 block discarded – undo
498 497
 		}
499 498
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path', $option, ".array2string($value).") url=$url");
500 499
 
501
-		switch($option)
500
+		switch ($option)
502 501
 		{
503 502
 			case STREAM_META_TOUCH:
504
-				return touch($url, $value[0]);	// atime is not supported
503
+				return touch($url, $value[0]); // atime is not supported
505 504
 
506 505
 			case STREAM_META_ACCESS:
507 506
 				return chmod($url, $value);
@@ -532,9 +531,9 @@  discard block
 block discarded – undo
532 531
 	 * @param string $path
533 532
 	 * @return boolean TRUE on success or FALSE on failure
534 533
 	 */
535
-	function unlink ( $path )
534
+	function unlink($path)
536 535
 	{
537
-		if (!($url = $this->resolve_url_symlinks($path,true,false)))	// true,false file need to exist, but do not resolve last component
536
+		if (!($url = $this->resolve_url_symlinks($path, true, false)))	// true,false file need to exist, but do not resolve last component
538 537
 		{
539 538
 			return false;
540 539
 		}
@@ -555,7 +554,7 @@  discard block
 block discarded – undo
555 554
 				'path' => $path[0] == '/' ? $path : Vfs::parse_url($path, PHP_URL_PATH),
556 555
 				'url'  => $url,
557 556
 				'stat' => $stat,
558
-			),'',true);
557
+			), '', true);
559 558
 		}
560 559
 		return $ok;
561 560
 	}
@@ -573,26 +572,26 @@  discard block
 block discarded – undo
573 572
 	 * @return boolean TRUE on success or FALSE on failure
574 573
 	 * @throws Exception\ProtectedDirectory if trying to delete a protected directory, see Vfs::isProtected()
575 574
 	 */
576
-	function rename ( $path_from, $path_to )
575
+	function rename($path_from, $path_to)
577 576
 	{
578 577
 		if (Vfs::isProtectedDir($path_from))
579 578
 		{
580 579
 			throw new Exception\ProtectedDirectory("Renaming protected directory '$path_from' rejected!");
581 580
 		}
582
-		if (!($url_from = $this->resolve_url_symlinks($path_from,true,false)) ||
583
-			!($url_to = $this->resolve_url_symlinks($path_to,false)))
581
+		if (!($url_from = $this->resolve_url_symlinks($path_from, true, false)) ||
582
+			!($url_to = $this->resolve_url_symlinks($path_to, false)))
584 583
 		{
585 584
 			return false;
586 585
 		}
587 586
 		// if file is moved from one filesystem / wrapper to an other --> copy it (rename fails cross wrappers)
588
-		if (Vfs::parse_url($url_from,PHP_URL_SCHEME) == Vfs::parse_url($url_to,PHP_URL_SCHEME))
587
+		if (Vfs::parse_url($url_from, PHP_URL_SCHEME) == Vfs::parse_url($url_to, PHP_URL_SCHEME))
589 588
 		{
590 589
 			self::symlinkCache_remove($path_from);
591
-			$ret = rename($url_from,$url_to);
590
+			$ret = rename($url_from, $url_to);
592 591
 		}
593
-		elseif (($from = fopen($url_from,'r')) && ($to = fopen($url_to,'w')))
592
+		elseif (($from = fopen($url_from, 'r')) && ($to = fopen($url_to, 'w')))
594 593
 		{
595
-			$ret = stream_copy_to_stream($from,$to) !== false;
594
+			$ret = stream_copy_to_stream($from, $to) !== false;
596 595
 			fclose($from);
597 596
 			fclose($to);
598 597
 			if ($ret) $this->unlink($path_from);
@@ -614,7 +613,7 @@  discard block
 block discarded – undo
614 613
 				'to' => $path_to[0] == '/' ? $path_to : Vfs::parse_url($path_to, PHP_URL_PATH),
615 614
 				'url_from' => $url_from,
616 615
 				'url_to' => $url_to,
617
-			),'',true);
616
+			), '', true);
618 617
 		}
619 618
 		return $ret;
620 619
 	}
@@ -630,14 +629,14 @@  discard block
 block discarded – undo
630 629
 	 * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE
631 630
 	 * @return boolean TRUE on success or FALSE on failure
632 631
 	 */
633
-	function mkdir ( $path, $mode, $options )
632
+	function mkdir($path, $mode, $options)
634 633
 	{
635
-		if (!($url = $this->resolve_url_symlinks($path,false)))	// false = directory does not need to exists
634
+		if (!($url = $this->resolve_url_symlinks($path, false)))	// false = directory does not need to exists
636 635
 		{
637 636
 			return false;
638 637
 		}
639 638
 		// check if recursive option is set and needed
640
-		if (($options & STREAM_MKDIR_RECURSIVE) &&
639
+		if (($options&STREAM_MKDIR_RECURSIVE) &&
641 640
 			($parent_url = Vfs::dirname($url)) &&
642 641
 			!($this->url_stat($parent_url, STREAM_URL_STAT_QUIET)) &&
643 642
 			Vfs::parse_url($parent_url, PHP_URL_PATH) !== '/')
@@ -647,7 +646,7 @@  discard block
 block discarded – undo
647 646
 		// unset it now, as it was handled above
648 647
 		$options &= ~STREAM_MKDIR_RECURSIVE;
649 648
 
650
-		$ret = mkdir($url,$mode,$options);
649
+		$ret = mkdir($url, $mode, $options);
651 650
 
652 651
 		// call "vfs_mkdir" hook
653 652
 		if ($ret && !class_exists('setup_process', false))
@@ -656,7 +655,7 @@  discard block
 block discarded – undo
656 655
 				'location' => 'vfs_mkdir',
657 656
 				'path' => $path[0] == '/' ? $path : Vfs::parse_url($path, PHP_URL_PATH),
658 657
 				'url' => $url,
659
-			),'',true);
658
+			), '', true);
660 659
 		}
661 660
 		return $ret;
662 661
 	}
@@ -672,13 +671,13 @@  discard block
 block discarded – undo
672 671
 	 * @return boolean TRUE on success or FALSE on failure.
673 672
 	 * @throws Exception\ProtectedDirectory if trying to delete a protected directory, see Vfs::isProtected()
674 673
 	 */
675
-	function rmdir ( $path, $options )
674
+	function rmdir($path, $options)
676 675
 	{
677 676
 		if (Vfs::isProtectedDir($path))
678 677
 		{
679 678
 			throw new Exception\ProtectedDirectory("Deleting protected directory '$path' rejected!");
680 679
 		}
681
-		unset($options);	// not uses but required by function signature
680
+		unset($options); // not uses but required by function signature
682 681
 		if (!($url = $this->resolve_url_symlinks($path)))
683 682
 		{
684 683
 			return false;
@@ -700,7 +699,7 @@  discard block
 block discarded – undo
700 699
 				'path' => $path[0] == '/' ? $path : Vfs::parse_url($path, PHP_URL_PATH),
701 700
 				'url' => $url,
702 701
 				'stat' => $stat,
703
-			),'',true);
702
+			), '', true);
704 703
 		}
705 704
 		return $ok;
706 705
 	}
@@ -711,7 +710,7 @@  discard block
 block discarded – undo
711 710
 	 * @param string $path URL that was passed to opendir() and that this object is expected to explore.
712 711
 	 * @return booelan
713 712
 	 */
714
-	function dir_opendir ( $path, $options )
713
+	function dir_opendir($path, $options)
715 714
 	{
716 715
 		$this->opened_dir = $this->extra_dirs = null;
717 716
 		$this->dir_url_params = array();
@@ -728,15 +727,15 @@  discard block
 block discarded – undo
728 727
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!");
729 728
 			return false;
730 729
 		}
731
-		$this->opened_dir_writable = Vfs::check_access($this->opened_dir_url,Vfs::WRITABLE);
730
+		$this->opened_dir_writable = Vfs::check_access($this->opened_dir_url, Vfs::WRITABLE);
732 731
 		// check our fstab if we need to add some of the mountpoints
733
-		$basepath = Vfs::parse_url($path,PHP_URL_PATH);
734
-		foreach(array_keys(self::$fstab) as $mounted)
732
+		$basepath = Vfs::parse_url($path, PHP_URL_PATH);
733
+		foreach (array_keys(self::$fstab) as $mounted)
735 734
 		{
736 735
 			if (((Vfs::dirname($mounted) == $basepath || Vfs::dirname($mounted).'/' == $basepath) && $mounted != '/') &&
737 736
 				// only return children readable by the user, if dir is not writable
738 737
 				(!self::HIDE_UNREADABLES || $this->opened_dir_writable ||
739
-					Vfs::check_access($mounted,Vfs::READABLE)))
738
+					Vfs::check_access($mounted, Vfs::READABLE)))
740 739
 			{
741 740
 				$this->extra_dirs[] = basename($mounted);
742 741
 			}
@@ -775,24 +774,24 @@  discard block
 block discarded – undo
775 774
 	 * @param boolean $check_symlink_components =true check if path contains symlinks in path components other then the last one
776 775
 	 * @return array
777 776
 	 */
778
-	function url_stat ( $path, $flags, $try_create_home=false, $check_symlink_components=true, $check_symlink_depth=self::MAX_SYMLINK_DEPTH, $try_reconnect=true )
777
+	function url_stat($path, $flags, $try_create_home = false, $check_symlink_components = true, $check_symlink_depth = self::MAX_SYMLINK_DEPTH, $try_reconnect = true)
779 778
 	{
780
-		if (!($url = self::resolve_url($path,!($flags & STREAM_URL_STAT_LINK), $check_symlink_components)))
779
+		if (!($url = self::resolve_url($path, !($flags&STREAM_URL_STAT_LINK), $check_symlink_components)))
781 780
 		{
782 781
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) can NOT resolve path!");
783 782
 			return false;
784 783
 		}
785 784
 
786 785
 		try {
787
-			if ($flags & STREAM_URL_STAT_LINK)
786
+			if ($flags&STREAM_URL_STAT_LINK)
788 787
 			{
789
-				$stat = @lstat($url);	// suppressed the stat failed warnings
788
+				$stat = @lstat($url); // suppressed the stat failed warnings
790 789
 			}
791 790
 			else
792 791
 			{
793
-				$stat = @stat($url);	// suppressed the stat failed warnings
792
+				$stat = @stat($url); // suppressed the stat failed warnings
794 793
 
795
-				if ($stat && ($stat['mode'] & self::MODE_LINK))
794
+				if ($stat && ($stat['mode']&self::MODE_LINK))
796 795
 				{
797 796
 					if (!$check_symlink_depth)
798 797
 					{
@@ -803,25 +802,25 @@  discard block
 block discarded – undo
803 802
 					{
804 803
 						if ($lpath[0] != '/')	// concat relative path
805 804
 						{
806
-							$lpath = Vfs::concat(Vfs::parse_url($path,PHP_URL_PATH),'../'.$lpath);
805
+							$lpath = Vfs::concat(Vfs::parse_url($path, PHP_URL_PATH), '../'.$lpath);
807 806
 						}
808
-						$u_query = parse_url($url,PHP_URL_QUERY);
807
+						$u_query = parse_url($url, PHP_URL_QUERY);
809 808
 						$url = Vfs::PREFIX.$lpath;
810 809
 						if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$flags) symlif (substr($path,-1) == '/' && $path != '/') $path = substr($path,0,-1);	// remove trailing slash eg. added by WebDAVink found and resolved to $url");
811 810
 						// try reading the stat of the link
812
-						if (($stat = $this->url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth-1)))
811
+						if (($stat = $this->url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth - 1)))
813 812
 						{
814 813
 							$stat_query = parse_url($stat['url'], PHP_URL_QUERY);
815
-							if($u_query || $stat_query)
814
+							if ($u_query || $stat_query)
816 815
 							{
817 816
 								$stat_url = parse_url($stat['url']);
818
-								parse_str($stat_query,$stat_query);
817
+								parse_str($stat_query, $stat_query);
819 818
 								parse_str($u_query, $u_query);
820 819
 								$stat_query = http_build_query(array_merge($stat_query, $u_query));
821 820
 								$stat['url'] = $stat_url['scheme'].'://'.$stat_url['host'].$stat_url['path'].'?'.$stat_query;
822 821
 							}
823
-							if(isset($stat['url'])) $url = $stat['url'];	// if stat returns an url use that, as there might be more links ...
824
-							self::symlinkCache_add($path,$url);
822
+							if (isset($stat['url'])) $url = $stat['url']; // if stat returns an url use that, as there might be more links ...
823
+							self::symlinkCache_add($path, $url);
825 824
 						}
826 825
 					}
827 826
 				}
@@ -841,7 +840,7 @@  discard block
 block discarded – undo
841 840
 			throw $e;
842 841
 		}
843 842
 		// check if a failed url_stat was for a home dir, in that case silently create it
844
-		if (!$stat && $try_create_home && Vfs::dirname(Vfs::parse_url($path,PHP_URL_PATH)) == '/home' &&
843
+		if (!$stat && $try_create_home && Vfs::dirname(Vfs::parse_url($path, PHP_URL_PATH)) == '/home' &&
845 844
 			($id = $GLOBALS['egw']->accounts->name2id(basename($path))) &&
846 845
 			$GLOBALS['egw']->accounts->id2name($id) == basename($path))	// make sure path has the right case!
847 846
 		{
@@ -851,25 +850,25 @@  discard block
 block discarded – undo
851 850
 				'account_lid' => basename($path),
852 851
 				'account_name' => basename($path),
853 852
 			);
854
-			call_user_func(array(__NAMESPACE__.'\\Hooks',$hook_data['location']),$hook_data);
853
+			call_user_func(array(__NAMESPACE__.'\\Hooks', $hook_data['location']), $hook_data);
855 854
 			unset($hook_data);
856
-			$stat = $this->url_stat($path,$flags,false);
855
+			$stat = $this->url_stat($path, $flags, false);
857 856
 		}
858 857
 		$query = parse_url($url, PHP_URL_QUERY);
859 858
 		if (!$stat && $check_symlink_components)	// check if there's a symlink somewhere inbetween the path
860 859
 		{
861
-			$stat = self::check_symlink_components($path,$flags,$url);
862
-			if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path,$stat['url']);
860
+			$stat = self::check_symlink_components($path, $flags, $url);
861
+			if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path, $stat['url']);
863 862
 		}
864
-		elseif(is_array($stat) && !isset($stat['url']))
863
+		elseif (is_array($stat) && !isset($stat['url']))
865 864
 		{
866 865
 			$stat['url'] = $url;
867 866
 		}
868
-		if (($stat['mode'] & 0222) && self::url_is_readonly($stat['url']))
867
+		if (($stat['mode']&0222) && self::url_is_readonly($stat['url']))
869 868
 		{
870 869
 			$stat['mode'] &= ~0222;
871 870
 		}
872
-		if($stat['url'] && $query && strpos($stat['url'],'?'.$query)===false)
871
+		if ($stat['url'] && $query && strpos($stat['url'], '?'.$query) === false)
873 872
 		{
874 873
 			$stat['url'] .= '?'.$query;
875 874
 		}
@@ -896,7 +895,7 @@  discard block
 block discarded – undo
896 895
 	 * @param string &$url=null already resolved path
897 896
 	 * @return array|boolean stat array or false if not found
898 897
 	 */
899
-	private function check_symlink_components($path,$flags=0,&$url=null)
898
+	private function check_symlink_components($path, $flags = 0, &$url = null)
900 899
 	{
901 900
 		if (is_null($url) && !($url = self::resolve_url($path)))
902 901
 		{
@@ -908,7 +907,7 @@  discard block
 block discarded – undo
908 907
 		while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) &&
909 908
 		       ($url = Vfs::dirname($url)))
910 909
 		{
911
-			if (($stat = $this->url_stat($url,0,true,false)))
910
+			if (($stat = $this->url_stat($url, 0, true, false)))
912 911
 			{
913 912
 				if (is_link($url) && ($lpath = Vfs::readlink($url)))
914 913
 				{
@@ -916,20 +915,20 @@  discard block
 block discarded – undo
916 915
 
917 916
 					if ($lpath[0] != '/')
918 917
 					{
919
-						$lpath = Vfs::concat(Vfs::parse_url($url,PHP_URL_PATH),'../'.$lpath);
918
+						$lpath = Vfs::concat(Vfs::parse_url($url, PHP_URL_PATH), '../'.$lpath);
920 919
 					}
921 920
 					//self::symlinkCache_add($path,Vfs::PREFIX.$lpath);
922
-					$url = Vfs::PREFIX.Vfs::concat($lpath,$rel_path);
921
+					$url = Vfs::PREFIX.Vfs::concat($lpath, $rel_path);
923 922
 					if (self::LOG_LEVEL > 1) error_log("$log --> lpath='$lpath', url='$url'");
924
-					return $this->url_stat($url,$flags);
923
+					return $this->url_stat($url, $flags);
925 924
 				}
926
-				$url = Vfs::concat($url,$rel_path);
925
+				$url = Vfs::concat($url, $rel_path);
927 926
 				if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning null");
928 927
 				return null;
929 928
 			}
930 929
 		}
931 930
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning false");
932
-		return false;	// $path does not exist
931
+		return false; // $path does not exist
933 932
 	}
934 933
 
935 934
 	/**
@@ -945,13 +944,13 @@  discard block
 block discarded – undo
945 944
 	 * @param string $_path vfs path
946 945
 	 * @param string $target target path
947 946
 	 */
948
-	static protected function symlinkCache_add($_path,$target)
947
+	static protected function symlinkCache_add($_path, $target)
949 948
 	{
950 949
 		$path = self::get_path($_path);
951 950
 
952
-		if (isset(self::$symlink_cache[$path])) return;	// nothing to do
951
+		if (isset(self::$symlink_cache[$path])) return; // nothing to do
953 952
 
954
-		if ($target[0] != '/') $target = Vfs::parse_url($target,PHP_URL_PATH);
953
+		if ($target[0] != '/') $target = Vfs::parse_url($target, PHP_URL_PATH);
955 954
 
956 955
 		self::$symlink_cache[$path] = $target;
957 956
 
@@ -985,25 +984,25 @@  discard block
 block discarded – undo
985 984
 	 * @param boolean $do_symlink =true is a direct match allowed, default yes (must be false for a lstat or readlink!)
986 985
 	 * @return string target or path, if path not found
987 986
 	 */
988
-	static public function symlinkCache_resolve($_path,$do_symlink=true)
987
+	static public function symlinkCache_resolve($_path, $do_symlink = true)
989 988
 	{
990 989
 		// remove vfs scheme, but no other schemes (eg. filesystem!)
991 990
 		$path = self::get_path($_path);
992 991
 
993 992
 		$strlen_path = strlen($path);
994 993
 
995
-		foreach(self::$symlink_cache as $p => $t)
994
+		foreach (self::$symlink_cache as $p => $t)
996 995
 		{
997
-			if (($strlen_p = strlen($p)) > $strlen_path) continue;	// $path can NOT start with $p
996
+			if (($strlen_p = strlen($p)) > $strlen_path) continue; // $path can NOT start with $p
998 997
 
999 998
 			if ($path == $p)
1000 999
 			{
1001 1000
 				if ($do_symlink) $target = $t;
1002 1001
 				break;
1003 1002
 			}
1004
-			elseif (substr($path,0,$strlen_p+1) == $p.'/')
1003
+			elseif (substr($path, 0, $strlen_p + 1) == $p.'/')
1005 1004
 			{
1006
-				$target = $t . substr($path,$strlen_p);
1005
+				$target = $t.substr($path, $strlen_p);
1007 1006
 				break;
1008 1007
 			}
1009 1008
 		}
@@ -1031,7 +1030,7 @@  discard block
 block discarded – undo
1031 1030
 	 *
1032 1031
 	 * @return string
1033 1032
 	 */
1034
-	function dir_readdir ( )
1033
+	function dir_readdir( )
1035 1034
 	{
1036 1035
 		if ($this->extra_dirs && count($this->extra_dirs) > $this->extra_dir_ptr)
1037 1036
 		{
@@ -1043,10 +1042,10 @@  discard block
 block discarded – undo
1043 1042
 			do {
1044 1043
 				$file = readdir($this->opened_dir);
1045 1044
 			}
1046
-			while($file !== false &&
1047
-				(is_array($this->extra_dirs) && in_array($file,$this->extra_dirs) || // do NOT return extra_dirs twice
1045
+			while ($file !== false &&
1046
+				(is_array($this->extra_dirs) && in_array($file, $this->extra_dirs) || // do NOT return extra_dirs twice
1048 1047
 				self::HIDE_UNREADABLES && !$this->opened_dir_writable &&
1049
-				!Vfs::check_access(Vfs::concat($this->opened_dir_url,$file),Vfs::READABLE)));
1048
+				!Vfs::check_access(Vfs::concat($this->opened_dir_url, $file), Vfs::READABLE)));
1050 1049
 		}
1051 1050
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $this->opened_dir ) = '$file'");
1052 1051
 		return $file;
@@ -1060,7 +1059,7 @@  discard block
 block discarded – undo
1060 1059
 	 *
1061 1060
 	 * @return boolean
1062 1061
 	 */
1063
-	function dir_rewinddir ( )
1062
+	function dir_rewinddir( )
1064 1063
 	{
1065 1064
 		$this->extra_dir_ptr = 0;
1066 1065
 
@@ -1074,7 +1073,7 @@  discard block
 block discarded – undo
1074 1073
 	 *
1075 1074
 	 * @return boolean
1076 1075
 	 */
1077
-	function dir_closedir ( )
1076
+	function dir_closedir( )
1078 1077
 	{
1079 1078
 		$ret = closedir($this->opened_dir);
1080 1079
 
@@ -1091,9 +1090,9 @@  discard block
 block discarded – undo
1091 1090
 	 */
1092 1091
 	static function load_wrapper($scheme)
1093 1092
 	{
1094
-		if (!in_array($scheme,self::get_wrappers()))
1093
+		if (!in_array($scheme, self::get_wrappers()))
1095 1094
 		{
1096
-			switch($scheme)
1095
+			switch ($scheme)
1097 1096
 			{
1098 1097
 				case 'webdav':
1099 1098
 				case 'webdavs':
@@ -1101,16 +1100,16 @@  discard block
 block discarded – undo
1101 1100
 					self::$wrappers[] = $scheme;
1102 1101
 					break;
1103 1102
 				case '':
1104
-					break;	// default file, always loaded
1103
+					break; // default file, always loaded
1105 1104
 				default:
1106 1105
 					// check if scheme is buildin in php or one of our own stream wrappers
1107
-					if (in_array($scheme,stream_get_wrappers()) || class_exists(self::scheme2class($scheme)))
1106
+					if (in_array($scheme, stream_get_wrappers()) || class_exists(self::scheme2class($scheme)))
1108 1107
 					{
1109 1108
 						self::$wrappers[] = $scheme;
1110 1109
 					}
1111 1110
 					else
1112 1111
 					{
1113
-						trigger_error("Can't load stream-wrapper for scheme '$scheme'!",E_USER_WARNING);
1112
+						trigger_error("Can't load stream-wrapper for scheme '$scheme'!", E_USER_WARNING);
1114 1113
 						return false;
1115 1114
 					}
1116 1115
 			}
@@ -1144,10 +1143,10 @@  discard block
 block discarded – undo
1144 1143
 	static function scheme2class($scheme)
1145 1144
 	{
1146 1145
 		list($app, $app_scheme) = explode('.', $scheme);
1147
-		foreach(array(
1148
-			empty($app_scheme) ? 'EGroupware\\Api\\Vfs\\'.ucfirst($scheme).'\\StreamWrapper' :	// streamwrapper in Api\Vfs
1146
+		foreach (array(
1147
+			empty($app_scheme) ? 'EGroupware\\Api\\Vfs\\'.ucfirst($scheme).'\\StreamWrapper' : // streamwrapper in Api\Vfs
1149 1148
 				'EGroupware\\'.ucfirst($app).'\\Vfs\\'.ucfirst($app_scheme).'\\StreamWrapper', // streamwrapper in $app\Vfs
1150
-			str_replace('.','_',$scheme).'_stream_wrapper',	// old (flat) name
1149
+			str_replace('.', '_', $scheme).'_stream_wrapper', // old (flat) name
1151 1150
 		) as $class)
1152 1151
 		{
1153 1152
 			//error_log(__METHOD__."('$scheme') class_exists('$class')=".array2string(class_exists($class)));
@@ -1162,7 +1161,7 @@  discard block
 block discarded – undo
1162 1161
 	 * @param string $only_remove_scheme =self::SCHEME if given only that scheme get's removed
1163 1162
 	 * @return string path without training slash
1164 1163
 	 */
1165
-	static protected function get_path($path,$only_remove_scheme=self::SCHEME)
1164
+	static protected function get_path($path, $only_remove_scheme = self::SCHEME)
1166 1165
 	{
1167 1166
 		if ($path[0] != '/' && (!$only_remove_scheme || Vfs::parse_url($path, PHP_URL_SCHEME) == $only_remove_scheme))
1168 1167
 		{
@@ -1173,7 +1172,7 @@  discard block
 block discarded – undo
1173 1172
 		{
1174 1173
 			while (mb_substr($path, -1) == '/' && $path != '/' && ($path[0] == '/' || Vfs::parse_url($path, PHP_URL_PATH) != '/'))
1175 1174
 			{
1176
-				$path = mb_substr($path,0,-1);
1175
+				$path = mb_substr($path, 0, -1);
1177 1176
 			}
1178 1177
 		}
1179 1178
 		return $path;
@@ -1188,7 +1187,7 @@  discard block
 block discarded – undo
1188 1187
 	static function url_is_readonly($url)
1189 1188
 	{
1190 1189
 		static $cache = array();
1191
-		$ret =& $cache[$url];
1190
+		$ret = & $cache[$url];
1192 1191
 		if (!isset($ret))
1193 1192
 		{
1194 1193
 			$matches = null;
@@ -1210,9 +1209,9 @@  discard block
 block discarded – undo
1210 1209
 	 * @param boolean $clear_fstab =false true clear current fstab, false (default) only add given mount
1211 1210
 	 * @return array|boolean array with fstab, if called without parameter or true on successful mount
1212 1211
 	 */
1213
-	static function mount($url=null,$path=null,$check_url=null,$persitent_mount=true,$clear_fstab=false)
1212
+	static function mount($url = null, $path = null, $check_url = null, $persitent_mount = true, $clear_fstab = false)
1214 1213
 	{
1215
-		if (is_null($check_url)) $check_url = strpos($url,'$') === false;
1214
+		if (is_null($check_url)) $check_url = strpos($url, '$') === false;
1216 1215
 
1217 1216
 		if (!isset($GLOBALS['egw_info']['server']['vfs_fstab']))	// happens eg. in setup
1218 1217
 		{
@@ -1238,7 +1237,7 @@  discard block
 block discarded – undo
1238 1237
 		if (!Vfs::$is_root)
1239 1238
 		{
1240 1239
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!');
1241
-			return false;	// only root can mount
1240
+			return false; // only root can mount
1242 1241
 		}
1243 1242
 		if ($clear_fstab)
1244 1243
 		{
@@ -1247,14 +1246,14 @@  discard block
 block discarded – undo
1247 1246
 		if (isset(self::$fstab[$path]) && self::$fstab[$path] === $url)
1248 1247
 		{
1249 1248
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') already mounted.');
1250
-			return true;	// already mounted
1249
+			return true; // already mounted
1251 1250
 		}
1252
-		self::load_wrapper(Vfs::parse_url($url,PHP_URL_SCHEME));
1251
+		self::load_wrapper(Vfs::parse_url($url, PHP_URL_SCHEME));
1253 1252
 
1254 1253
 		if ($check_url && (!file_exists($url) || opendir($url) === false))
1255 1254
 		{
1256 1255
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') url does NOT exist!');
1257
-			return false;	// url does not exist
1256
+			return false; // url does not exist
1258 1257
 		}
1259 1258
 		self::$fstab[$path] = $url;
1260 1259
 
@@ -1265,10 +1264,10 @@  discard block
 block discarded – undo
1265 1264
 
1266 1265
 		if ($persitent_mount)
1267 1266
 		{
1268
-			Api\Config::save_value('vfs_fstab',self::$fstab,'phpgwapi');
1267
+			Api\Config::save_value('vfs_fstab', self::$fstab, 'phpgwapi');
1269 1268
 			$GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab;
1270 1269
 			// invalidate session cache
1271
-			if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
1270
+			if (method_exists($GLOBALS['egw'], 'invalidate_session_cache'))	// egw object in setup is limited
1272 1271
 			{
1273 1272
 				$GLOBALS['egw']->invalidate_session_cache();
1274 1273
 			}
@@ -1287,19 +1286,19 @@  discard block
 block discarded – undo
1287 1286
 		if (!Vfs::$is_root)
1288 1287
 		{
1289 1288
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!');
1290
-			return false;	// only root can mount
1289
+			return false; // only root can mount
1291 1290
 		}
1292
-		if (!isset(self::$fstab[$path]) && ($path = array_search($path,self::$fstab)) === false)
1291
+		if (!isset(self::$fstab[$path]) && ($path = array_search($path, self::$fstab)) === false)
1293 1292
 		{
1294 1293
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).') NOT mounted!');
1295
-			return false;	// $path not mounted
1294
+			return false; // $path not mounted
1296 1295
 		}
1297 1296
 		unset(self::$fstab[$path]);
1298 1297
 
1299
-		Api\Config::save_value('vfs_fstab',self::$fstab,'phpgwapi');
1298
+		Api\Config::save_value('vfs_fstab', self::$fstab, 'phpgwapi');
1300 1299
 		$GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab;
1301 1300
 		// invalidate session cache
1302
-		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
1301
+		if (method_exists($GLOBALS['egw'], 'invalidate_session_cache'))	// egw object in setup is limited
1303 1302
 		{
1304 1303
 			$GLOBALS['egw']->invalidate_session_cache();
1305 1304
 		}
@@ -1313,7 +1312,7 @@  discard block
 block discarded – undo
1313 1312
 	 */
1314 1313
 	static function init_static()
1315 1314
 	{
1316
-		stream_register_wrapper(self::SCHEME,__CLASS__);
1315
+		stream_register_wrapper(self::SCHEME, __CLASS__);
1317 1316
 
1318 1317
 		if (($fstab = $GLOBALS['egw_info']['server']['vfs_fstab']) && is_array($fstab) && count($fstab))
1319 1318
 		{
Please login to merge, or discard this patch.