@@ -165,7 +165,10 @@ discard block |
||
| 165 | 165 | { |
| 166 | 166 | $url = null; |
| 167 | 167 | $stat = self::check_symlink_components($path,0,$url); |
| 168 | - if (self::LOG_LEVEL > 1) $log = " (check_symlink_components('$path',0,'$url') = $stat)"; |
|
| 168 | + if (self::LOG_LEVEL > 1) |
|
| 169 | + { |
|
| 170 | + $log = " (check_symlink_components('$path',0,'$url') = $stat)"; |
|
| 171 | + } |
|
| 169 | 172 | } |
| 170 | 173 | else |
| 171 | 174 | { |
@@ -176,7 +179,10 @@ discard block |
||
| 176 | 179 | { |
| 177 | 180 | $url = self::resolve_url(Vfs::parse_url($url,PHP_URL_PATH)); |
| 178 | 181 | } |
| 179 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,file_exists=$file_exists,resolve_last_symlink=$resolve_last_symlink) = '$url'$log"); |
|
| 182 | + if (self::LOG_LEVEL > 1) |
|
| 183 | + { |
|
| 184 | + error_log(__METHOD__."($path,file_exists=$file_exists,resolve_last_symlink=$resolve_last_symlink) = '$url'$log"); |
|
| 185 | + } |
|
| 180 | 186 | return $url; |
| 181 | 187 | } |
| 182 | 188 | |
@@ -204,7 +210,10 @@ discard block |
||
| 204 | 210 | // we do some caching here |
| 205 | 211 | if (isset(self::$resolve_url_cache[$path]) && $replace_user_pass_host) |
| 206 | 212 | { |
| 207 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '".self::$resolve_url_cache[$path]."' (from cache)"); |
|
| 213 | + if (self::LOG_LEVEL > 1) |
|
| 214 | + { |
|
| 215 | + error_log(__METHOD__."('$path') = '".self::$resolve_url_cache[$path]."' (from cache)"); |
|
| 216 | + } |
|
| 208 | 217 | return self::$resolve_url_cache[$path]; |
| 209 | 218 | } |
| 210 | 219 | // check if we can already resolve path (or a part of it) with a known symlinks |
@@ -224,14 +233,24 @@ discard block |
||
| 224 | 233 | ); |
| 225 | 234 | } |
| 226 | 235 | $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)! |
|
| 236 | + if (!$parts['host']) |
|
| 237 | + { |
|
| 238 | + $parts['host'] = 'default'; |
|
| 239 | + } |
|
| 240 | + // otherwise we get an invalid url (scheme:///path/to/something)! |
|
| 228 | 241 | |
| 229 | 242 | if (!empty($parts['scheme']) && $parts['scheme'] != self::SCHEME) |
| 230 | 243 | { |
| 231 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$path' (path is already an url)"); |
|
| 244 | + if (self::LOG_LEVEL > 1) |
|
| 245 | + { |
|
| 246 | + error_log(__METHOD__."('$path') = '$path' (path is already an url)"); |
|
| 247 | + } |
|
| 232 | 248 | return $path; // path is already a non-vfs url --> nothing to do |
| 233 | 249 | } |
| 234 | - if (empty($parts['path'])) $parts['path'] = '/'; |
|
| 250 | + if (empty($parts['path'])) |
|
| 251 | + { |
|
| 252 | + $parts['path'] = '/'; |
|
| 253 | + } |
|
| 235 | 254 | |
| 236 | 255 | foreach(array_reverse(self::$fstab) as $mounted => $url) |
| 237 | 256 | { |
@@ -257,17 +276,32 @@ discard block |
||
| 257 | 276 | { |
| 258 | 277 | $url = str_replace(array('$user','$pass','$host','$home'),array($parts['user'],$parts['pass'],$parts['host'],$parts['home']),$url); |
| 259 | 278 | } |
| 260 | - if ($parts['query']) $url .= '?'.$parts['query']; |
|
| 261 | - if ($parts['fragment']) $url .= '#'.$parts['fragment']; |
|
| 279 | + if ($parts['query']) |
|
| 280 | + { |
|
| 281 | + $url .= '?'.$parts['query']; |
|
| 282 | + } |
|
| 283 | + if ($parts['fragment']) |
|
| 284 | + { |
|
| 285 | + $url .= '#'.$parts['fragment']; |
|
| 286 | + } |
|
| 262 | 287 | |
| 263 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$url'"); |
|
| 288 | + if (self::LOG_LEVEL > 1) |
|
| 289 | + { |
|
| 290 | + error_log(__METHOD__."('$path') = '$url'"); |
|
| 291 | + } |
|
| 264 | 292 | |
| 265 | - if ($replace_user_pass_host) self::$resolve_url_cache[$path] = $url; |
|
| 293 | + if ($replace_user_pass_host) |
|
| 294 | + { |
|
| 295 | + self::$resolve_url_cache[$path] = $url; |
|
| 296 | + } |
|
| 266 | 297 | |
| 267 | 298 | return $url; |
| 268 | 299 | } |
| 269 | 300 | } |
| 270 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path') can't resolve path!\n"); |
|
| 301 | + if (self::LOG_LEVEL > 0) |
|
| 302 | + { |
|
| 303 | + error_log(__METHOD__."('$path') can't resolve path!\n"); |
|
| 304 | + } |
|
| 271 | 305 | trigger_error(__METHOD__."($path) can't resolve path!\n",E_USER_WARNING); |
| 272 | 306 | return false; |
| 273 | 307 | } |
@@ -488,15 +522,21 @@ discard block |
||
| 488 | 522 | */ |
| 489 | 523 | function stream_metadata($path, $option, $value) |
| 490 | 524 | { |
| 491 | - if (!($url = $this->resolve_url_symlinks($path, $option != STREAM_META_TOUCH, false))) // true,false file need to exist, but do not resolve last component |
|
| 525 | + if (!($url = $this->resolve_url_symlinks($path, $option != STREAM_META_TOUCH, false))) |
|
| 526 | + { |
|
| 527 | + // true,false file need to exist, but do not resolve last component |
|
| 492 | 528 | { |
| 493 | 529 | return false; |
| 494 | 530 | } |
| 531 | + } |
|
| 495 | 532 | if (self::url_is_readonly($url)) |
| 496 | 533 | { |
| 497 | 534 | return false; |
| 498 | 535 | } |
| 499 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path', $option, ".array2string($value).") url=$url"); |
|
| 536 | + if (self::LOG_LEVEL > 1) |
|
| 537 | + { |
|
| 538 | + error_log(__METHOD__."('$path', $option, ".array2string($value).") url=$url"); |
|
| 539 | + } |
|
| 500 | 540 | |
| 501 | 541 | switch($option) |
| 502 | 542 | { |
@@ -508,14 +548,18 @@ discard block |
||
| 508 | 548 | |
| 509 | 549 | case STREAM_META_OWNER_NAME: |
| 510 | 550 | if (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'u')) === false) |
| 511 | - return false; |
|
| 551 | + { |
|
| 552 | + return false; |
|
| 553 | + } |
|
| 512 | 554 | // fall through |
| 513 | 555 | case STREAM_META_OWNER: |
| 514 | 556 | return chown($url, $value); |
| 515 | 557 | |
| 516 | 558 | case STREAM_META_GROUP_NAME: |
| 517 | 559 | if (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'g')) === false) |
| 518 | - return false; |
|
| 560 | + { |
|
| 561 | + return false; |
|
| 562 | + } |
|
| 519 | 563 | // fall through |
| 520 | 564 | case STREAM_META_GROUP: |
| 521 | 565 | return chgrp($url, $value); |
@@ -534,10 +578,13 @@ discard block |
||
| 534 | 578 | */ |
| 535 | 579 | function unlink ( $path ) |
| 536 | 580 | { |
| 537 | - if (!($url = $this->resolve_url_symlinks($path,true,false))) // true,false file need to exist, but do not resolve last component |
|
| 581 | + if (!($url = $this->resolve_url_symlinks($path,true,false))) |
|
| 582 | + { |
|
| 583 | + // true,false file need to exist, but do not resolve last component |
|
| 538 | 584 | { |
| 539 | 585 | return false; |
| 540 | 586 | } |
| 587 | + } |
|
| 541 | 588 | if (self::url_is_readonly($url)) |
| 542 | 589 | { |
| 543 | 590 | return false; |
@@ -600,7 +647,10 @@ discard block |
||
| 600 | 647 | $ret = stream_copy_to_stream($from,$to) !== false; |
| 601 | 648 | fclose($from); |
| 602 | 649 | fclose($to); |
| 603 | - if ($ret) $this->unlink($path_from); |
|
| 650 | + if ($ret) |
|
| 651 | + { |
|
| 652 | + $this->unlink($path_from); |
|
| 653 | + } |
|
| 604 | 654 | } |
| 605 | 655 | else |
| 606 | 656 | { |
@@ -637,10 +687,13 @@ discard block |
||
| 637 | 687 | */ |
| 638 | 688 | function mkdir ( $path, $mode, $options ) |
| 639 | 689 | { |
| 640 | - if (!($url = $this->resolve_url_symlinks($path,false))) // false = directory does not need to exists |
|
| 690 | + if (!($url = $this->resolve_url_symlinks($path,false))) |
|
| 691 | + { |
|
| 692 | + // false = directory does not need to exists |
|
| 641 | 693 | { |
| 642 | 694 | return false; |
| 643 | 695 | } |
| 696 | + } |
|
| 644 | 697 | // refuse to modify readonly target (eg. readonly share) |
| 645 | 698 | if (self::url_is_readonly($url)) |
| 646 | 699 | { |
@@ -652,7 +705,10 @@ discard block |
||
| 652 | 705 | !($this->url_stat($parent_url, STREAM_URL_STAT_QUIET)) && |
| 653 | 706 | Vfs::parse_url($parent_url, PHP_URL_PATH) !== '/') |
| 654 | 707 | { |
| 655 | - if (!mkdir($parent_url, $mode, $options)) return false; |
|
| 708 | + if (!mkdir($parent_url, $mode, $options)) |
|
| 709 | + { |
|
| 710 | + return false; |
|
| 711 | + } |
|
| 656 | 712 | } |
| 657 | 713 | // unset it now, as it was handled above |
| 658 | 714 | $options &= ~STREAM_MKDIR_RECURSIVE; |
@@ -729,13 +785,19 @@ discard block |
||
| 729 | 785 | |
| 730 | 786 | if (!($this->opened_dir_url = $this->resolve_url_symlinks($path))) |
| 731 | 787 | { |
| 732 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) resolve_url_symlinks() failed!"); |
|
| 788 | + if (self::LOG_LEVEL > 0) |
|
| 789 | + { |
|
| 790 | + error_log(__METHOD__."( $path,$options) resolve_url_symlinks() failed!"); |
|
| 791 | + } |
|
| 733 | 792 | return false; |
| 734 | 793 | } |
| 735 | 794 | if (!($this->opened_dir = $this->context ? |
| 736 | 795 | opendir($this->opened_dir_url, $this->context) : opendir($this->opened_dir_url))) |
| 737 | 796 | { |
| 738 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!"); |
|
| 797 | + if (self::LOG_LEVEL > 0) |
|
| 798 | + { |
|
| 799 | + error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!"); |
|
| 800 | + } |
|
| 739 | 801 | return false; |
| 740 | 802 | } |
| 741 | 803 | $this->opened_dir_writable = Vfs::check_access($this->opened_dir_url,Vfs::WRITABLE); |
@@ -753,7 +815,10 @@ discard block |
||
| 753 | 815 | } |
| 754 | 816 | |
| 755 | 817 | |
| 756 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $path,$options): opendir($this->opened_dir_url)=$this->opened_dir, extra_dirs=".array2string($this->extra_dirs).', '.function_backtrace()); |
|
| 818 | + if (self::LOG_LEVEL > 1) |
|
| 819 | + { |
|
| 820 | + error_log(__METHOD__."( $path,$options): opendir($this->opened_dir_url)=$this->opened_dir, extra_dirs=".array2string($this->extra_dirs).', '.function_backtrace()); |
|
| 821 | + } |
|
| 757 | 822 | return true; |
| 758 | 823 | } |
| 759 | 824 | |
@@ -789,7 +854,10 @@ discard block |
||
| 789 | 854 | { |
| 790 | 855 | if (!($url = self::resolve_url($path,!($flags & STREAM_URL_STAT_LINK), $check_symlink_components))) |
| 791 | 856 | { |
| 792 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) can NOT resolve path!"); |
|
| 857 | + if (self::LOG_LEVEL > 0) |
|
| 858 | + { |
|
| 859 | + error_log(__METHOD__."('$path',$flags) can NOT resolve path!"); |
|
| 860 | + } |
|
| 793 | 861 | return false; |
| 794 | 862 | } |
| 795 | 863 | |
@@ -806,18 +874,27 @@ discard block |
||
| 806 | 874 | { |
| 807 | 875 | if (!$check_symlink_depth) |
| 808 | 876 | { |
| 809 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) maximum symlink depth exceeded, might be a circular symlink!"); |
|
| 877 | + if (self::LOG_LEVEL > 0) |
|
| 878 | + { |
|
| 879 | + error_log(__METHOD__."('$path',$flags) maximum symlink depth exceeded, might be a circular symlink!"); |
|
| 880 | + } |
|
| 810 | 881 | $stat = false; |
| 811 | 882 | } |
| 812 | 883 | elseif (($lpath = Vfs::readlink($url))) |
| 813 | 884 | { |
| 814 | - if ($lpath[0] != '/') // concat relative path |
|
| 885 | + if ($lpath[0] != '/') |
|
| 886 | + { |
|
| 887 | + // concat relative path |
|
| 815 | 888 | { |
| 816 | 889 | $lpath = Vfs::concat(Vfs::parse_url($path,PHP_URL_PATH),'../'.$lpath); |
| 817 | 890 | } |
| 891 | + } |
|
| 818 | 892 | $u_query = parse_url($url,PHP_URL_QUERY); |
| 819 | 893 | $url = Vfs::PREFIX.$lpath; |
| 820 | - 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"); |
|
| 894 | + if (self::LOG_LEVEL > 1) |
|
| 895 | + { |
|
| 896 | + 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"); |
|
| 897 | + } |
|
| 821 | 898 | // try reading the stat of the link |
| 822 | 899 | if (($stat = $this->url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth-1))) |
| 823 | 900 | { |
@@ -830,7 +907,11 @@ discard block |
||
| 830 | 907 | $stat_query = http_build_query(array_merge($stat_query, $u_query)); |
| 831 | 908 | $stat['url'] = $stat_url['scheme'].'://'.$stat_url['host'].$stat_url['path'].'?'.$stat_query; |
| 832 | 909 | } |
| 833 | - if(isset($stat['url'])) $url = $stat['url']; // if stat returns an url use that, as there might be more links ... |
|
| 910 | + if(isset($stat['url'])) |
|
| 911 | + { |
|
| 912 | + $url = $stat['url']; |
|
| 913 | + } |
|
| 914 | + // if stat returns an url use that, as there might be more links ... |
|
| 834 | 915 | self::symlinkCache_add($path,$url); |
| 835 | 916 | } |
| 836 | 917 | } |
@@ -853,7 +934,9 @@ discard block |
||
| 853 | 934 | // check if a failed url_stat was for a home dir, in that case silently create it |
| 854 | 935 | if (!$stat && $try_create_home && Vfs::dirname(Vfs::parse_url($path,PHP_URL_PATH)) == '/home' && |
| 855 | 936 | ($id = $GLOBALS['egw']->accounts->name2id(basename($path))) && |
| 856 | - $GLOBALS['egw']->accounts->id2name($id) == basename($path)) // make sure path has the right case! |
|
| 937 | + $GLOBALS['egw']->accounts->id2name($id) == basename($path)) |
|
| 938 | + { |
|
| 939 | + // make sure path has the right case! |
|
| 857 | 940 | { |
| 858 | 941 | $hook_data = array( |
| 859 | 942 | 'location' => $GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'addgroup' : 'addaccount', |
@@ -861,15 +944,22 @@ discard block |
||
| 861 | 944 | 'account_lid' => basename($path), |
| 862 | 945 | 'account_name' => basename($path), |
| 863 | 946 | ); |
| 947 | + } |
|
| 864 | 948 | call_user_func(array(__NAMESPACE__.'\\Hooks',$hook_data['location']),$hook_data); |
| 865 | 949 | unset($hook_data); |
| 866 | 950 | $stat = $this->url_stat($path,$flags,false); |
| 867 | 951 | } |
| 868 | 952 | $query = parse_url($url, PHP_URL_QUERY); |
| 869 | - if (!$stat && $check_symlink_components) // check if there's a symlink somewhere inbetween the path |
|
| 953 | + if (!$stat && $check_symlink_components) |
|
| 954 | + { |
|
| 955 | + // check if there's a symlink somewhere inbetween the path |
|
| 870 | 956 | { |
| 871 | 957 | $stat = self::check_symlink_components($path,$flags,$url); |
| 872 | - if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path,$stat['url']); |
|
| 958 | + } |
|
| 959 | + if ($stat && isset($stat['url']) && !$query) |
|
| 960 | + { |
|
| 961 | + self::symlinkCache_add($path,$stat['url']); |
|
| 962 | + } |
|
| 873 | 963 | } |
| 874 | 964 | elseif(is_array($stat) && !isset($stat['url'])) |
| 875 | 965 | { |
@@ -884,7 +974,10 @@ discard block |
||
| 884 | 974 | $stat['url'] .= '?'.$query; |
| 885 | 975 | } |
| 886 | 976 | |
| 887 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,try_create_home=$try_create_home,check_symlink_components=$check_symlink_components) returning ".array2string($stat)); |
|
| 977 | + if (self::LOG_LEVEL > 1) |
|
| 978 | + { |
|
| 979 | + error_log(__METHOD__."('$path',$flags,try_create_home=$try_create_home,check_symlink_components=$check_symlink_components) returning ".array2string($stat)); |
|
| 980 | + } |
|
| 888 | 981 | |
| 889 | 982 | return $stat; |
| 890 | 983 | |
@@ -910,10 +1003,16 @@ discard block |
||
| 910 | 1003 | { |
| 911 | 1004 | if (is_null($url) && !($url = self::resolve_url($path))) |
| 912 | 1005 | { |
| 913 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags,'$url') can NOT resolve path: ".function_backtrace(1)); |
|
| 1006 | + if (self::LOG_LEVEL > 0) |
|
| 1007 | + { |
|
| 1008 | + error_log(__METHOD__."('$path',$flags,'$url') can NOT resolve path: ".function_backtrace(1)); |
|
| 1009 | + } |
|
| 914 | 1010 | return false; |
| 915 | 1011 | } |
| 916 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1)); |
|
| 1012 | + if (self::LOG_LEVEL > 1) |
|
| 1013 | + { |
|
| 1014 | + error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1)); |
|
| 1015 | + } |
|
| 917 | 1016 | |
| 918 | 1017 | while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) && |
| 919 | 1018 | ($url = Vfs::dirname($url))) |
@@ -922,7 +1021,10 @@ discard block |
||
| 922 | 1021 | { |
| 923 | 1022 | if (is_link($url) && ($lpath = Vfs::readlink($url))) |
| 924 | 1023 | { |
| 925 | - if (self::LOG_LEVEL > 1) $log = "rel_path='$rel_path', url='$url': lpath='$lpath'"; |
|
| 1024 | + if (self::LOG_LEVEL > 1) |
|
| 1025 | + { |
|
| 1026 | + $log = "rel_path='$rel_path', url='$url': lpath='$lpath'"; |
|
| 1027 | + } |
|
| 926 | 1028 | |
| 927 | 1029 | if ($lpath[0] != '/') |
| 928 | 1030 | { |
@@ -930,15 +1032,24 @@ discard block |
||
| 930 | 1032 | } |
| 931 | 1033 | //self::symlinkCache_add($path,Vfs::PREFIX.$lpath); |
| 932 | 1034 | $url = Vfs::PREFIX.Vfs::concat($lpath,$rel_path); |
| 933 | - if (self::LOG_LEVEL > 1) error_log("$log --> lpath='$lpath', url='$url'"); |
|
| 1035 | + if (self::LOG_LEVEL > 1) |
|
| 1036 | + { |
|
| 1037 | + error_log("$log --> lpath='$lpath', url='$url'"); |
|
| 1038 | + } |
|
| 934 | 1039 | return $this->url_stat($url,$flags); |
| 935 | 1040 | } |
| 936 | 1041 | $url = Vfs::concat($url,$rel_path); |
| 937 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning null"); |
|
| 1042 | + if (self::LOG_LEVEL > 1) |
|
| 1043 | + { |
|
| 1044 | + error_log(__METHOD__."('$path',$flags,'$url') returning null"); |
|
| 1045 | + } |
|
| 938 | 1046 | return null; |
| 939 | 1047 | } |
| 940 | 1048 | } |
| 941 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning false"); |
|
| 1049 | + if (self::LOG_LEVEL > 1) |
|
| 1050 | + { |
|
| 1051 | + error_log(__METHOD__."('$path',$flags,'$url') returning false"); |
|
| 1052 | + } |
|
| 942 | 1053 | return false; // $path does not exist |
| 943 | 1054 | } |
| 944 | 1055 | |
@@ -959,9 +1070,16 @@ discard block |
||
| 959 | 1070 | { |
| 960 | 1071 | $path = self::get_path($_path); |
| 961 | 1072 | |
| 962 | - if (isset(self::$symlink_cache[$path])) return; // nothing to do |
|
| 1073 | + if (isset(self::$symlink_cache[$path])) |
|
| 1074 | + { |
|
| 1075 | + return; |
|
| 1076 | + } |
|
| 1077 | + // nothing to do |
|
| 963 | 1078 | |
| 964 | - if ($target[0] != '/') $target = Vfs::parse_url($target,PHP_URL_PATH); |
|
| 1079 | + if ($target[0] != '/') |
|
| 1080 | + { |
|
| 1081 | + $target = Vfs::parse_url($target,PHP_URL_PATH); |
|
| 1082 | + } |
|
| 965 | 1083 | |
| 966 | 1084 | self::$symlink_cache[$path] = $target; |
| 967 | 1085 | |
@@ -970,7 +1088,10 @@ discard block |
||
| 970 | 1088 | { |
| 971 | 1089 | return strlen($a) - strlen($b); |
| 972 | 1090 | }); |
| 973 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache)); |
|
| 1091 | + if (self::LOG_LEVEL > 1) |
|
| 1092 | + { |
|
| 1093 | + error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache)); |
|
| 1094 | + } |
|
| 974 | 1095 | } |
| 975 | 1096 | |
| 976 | 1097 | /** |
@@ -983,7 +1104,10 @@ discard block |
||
| 983 | 1104 | $path = self::get_path($_path); |
| 984 | 1105 | |
| 985 | 1106 | unset(self::$symlink_cache[$path]); |
| 986 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path) cache now ".array2string(self::$symlink_cache)); |
|
| 1107 | + if (self::LOG_LEVEL > 1) |
|
| 1108 | + { |
|
| 1109 | + error_log(__METHOD__."($path) cache now ".array2string(self::$symlink_cache)); |
|
| 1110 | + } |
|
| 987 | 1111 | } |
| 988 | 1112 | |
| 989 | 1113 | /** |
@@ -1004,11 +1128,18 @@ discard block |
||
| 1004 | 1128 | |
| 1005 | 1129 | foreach(self::$symlink_cache as $p => $t) |
| 1006 | 1130 | { |
| 1007 | - if (($strlen_p = strlen($p)) > $strlen_path) continue; // $path can NOT start with $p |
|
| 1131 | + if (($strlen_p = strlen($p)) > $strlen_path) |
|
| 1132 | + { |
|
| 1133 | + continue; |
|
| 1134 | + } |
|
| 1135 | + // $path can NOT start with $p |
|
| 1008 | 1136 | |
| 1009 | 1137 | if ($path == $p) |
| 1010 | 1138 | { |
| 1011 | - if ($do_symlink) $target = $t; |
|
| 1139 | + if ($do_symlink) |
|
| 1140 | + { |
|
| 1141 | + $target = $t; |
|
| 1142 | + } |
|
| 1012 | 1143 | break; |
| 1013 | 1144 | } |
| 1014 | 1145 | elseif (substr($path,0,$strlen_p+1) == $p.'/') |
@@ -1017,7 +1148,10 @@ discard block |
||
| 1017 | 1148 | break; |
| 1018 | 1149 | } |
| 1019 | 1150 | } |
| 1020 | - if (self::LOG_LEVEL > 1 && isset($target)) error_log(__METHOD__."($path) = $target"); |
|
| 1151 | + if (self::LOG_LEVEL > 1 && isset($target)) |
|
| 1152 | + { |
|
| 1153 | + error_log(__METHOD__."($path) = $target"); |
|
| 1154 | + } |
|
| 1021 | 1155 | return isset($target) ? $target : $path; |
| 1022 | 1156 | } |
| 1023 | 1157 | |
@@ -1058,7 +1192,10 @@ discard block |
||
| 1058 | 1192 | self::HIDE_UNREADABLES && !$this->opened_dir_writable && |
| 1059 | 1193 | !Vfs::check_access(Vfs::concat($this->opened_dir_url,$file),Vfs::READABLE))); |
| 1060 | 1194 | } |
| 1061 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $this->opened_dir ) = '$file'"); |
|
| 1195 | + if (self::LOG_LEVEL > 1) |
|
| 1196 | + { |
|
| 1197 | + error_log(__METHOD__."( $this->opened_dir ) = '$file'"); |
|
| 1198 | + } |
|
| 1062 | 1199 | return $file; |
| 1063 | 1200 | } |
| 1064 | 1201 | |
@@ -1161,7 +1298,10 @@ discard block |
||
| 1161 | 1298 | ) as $class) |
| 1162 | 1299 | { |
| 1163 | 1300 | //error_log(__METHOD__."('$scheme') class_exists('$class')=".array2string(class_exists($class))); |
| 1164 | - if (class_exists($class)) return $class; |
|
| 1301 | + if (class_exists($class)) |
|
| 1302 | + { |
|
| 1303 | + return $class; |
|
| 1304 | + } |
|
| 1165 | 1305 | } |
| 1166 | 1306 | } |
| 1167 | 1307 | |
@@ -1222,11 +1362,17 @@ discard block |
||
| 1222 | 1362 | */ |
| 1223 | 1363 | static function mount($url=null,$path=null,$check_url=null,$persitent_mount=true,$clear_fstab=false) |
| 1224 | 1364 | { |
| 1225 | - if (is_null($check_url)) $check_url = strpos($url,'$') === false; |
|
| 1365 | + if (is_null($check_url)) |
|
| 1366 | + { |
|
| 1367 | + $check_url = strpos($url,'$') === false; |
|
| 1368 | + } |
|
| 1226 | 1369 | |
| 1227 | - if (!isset($GLOBALS['egw_info']['server']['vfs_fstab'])) // happens eg. in setup |
|
| 1370 | + if (!isset($GLOBALS['egw_info']['server']['vfs_fstab'])) |
|
| 1371 | + { |
|
| 1372 | + // happens eg. in setup |
|
| 1228 | 1373 | { |
| 1229 | 1374 | $api_config = Api\Config::read('phpgwapi'); |
| 1375 | + } |
|
| 1230 | 1376 | if (isset($api_config['vfs_fstab']) && is_array($api_config['vfs_fstab'])) |
| 1231 | 1377 | { |
| 1232 | 1378 | self::$fstab = $api_config['vfs_fstab']; |
@@ -1242,12 +1388,18 @@ discard block |
||
| 1242 | 1388 | } |
| 1243 | 1389 | if (is_null($url) || is_null($path)) |
| 1244 | 1390 | { |
| 1245 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns '.array2string(self::$fstab)); |
|
| 1391 | + if (self::LOG_LEVEL > 1) |
|
| 1392 | + { |
|
| 1393 | + error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns '.array2string(self::$fstab)); |
|
| 1394 | + } |
|
| 1246 | 1395 | return self::$fstab; |
| 1247 | 1396 | } |
| 1248 | 1397 | if (!Vfs::$is_root) |
| 1249 | 1398 | { |
| 1250 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!'); |
|
| 1399 | + if (self::LOG_LEVEL > 0) |
|
| 1400 | + { |
|
| 1401 | + error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!'); |
|
| 1402 | + } |
|
| 1251 | 1403 | return false; // only root can mount |
| 1252 | 1404 | } |
| 1253 | 1405 | if ($clear_fstab) |
@@ -1256,14 +1408,20 @@ discard block |
||
| 1256 | 1408 | } |
| 1257 | 1409 | if (isset(self::$fstab[$path]) && self::$fstab[$path] === $url) |
| 1258 | 1410 | { |
| 1259 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') already mounted.'); |
|
| 1411 | + if (self::LOG_LEVEL > 0) |
|
| 1412 | + { |
|
| 1413 | + error_log(__METHOD__.'('.array2string($url).','.array2string($path).') already mounted.'); |
|
| 1414 | + } |
|
| 1260 | 1415 | return true; // already mounted |
| 1261 | 1416 | } |
| 1262 | 1417 | self::load_wrapper(Vfs::parse_url($url,PHP_URL_SCHEME)); |
| 1263 | 1418 | |
| 1264 | 1419 | if ($check_url && (!file_exists($url) || opendir($url) === false)) |
| 1265 | 1420 | { |
| 1266 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') url does NOT exist!'); |
|
| 1421 | + if (self::LOG_LEVEL > 0) |
|
| 1422 | + { |
|
| 1423 | + error_log(__METHOD__.'('.array2string($url).','.array2string($path).') url does NOT exist!'); |
|
| 1424 | + } |
|
| 1267 | 1425 | return false; // url does not exist |
| 1268 | 1426 | } |
| 1269 | 1427 | self::$fstab[$path] = $url; |
@@ -1278,12 +1436,18 @@ discard block |
||
| 1278 | 1436 | Api\Config::save_value('vfs_fstab',self::$fstab,'phpgwapi'); |
| 1279 | 1437 | $GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab; |
| 1280 | 1438 | // invalidate session cache |
| 1281 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 1439 | + if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
| 1440 | + { |
|
| 1441 | + // egw object in setup is limited |
|
| 1282 | 1442 | { |
| 1283 | 1443 | $GLOBALS['egw']->invalidate_session_cache(); |
| 1284 | 1444 | } |
| 1445 | + } |
|
| 1446 | + } |
|
| 1447 | + if (self::LOG_LEVEL > 1) |
|
| 1448 | + { |
|
| 1449 | + error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns true (successful new mount).'); |
|
| 1285 | 1450 | } |
| 1286 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns true (successful new mount).'); |
|
| 1287 | 1451 | return true; |
| 1288 | 1452 | } |
| 1289 | 1453 | |
@@ -1296,12 +1460,18 @@ discard block |
||
| 1296 | 1460 | { |
| 1297 | 1461 | if (!Vfs::$is_root) |
| 1298 | 1462 | { |
| 1299 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!'); |
|
| 1463 | + if (self::LOG_LEVEL > 0) |
|
| 1464 | + { |
|
| 1465 | + error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!'); |
|
| 1466 | + } |
|
| 1300 | 1467 | return false; // only root can mount |
| 1301 | 1468 | } |
| 1302 | 1469 | if (!isset(self::$fstab[$path]) && ($path = array_search($path,self::$fstab)) === false) |
| 1303 | 1470 | { |
| 1304 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).') NOT mounted!'); |
|
| 1471 | + if (self::LOG_LEVEL > 0) |
|
| 1472 | + { |
|
| 1473 | + error_log(__METHOD__.'('.array2string($path).') NOT mounted!'); |
|
| 1474 | + } |
|
| 1305 | 1475 | return false; // $path not mounted |
| 1306 | 1476 | } |
| 1307 | 1477 | unset(self::$fstab[$path]); |
@@ -1309,11 +1479,17 @@ discard block |
||
| 1309 | 1479 | Api\Config::save_value('vfs_fstab',self::$fstab,'phpgwapi'); |
| 1310 | 1480 | $GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab; |
| 1311 | 1481 | // invalidate session cache |
| 1312 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 1482 | + if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
| 1483 | + { |
|
| 1484 | + // egw object in setup is limited |
|
| 1313 | 1485 | { |
| 1314 | 1486 | $GLOBALS['egw']->invalidate_session_cache(); |
| 1315 | 1487 | } |
| 1316 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($path).') returns true (successful unmount).'); |
|
| 1488 | + } |
|
| 1489 | + if (self::LOG_LEVEL > 1) |
|
| 1490 | + { |
|
| 1491 | + error_log(__METHOD__.'('.array2string($path).') returns true (successful unmount).'); |
|
| 1492 | + } |
|
| 1317 | 1493 | return true; |
| 1318 | 1494 | } |
| 1319 | 1495 | |