@@ -84,7 +84,7 @@ |
||
84 | 84 | /** |
85 | 85 | * Returns available diskspace information |
86 | 86 | * |
87 | - * @return array [ available-space, free-space ] |
|
87 | + * @return false[] [ available-space, free-space ] |
|
88 | 88 | */ |
89 | 89 | function getQuotaInfo() |
90 | 90 | { |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | function getChild($name) |
67 | 67 | { |
68 | 68 | //error_log(__METHOD__."('$name') this->path=$this->path, this->vfs_path=$this->vfs_path"); |
69 | - $path = $this->vfs_path . '/' . $name; |
|
70 | - $vfs_path = $this->vfs_path . '/' . Vfs::encodePathComponent($name); |
|
69 | + $path = $this->vfs_path.'/'.$name; |
|
70 | + $vfs_path = $this->vfs_path.'/'.Vfs::encodePathComponent($name); |
|
71 | 71 | |
72 | - if (!Vfs::file_exists($vfs_path)) throw new DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); |
|
72 | + if (!Vfs::file_exists($vfs_path)) throw new DAV\Exception\NotFound('File with name '.$path.' could not be located'); |
|
73 | 73 | |
74 | 74 | if (Vfs::is_dir($vfs_path)) |
75 | 75 | { |
@@ -88,6 +88,6 @@ discard block |
||
88 | 88 | */ |
89 | 89 | function getQuotaInfo() |
90 | 90 | { |
91 | - return [ false, false ]; |
|
91 | + return [false, false]; |
|
92 | 92 | } |
93 | 93 | } |
@@ -69,7 +69,10 @@ |
||
69 | 69 | $path = $this->vfs_path . '/' . $name; |
70 | 70 | $vfs_path = $this->vfs_path . '/' . Vfs::encodePathComponent($name); |
71 | 71 | |
72 | - if (!Vfs::file_exists($vfs_path)) throw new DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); |
|
72 | + if (!Vfs::file_exists($vfs_path)) |
|
73 | + { |
|
74 | + throw new DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); |
|
75 | + } |
|
73 | 76 | |
74 | 77 | if (Vfs::is_dir($vfs_path)) |
75 | 78 | { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * Return null if the ETag can not effectively be determined |
64 | 64 | * |
65 | - * @return mixed |
|
65 | + * @return string|null |
|
66 | 66 | */ |
67 | 67 | function getETag() |
68 | 68 | { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * If null is returned, we'll assume application/octet-stream |
80 | 80 | * |
81 | - * @return mixed |
|
81 | + * @return string |
|
82 | 82 | */ |
83 | 83 | function getContentType() |
84 | 84 | { |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * |
272 | 272 | * If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now. |
273 | 273 | * |
274 | - * @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. |
|
274 | + * @return boolean 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. |
|
275 | 275 | */ |
276 | 276 | function stream_flush ( ) |
277 | 277 | { |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * |
508 | 508 | * @param string $url URL that was passed to opendir() and that this object is expected to explore. |
509 | 509 | * @param int $options |
510 | - * @return booelan |
|
510 | + * @return boolean |
|
511 | 511 | */ |
512 | 512 | function dir_opendir ( $url, $options ) |
513 | 513 | { |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | * It should reset the output generated by dir_readdir(). i.e.: |
617 | 617 | * The next call to dir_readdir() should return the first entry in the location returned by dir_opendir(). |
618 | 618 | * |
619 | - * @return boolean |
|
619 | + * @return boolean|null |
|
620 | 620 | */ |
621 | 621 | function dir_rewinddir ( ) |
622 | 622 | { |
@@ -80,10 +80,10 @@ |
||
80 | 80 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
81 | 81 | * |
82 | 82 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
83 | - * { |
|
83 | + * { |
|
84 | 84 | * $eof = !$eof; |
85 | 85 | * } |
86 | - * |
|
86 | + * |
|
87 | 87 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
88 | 88 | */ |
89 | 89 | function stream_eof ( ); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * Mime type of directories, the old vfs used 'Directory', while eg. WebDAV uses 'httpd/unix-directory' |
53 | 53 | */ |
54 | - const DIR_MIME_TYPE = Vfs::DIR_MIME_TYPE ; |
|
54 | + const DIR_MIME_TYPE = Vfs::DIR_MIME_TYPE; |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * mode-bits, which have to be set for files |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * mode-bits, which have to be set for directories |
62 | 62 | */ |
63 | - const MODE_DIR = 040000; |
|
63 | + const MODE_DIR = 040000; |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * optional context param when opening the stream, null if no context passed |
@@ -123,50 +123,50 @@ discard block |
||
123 | 123 | * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set |
124 | 124 | * @return boolean true if the ressource was opened successful, otherwise false |
125 | 125 | */ |
126 | - function stream_open ( $url, $mode, $options, &$opened_path ) |
|
126 | + function stream_open($url, $mode, $options, &$opened_path) |
|
127 | 127 | { |
128 | - unset($opened_path); // not used, but required by interface |
|
128 | + unset($opened_path); // not used, but required by interface |
|
129 | 129 | |
130 | 130 | $this->opened_stream = $this->opened_stream_url = null; |
131 | - $read_only = str_replace('b','',$mode) == 'r'; |
|
131 | + $read_only = str_replace('b', '', $mode) == 'r'; |
|
132 | 132 | |
133 | 133 | // check access rights, based on the eGW mount perms |
134 | - if (!($stat = self::url_stat($url,0)) || $mode[0] == 'x') // file not found or file should NOT exist |
|
134 | + if (!($stat = self::url_stat($url, 0)) || $mode[0] == 'x') // file not found or file should NOT exist |
|
135 | 135 | { |
136 | - if ($mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
|
137 | - $mode[0] == 'x' || // or file should not exist, but does |
|
136 | + if ($mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
|
137 | + $mode[0] == 'x' || // or file should not exist, but does |
|
138 | 138 | !($dir = Vfs::dirname($url)) || |
139 | - !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=self::url_stat($dir,0))) // or we are not allowed to create it |
|
139 | + !Vfs::check_access($dir, Vfs::WRITABLE, $dir_stat = self::url_stat($dir, 0))) // or we are not allowed to create it |
|
140 | 140 | { |
141 | 141 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!"); |
142 | - if (!($options & STREAM_URL_STAT_QUIET)) |
|
142 | + if (!($options&STREAM_URL_STAT_QUIET)) |
|
143 | 143 | { |
144 | - trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING); |
|
144 | + trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!", E_USER_WARNING); |
|
145 | 145 | } |
146 | 146 | return false; |
147 | 147 | } |
148 | 148 | } |
149 | - elseif (!$read_only && !Vfs::check_access($url,Vfs::WRITABLE,$stat)) // we are not allowed to edit it |
|
149 | + elseif (!$read_only && !Vfs::check_access($url, Vfs::WRITABLE, $stat)) // we are not allowed to edit it |
|
150 | 150 | { |
151 | 151 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be edited!"); |
152 | - if (!($options & STREAM_URL_STAT_QUIET)) |
|
152 | + if (!($options&STREAM_URL_STAT_QUIET)) |
|
153 | 153 | { |
154 | - trigger_error(__METHOD__."($url,$mode,$options) file can not be edited!",E_USER_WARNING); |
|
154 | + trigger_error(__METHOD__."($url,$mode,$options) file can not be edited!", E_USER_WARNING); |
|
155 | 155 | } |
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | if (!$read_only && self::deny_script($url)) |
159 | 159 | { |
160 | 160 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) permission denied, file is a script!"); |
161 | - if (!($options & STREAM_URL_STAT_QUIET)) |
|
161 | + if (!($options&STREAM_URL_STAT_QUIET)) |
|
162 | 162 | { |
163 | - trigger_error(__METHOD__."($url,$mode,$options) permission denied, file is a script!",E_USER_WARNING); |
|
163 | + trigger_error(__METHOD__."($url,$mode,$options) permission denied, file is a script!", E_USER_WARNING); |
|
164 | 164 | } |
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // open the "real" file |
169 | - if (!($this->opened_stream = fopen($path=Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)),$mode,$options))) |
|
169 | + if (!($this->opened_stream = fopen($path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)), $mode, $options))) |
|
170 | 170 | { |
171 | 171 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) fopen('$path','$mode',$options) returned false!"); |
172 | 172 | return false; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * |
182 | 182 | * You must release any resources that were locked or allocated by the stream. |
183 | 183 | */ |
184 | - function stream_close ( ) |
|
184 | + function stream_close( ) |
|
185 | 185 | { |
186 | 186 | $ret = fclose($this->opened_stream); |
187 | 187 | |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | * @param int $count |
202 | 202 | * @return string/false up to count bytes read or false on EOF |
203 | 203 | */ |
204 | - function stream_read ( $count ) |
|
204 | + function stream_read($count) |
|
205 | 205 | { |
206 | - return fread($this->opened_stream,$count); |
|
206 | + return fread($this->opened_stream, $count); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | * @param string $data |
218 | 218 | * @return integer |
219 | 219 | */ |
220 | - function stream_write ( $data ) |
|
220 | + function stream_write($data) |
|
221 | 221 | { |
222 | - return fwrite($this->opened_stream,$data); |
|
222 | + return fwrite($this->opened_stream, $data); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
236 | 236 | */ |
237 | - function stream_eof ( ) |
|
237 | + function stream_eof( ) |
|
238 | 238 | { |
239 | 239 | return feof($this->opened_stream); |
240 | 240 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return integer current read/write position of the stream |
246 | 246 | */ |
247 | - function stream_tell ( ) |
|
247 | + function stream_tell( ) |
|
248 | 248 | { |
249 | 249 | return ftell($this->opened_stream); |
250 | 250 | } |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * 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.) |
262 | 262 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
263 | 263 | */ |
264 | - function stream_seek ( $offset, $whence ) |
|
264 | + function stream_seek($offset, $whence) |
|
265 | 265 | { |
266 | - return !fseek($this->opened_stream,$offset,$whence); // fseek returns 0 on success and -1 on failure |
|
266 | + return !fseek($this->opened_stream, $offset, $whence); // fseek returns 0 on success and -1 on failure |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @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. |
275 | 275 | */ |
276 | - function stream_flush ( ) |
|
276 | + function stream_flush( ) |
|
277 | 277 | { |
278 | 278 | return fflush($this->opened_stream); |
279 | 279 | } |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @return array containing the same values as appropriate for the stream. |
294 | 294 | */ |
295 | - function stream_stat ( ) |
|
295 | + function stream_stat( ) |
|
296 | 296 | { |
297 | - return self::url_stat($this->opened_stream_url,0); |
|
297 | + return self::url_stat($this->opened_stream_url, 0); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -306,15 +306,15 @@ discard block |
||
306 | 306 | * @param string $url |
307 | 307 | * @return boolean TRUE on success or FALSE on failure |
308 | 308 | */ |
309 | - static function unlink ( $url ) |
|
309 | + static function unlink($url) |
|
310 | 310 | { |
311 | - $path = Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)); |
|
311 | + $path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)); |
|
312 | 312 | |
313 | 313 | // check access rights (file need to exist and directory need to be writable |
314 | - if (!file_exists($path) || is_dir($path) || !($dir = Vfs::dirname($url)) || !Vfs::check_access($dir,Vfs::WRITABLE)) |
|
314 | + if (!file_exists($path) || is_dir($path) || !($dir = Vfs::dirname($url)) || !Vfs::check_access($dir, Vfs::WRITABLE)) |
|
315 | 315 | { |
316 | 316 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
317 | - return false; // no permission or file does not exist |
|
317 | + return false; // no permission or file does not exist |
|
318 | 318 | } |
319 | 319 | return unlink($path); |
320 | 320 | } |
@@ -331,21 +331,21 @@ discard block |
||
331 | 331 | * @param string $url_to |
332 | 332 | * @return boolean TRUE on success or FALSE on failure |
333 | 333 | */ |
334 | - static function rename ( $url_from, $url_to ) |
|
334 | + static function rename($url_from, $url_to) |
|
335 | 335 | { |
336 | 336 | $from = Vfs::parse_url($url_from); |
337 | 337 | $to = Vfs::parse_url($url_to); |
338 | 338 | |
339 | 339 | // check access rights |
340 | - if (!($from_stat = self::url_stat($url_from,0)) || !($dir = Vfs::dirname($url_from)) || !Vfs::check_access($dir,Vfs::WRITABLE)) |
|
340 | + if (!($from_stat = self::url_stat($url_from, 0)) || !($dir = Vfs::dirname($url_from)) || !Vfs::check_access($dir, Vfs::WRITABLE)) |
|
341 | 341 | { |
342 | 342 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $from[path] permission denied!"); |
343 | - return false; // no permission or file does not exist |
|
343 | + return false; // no permission or file does not exist |
|
344 | 344 | } |
345 | - if (!($to_dir = Vfs::dirname($url_to)) || !Vfs::check_access($to_dir,Vfs::WRITABLE,$to_dir_stat = self::url_stat($to_dir,0))) |
|
345 | + if (!($to_dir = Vfs::dirname($url_to)) || !Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = self::url_stat($to_dir, 0))) |
|
346 | 346 | { |
347 | 347 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $to_dir permission denied!"); |
348 | - return false; // no permission or parent-dir does not exist |
|
348 | + return false; // no permission or parent-dir does not exist |
|
349 | 349 | } |
350 | 350 | if (self::deny_script($url_to)) |
351 | 351 | { |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | } |
355 | 355 | // the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems |
356 | 356 | // for our vfs too, we abort here with an error, like the filesystem one does |
357 | - if (($to_stat = self::url_stat($to['path'],0)) && |
|
357 | + if (($to_stat = self::url_stat($to['path'], 0)) && |
|
358 | 358 | ($to_stat['mime'] === self::DIR_MIME_TYPE) !== ($from_stat['mime'] === self::DIR_MIME_TYPE)) |
359 | 359 | { |
360 | 360 | $is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no'; |
361 | 361 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $to[path] is $is_dir directory!"); |
362 | - return false; // no permission or file does not exist |
|
362 | + return false; // no permission or file does not exist |
|
363 | 363 | } |
364 | 364 | // if destination file already exists, delete it |
365 | 365 | if ($to_stat && !self::unlink($url_to)) |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
368 | 368 | return false; |
369 | 369 | } |
370 | - return rename(Vfs::decodePath($from['path']),Vfs::decodePath($to['path'])); |
|
370 | + return rename(Vfs::decodePath($from['path']), Vfs::decodePath($to['path'])); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE |
382 | 382 | * @return boolean TRUE on success or FALSE on failure |
383 | 383 | */ |
384 | - static function mkdir ( $url, $mode, $options ) |
|
384 | + static function mkdir($url, $mode, $options) |
|
385 | 385 | { |
386 | - unset($mode); // not used, but required by interface |
|
386 | + unset($mode); // not used, but required by interface |
|
387 | 387 | |
388 | - $path = Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)); |
|
389 | - $recursive = (bool)($options & STREAM_MKDIR_RECURSIVE); |
|
388 | + $path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)); |
|
389 | + $recursive = (bool)($options&STREAM_MKDIR_RECURSIVE); |
|
390 | 390 | |
391 | 391 | // find the real parent (might be more then one level if $recursive!) |
392 | 392 | do { |
@@ -397,12 +397,12 @@ discard block |
||
397 | 397 | //echo __METHOD__."($url,$mode,$options) path=$path, recursive=$recursive, parent=$parent, Vfs::check_access(parent_url=$parent_url,Vfs::WRITABLE)=".(int)Vfs::check_access($parent_url,Vfs::WRITABLE)."\n"; |
398 | 398 | |
399 | 399 | // check access rights (in real filesystem AND by mount perms) |
400 | - if (!$parent_url || file_exists($path) || !file_exists($parent) || !is_writable($parent) || !Vfs::check_access($parent_url,Vfs::WRITABLE)) |
|
400 | + if (!$parent_url || file_exists($path) || !file_exists($parent) || !is_writable($parent) || !Vfs::check_access($parent_url, Vfs::WRITABLE)) |
|
401 | 401 | { |
402 | 402 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
403 | 403 | return false; |
404 | 404 | } |
405 | - return mkdir($path, 0700, $recursive); // setting mode 0700 allows (only) apache to write into the dir |
|
405 | + return mkdir($path, 0700, $recursive); // setting mode 0700 allows (only) apache to write into the dir |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | * @param int $options Possible values include STREAM_REPORT_ERRORS. |
416 | 416 | * @return boolean TRUE on success or FALSE on failure. |
417 | 417 | */ |
418 | - static function rmdir ( $url, $options ) |
|
418 | + static function rmdir($url, $options) |
|
419 | 419 | { |
420 | - unset($options); // not used, but required by interface |
|
420 | + unset($options); // not used, but required by interface |
|
421 | 421 | |
422 | - $path = Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)); |
|
422 | + $path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)); |
|
423 | 423 | $parent = dirname($path); |
424 | 424 | |
425 | 425 | // check access rights (in real filesystem AND by mount perms) |
@@ -439,9 +439,9 @@ discard block |
||
439 | 439 | * @param int $atime =null access time (unix timestamp), default null = current time, not implemented in the vfs! |
440 | 440 | * @return boolean true on success, false otherwise |
441 | 441 | */ |
442 | - static function touch($url,$time=null,$atime=null) |
|
442 | + static function touch($url, $time = null, $atime = null) |
|
443 | 443 | { |
444 | - $path = Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)); |
|
444 | + $path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)); |
|
445 | 445 | $parent = dirname($path); |
446 | 446 | |
447 | 447 | // check access rights (in real filesystem AND by mount perms) |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
451 | 451 | return false; |
452 | 452 | } |
453 | - return touch($path,$time,$atime); |
|
453 | + return touch($path, $time, $atime); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
@@ -462,9 +462,9 @@ discard block |
||
462 | 462 | * @param string $mode mode string see Vfs::mode2int |
463 | 463 | * @return boolean true on success, false otherwise |
464 | 464 | */ |
465 | - static function chmod($path,$mode) |
|
465 | + static function chmod($path, $mode) |
|
466 | 466 | { |
467 | - unset($path, $mode); // not used, but required by interface |
|
467 | + unset($path, $mode); // not used, but required by interface |
|
468 | 468 | |
469 | 469 | return false; |
470 | 470 | } |
@@ -478,9 +478,9 @@ discard block |
||
478 | 478 | * @param int $owner numeric user id |
479 | 479 | * @return boolean true on success, false otherwise |
480 | 480 | */ |
481 | - static function chown($path,$owner) |
|
481 | + static function chown($path, $owner) |
|
482 | 482 | { |
483 | - unset($path, $owner); // not used, but required by interface |
|
483 | + unset($path, $owner); // not used, but required by interface |
|
484 | 484 | |
485 | 485 | return false; |
486 | 486 | } |
@@ -494,9 +494,9 @@ discard block |
||
494 | 494 | * @param int $group numeric group id |
495 | 495 | * @return boolean true on success, false otherwise |
496 | 496 | */ |
497 | - static function chgrp($path,$group) |
|
497 | + static function chgrp($path, $group) |
|
498 | 498 | { |
499 | - unset($path, $group); // not used, but required by interface |
|
499 | + unset($path, $group); // not used, but required by interface |
|
500 | 500 | |
501 | 501 | return false; |
502 | 502 | } |
@@ -508,13 +508,13 @@ discard block |
||
508 | 508 | * @param int $options |
509 | 509 | * @return booelan |
510 | 510 | */ |
511 | - function dir_opendir ( $url, $options ) |
|
511 | + function dir_opendir($url, $options) |
|
512 | 512 | { |
513 | 513 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options)"); |
514 | 514 | |
515 | 515 | $this->opened_dir = null; |
516 | 516 | |
517 | - $path = Vfs::decodePath(Vfs::parse_url($this->opened_dir_url = $url,PHP_URL_PATH)); |
|
517 | + $path = Vfs::decodePath(Vfs::parse_url($this->opened_dir_url = $url, PHP_URL_PATH)); |
|
518 | 518 | |
519 | 519 | // ToDo: check access rights |
520 | 520 | |
@@ -552,31 +552,31 @@ discard block |
||
552 | 552 | * stat triggers it's own warning anyway, so it makes no sense to trigger one by our stream-wrapper! |
553 | 553 | * @return array |
554 | 554 | */ |
555 | - static function url_stat ( $url, $flags ) |
|
555 | + static function url_stat($url, $flags) |
|
556 | 556 | { |
557 | 557 | $parts = Vfs::parse_url($url); |
558 | 558 | $path = Vfs::decodePath($parts['path']); |
559 | 559 | |
560 | - $stat = @stat($path); // suppressed the stat failed warnings |
|
560 | + $stat = @stat($path); // suppressed the stat failed warnings |
|
561 | 561 | |
562 | 562 | if ($stat) |
563 | 563 | { |
564 | 564 | // set owner, group and mode from mount options |
565 | 565 | $uid = $gid = $mode = null; |
566 | - if (!self::parse_query($parts['query'],$uid,$gid,$mode)) |
|
566 | + if (!self::parse_query($parts['query'], $uid, $gid, $mode)) |
|
567 | 567 | { |
568 | 568 | return false; |
569 | 569 | } |
570 | 570 | $stat['uid'] = $stat[4] = $uid; |
571 | 571 | $stat['gid'] = $stat[5] = $gid; |
572 | - $stat['mode'] = $stat[2] = $stat['mode'] & self::MODE_DIR ? self::MODE_DIR | $mode : self::MODE_FILE | ($mode & ~0111); |
|
572 | + $stat['mode'] = $stat[2] = $stat['mode']&self::MODE_DIR ? self::MODE_DIR|$mode : self::MODE_FILE|($mode&~0111); |
|
573 | 573 | // write rights also depend on the write rights of the webserver |
574 | 574 | if (!is_writable($path)) |
575 | 575 | { |
576 | - $stat['mode'] = $stat[2] = $stat['mode'] & ~0222; |
|
576 | + $stat['mode'] = $stat[2] = $stat['mode']&~0222; |
|
577 | 577 | } |
578 | 578 | } |
579 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags) path=$path, mount_mode=".sprintf('0%o',$mode).", mode=".sprintf('0%o',$stat['mode']).'='.Vfs::int2mode($stat['mode'])); |
|
579 | + if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags) path=$path, mount_mode=".sprintf('0%o', $mode).", mode=".sprintf('0%o', $stat['mode']).'='.Vfs::int2mode($stat['mode'])); |
|
580 | 580 | return $stat; |
581 | 581 | } |
582 | 582 | |
@@ -590,13 +590,13 @@ discard block |
||
590 | 590 | * |
591 | 591 | * @return string |
592 | 592 | */ |
593 | - function dir_readdir ( ) |
|
593 | + function dir_readdir( ) |
|
594 | 594 | { |
595 | 595 | do { |
596 | 596 | $file = readdir($this->opened_dir); |
597 | 597 | |
598 | - $ignore = !($file === false || // stop if no more dirs or |
|
599 | - ($file != '.' && $file != '..' )); // file not . or .. |
|
598 | + $ignore = !($file === false || // stop if no more dirs or |
|
599 | + ($file != '.' && $file != '..')); // file not . or .. |
|
600 | 600 | if (self::LOG_LEVEL > 1 && $ignore) error_log(__METHOD__.'() ignoring '.array2string($file)); |
601 | 601 | } |
602 | 602 | while ($ignore); |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | * |
618 | 618 | * @return boolean |
619 | 619 | */ |
620 | - function dir_rewinddir ( ) |
|
620 | + function dir_rewinddir( ) |
|
621 | 621 | { |
622 | 622 | return rewinddir($this->opened_dir); |
623 | 623 | } |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | * |
630 | 630 | * @return boolean |
631 | 631 | */ |
632 | - function dir_closedir ( ) |
|
632 | + function dir_closedir( ) |
|
633 | 633 | { |
634 | 634 | closedir($this->opened_dir); |
635 | 635 | |
@@ -647,18 +647,18 @@ discard block |
||
647 | 647 | * @param int &$mode default if not set is 05 r-x for others |
648 | 648 | * @return boolean true on successfull parse, false on error |
649 | 649 | */ |
650 | - static function parse_query($query,&$uid,&$gid,&$mode) |
|
650 | + static function parse_query($query, &$uid, &$gid, &$mode) |
|
651 | 651 | { |
652 | 652 | $params = null; |
653 | - parse_str(is_array($query) ? $query['query'] : $query,$params); |
|
653 | + parse_str(is_array($query) ? $query['query'] : $query, $params); |
|
654 | 654 | |
655 | 655 | // setting the default perms root.root r-x for other |
656 | 656 | $uid = $gid = 0; |
657 | 657 | $mode = 05; |
658 | 658 | |
659 | - foreach($params as $name => $value) |
|
659 | + foreach ($params as $name => $value) |
|
660 | 660 | { |
661 | - switch($name) |
|
661 | + switch ($name) |
|
662 | 662 | { |
663 | 663 | case 'user': |
664 | 664 | if (!is_numeric($value)) |
@@ -667,10 +667,10 @@ discard block |
||
667 | 667 | { |
668 | 668 | $value = 0; |
669 | 669 | } |
670 | - elseif (($value = $GLOBALS['egw']->accounts->name2id($value,'account_lid','u')) === false) |
|
670 | + elseif (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'u')) === false) |
|
671 | 671 | { |
672 | 672 | error_log(__METHOD__."('$query') unknown user-name '$value'!"); |
673 | - return false; // wrong user-name |
|
673 | + return false; // wrong user-name |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | // fall-through |
@@ -689,12 +689,12 @@ discard block |
||
689 | 689 | { |
690 | 690 | $value = 0; |
691 | 691 | } |
692 | - elseif (($value = $GLOBALS['egw']->accounts->name2id($value,'account_lid','g')) === false) |
|
692 | + elseif (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'g')) === false) |
|
693 | 693 | { |
694 | 694 | error_log(__METHOD__."('$query') unknown group-name '$value'!"); |
695 | - return false; // wrong group-name |
|
695 | + return false; // wrong group-name |
|
696 | 696 | } |
697 | - $value = -$value; // vfs uses positiv gid's! |
|
697 | + $value = -$value; // vfs uses positiv gid's! |
|
698 | 698 | } |
699 | 699 | // fall-through |
700 | 700 | case 'gid': |
@@ -730,9 +730,9 @@ discard block |
||
730 | 730 | { |
731 | 731 | $parts = Vfs::parse_url($url); |
732 | 732 | $get = null; |
733 | - parse_str($parts['query'],$get); |
|
733 | + parse_str($parts['query'], $get); |
|
734 | 734 | |
735 | - $deny = !$get['exec'] && preg_match(self::SCRIPT_EXTENSIONS_PREG,$parts['path']); |
|
735 | + $deny = !$get['exec'] && preg_match(self::SCRIPT_EXTENSIONS_PREG, $parts['path']); |
|
736 | 736 | |
737 | 737 | if (self::LOG_LEVEL > 1 || self::LOG_LEVEL > 0 && $deny) |
738 | 738 | { |
@@ -752,21 +752,21 @@ discard block |
||
752 | 752 | * @todo get $force_download working through webdav |
753 | 753 | * @return string|false string with full download url or false to use default webdav.php url |
754 | 754 | */ |
755 | - static function download_url($_url,$force_download=false) |
|
755 | + static function download_url($_url, $force_download = false) |
|
756 | 756 | { |
757 | - unset($force_download); // not used, but required by interface |
|
757 | + unset($force_download); // not used, but required by interface |
|
758 | 758 | |
759 | - list($url,$query) = explode('?',$_url,2); |
|
759 | + list($url, $query) = explode('?', $_url, 2); |
|
760 | 760 | $get = null; |
761 | - parse_str($query,$get); |
|
762 | - if (empty($get['url'])) return false; // no download url given for this mount-point |
|
761 | + parse_str($query, $get); |
|
762 | + if (empty($get['url'])) return false; // no download url given for this mount-point |
|
763 | 763 | |
764 | - if (!($mount_url = Vfs::mount_url($_url))) return false; // no mount url found, should not happen |
|
765 | - list($mount_url) = explode('?',$mount_url); |
|
764 | + if (!($mount_url = Vfs::mount_url($_url))) return false; // no mount url found, should not happen |
|
765 | + list($mount_url) = explode('?', $mount_url); |
|
766 | 766 | |
767 | - $relpath = substr($url,strlen($mount_url)); |
|
767 | + $relpath = substr($url, strlen($mount_url)); |
|
768 | 768 | |
769 | - $download_url = Vfs::concat($get['url'],$relpath); |
|
769 | + $download_url = Vfs::concat($get['url'], $relpath); |
|
770 | 770 | if ($download_url[0] == '/') |
771 | 771 | { |
772 | 772 | $download_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://'). |
@@ -131,7 +131,9 @@ discard block |
||
131 | 131 | $read_only = str_replace('b','',$mode) == 'r'; |
132 | 132 | |
133 | 133 | // check access rights, based on the eGW mount perms |
134 | - if (!($stat = self::url_stat($url,0)) || $mode[0] == 'x') // file not found or file should NOT exist |
|
134 | + if (!($stat = self::url_stat($url,0)) || $mode[0] == 'x') |
|
135 | + { |
|
136 | + // file not found or file should NOT exist |
|
135 | 137 | { |
136 | 138 | if ($mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
137 | 139 | $mode[0] == 'x' || // or file should not exist, but does |
@@ -139,6 +141,7 @@ discard block |
||
139 | 141 | !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=self::url_stat($dir,0))) // or we are not allowed to create it |
140 | 142 | { |
141 | 143 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!"); |
144 | + } |
|
142 | 145 | if (!($options & STREAM_URL_STAT_QUIET)) |
143 | 146 | { |
144 | 147 | trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING); |
@@ -146,9 +149,12 @@ discard block |
||
146 | 149 | return false; |
147 | 150 | } |
148 | 151 | } |
149 | - elseif (!$read_only && !Vfs::check_access($url,Vfs::WRITABLE,$stat)) // we are not allowed to edit it |
|
152 | + elseif (!$read_only && !Vfs::check_access($url,Vfs::WRITABLE,$stat)) |
|
153 | + { |
|
154 | + // we are not allowed to edit it |
|
150 | 155 | { |
151 | 156 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be edited!"); |
157 | + } |
|
152 | 158 | if (!($options & STREAM_URL_STAT_QUIET)) |
153 | 159 | { |
154 | 160 | trigger_error(__METHOD__."($url,$mode,$options) file can not be edited!",E_USER_WARNING); |
@@ -157,7 +163,10 @@ discard block |
||
157 | 163 | } |
158 | 164 | if (!$read_only && self::deny_script($url)) |
159 | 165 | { |
160 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) permission denied, file is a script!"); |
|
166 | + if (self::LOG_LEVEL) |
|
167 | + { |
|
168 | + error_log(__METHOD__."($url,$mode,$options) permission denied, file is a script!"); |
|
169 | + } |
|
161 | 170 | if (!($options & STREAM_URL_STAT_QUIET)) |
162 | 171 | { |
163 | 172 | trigger_error(__METHOD__."($url,$mode,$options) permission denied, file is a script!",E_USER_WARNING); |
@@ -168,7 +177,10 @@ discard block |
||
168 | 177 | // open the "real" file |
169 | 178 | if (!($this->opened_stream = fopen($path=Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)),$mode,$options))) |
170 | 179 | { |
171 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) fopen('$path','$mode',$options) returned false!"); |
|
180 | + if (self::LOG_LEVEL) |
|
181 | + { |
|
182 | + error_log(__METHOD__."($url,$mode,$options) fopen('$path','$mode',$options) returned false!"); |
|
183 | + } |
|
172 | 184 | return false; |
173 | 185 | } |
174 | 186 | $this->opened_stream_url = $url; |
@@ -313,7 +325,10 @@ discard block |
||
313 | 325 | // check access rights (file need to exist and directory need to be writable |
314 | 326 | if (!file_exists($path) || is_dir($path) || !($dir = Vfs::dirname($url)) || !Vfs::check_access($dir,Vfs::WRITABLE)) |
315 | 327 | { |
316 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
|
328 | + if (self::LOG_LEVEL) |
|
329 | + { |
|
330 | + error_log(__METHOD__."($url) permission denied!"); |
|
331 | + } |
|
317 | 332 | return false; // no permission or file does not exist |
318 | 333 | } |
319 | 334 | return unlink($path); |
@@ -339,17 +354,26 @@ discard block |
||
339 | 354 | // check access rights |
340 | 355 | if (!($from_stat = self::url_stat($url_from,0)) || !($dir = Vfs::dirname($url_from)) || !Vfs::check_access($dir,Vfs::WRITABLE)) |
341 | 356 | { |
342 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $from[path] permission denied!"); |
|
357 | + if (self::LOG_LEVEL) |
|
358 | + { |
|
359 | + error_log(__METHOD__."($url_from,$url_to): $from[path] permission denied!"); |
|
360 | + } |
|
343 | 361 | return false; // no permission or file does not exist |
344 | 362 | } |
345 | 363 | if (!($to_dir = Vfs::dirname($url_to)) || !Vfs::check_access($to_dir,Vfs::WRITABLE,$to_dir_stat = self::url_stat($to_dir,0))) |
346 | 364 | { |
347 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $to_dir permission denied!"); |
|
365 | + if (self::LOG_LEVEL) |
|
366 | + { |
|
367 | + error_log(__METHOD__."($url_from,$url_to): $to_dir permission denied!"); |
|
368 | + } |
|
348 | 369 | return false; // no permission or parent-dir does not exist |
349 | 370 | } |
350 | 371 | if (self::deny_script($url_to)) |
351 | 372 | { |
352 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to) permission denied, file is a script!"); |
|
373 | + if (self::LOG_LEVEL) |
|
374 | + { |
|
375 | + error_log(__METHOD__."($url_from,$url_to) permission denied, file is a script!"); |
|
376 | + } |
|
353 | 377 | return false; |
354 | 378 | } |
355 | 379 | // the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems |
@@ -358,13 +382,19 @@ discard block |
||
358 | 382 | ($to_stat['mime'] === self::DIR_MIME_TYPE) !== ($from_stat['mime'] === self::DIR_MIME_TYPE)) |
359 | 383 | { |
360 | 384 | $is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no'; |
361 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $to[path] is $is_dir directory!"); |
|
385 | + if (self::LOG_LEVEL) |
|
386 | + { |
|
387 | + error_log(__METHOD__."($url_to,$url_from) $to[path] is $is_dir directory!"); |
|
388 | + } |
|
362 | 389 | return false; // no permission or file does not exist |
363 | 390 | } |
364 | 391 | // if destination file already exists, delete it |
365 | 392 | if ($to_stat && !self::unlink($url_to)) |
366 | 393 | { |
367 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
|
394 | + if (self::LOG_LEVEL) |
|
395 | + { |
|
396 | + error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
|
397 | + } |
|
368 | 398 | return false; |
369 | 399 | } |
370 | 400 | return rename(Vfs::decodePath($from['path']),Vfs::decodePath($to['path'])); |
@@ -399,7 +429,10 @@ discard block |
||
399 | 429 | // check access rights (in real filesystem AND by mount perms) |
400 | 430 | if (!$parent_url || file_exists($path) || !file_exists($parent) || !is_writable($parent) || !Vfs::check_access($parent_url,Vfs::WRITABLE)) |
401 | 431 | { |
402 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
|
432 | + if (self::LOG_LEVEL) |
|
433 | + { |
|
434 | + error_log(__METHOD__."($url) permission denied!"); |
|
435 | + } |
|
403 | 436 | return false; |
404 | 437 | } |
405 | 438 | return mkdir($path, 0700, $recursive); // setting mode 0700 allows (only) apache to write into the dir |
@@ -425,7 +458,10 @@ discard block |
||
425 | 458 | // check access rights (in real filesystem AND by mount perms) |
426 | 459 | if (!file_exists($path) || !is_writable($parent) || !($dir = Vfs::dirname($url)) || !Vfs::check_access($dir, Vfs::WRITABLE)) |
427 | 460 | { |
428 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
|
461 | + if (self::LOG_LEVEL) |
|
462 | + { |
|
463 | + error_log(__METHOD__."($url) permission denied!"); |
|
464 | + } |
|
429 | 465 | return false; |
430 | 466 | } |
431 | 467 | return rmdir($path); |
@@ -447,7 +483,10 @@ discard block |
||
447 | 483 | // check access rights (in real filesystem AND by mount perms) |
448 | 484 | if (!file_exists($path) || !is_writable($parent) || !($dir = Vfs::dirname($url)) || !Vfs::check_access($dir, Vfs::WRITABLE)) |
449 | 485 | { |
450 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
|
486 | + if (self::LOG_LEVEL) |
|
487 | + { |
|
488 | + error_log(__METHOD__."($url) permission denied!"); |
|
489 | + } |
|
451 | 490 | return false; |
452 | 491 | } |
453 | 492 | return touch($path,$time,$atime); |
@@ -510,7 +549,10 @@ discard block |
||
510 | 549 | */ |
511 | 550 | function dir_opendir ( $url, $options ) |
512 | 551 | { |
513 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options)"); |
|
552 | + if (self::LOG_LEVEL > 1) |
|
553 | + { |
|
554 | + error_log(__METHOD__."($url,$options)"); |
|
555 | + } |
|
514 | 556 | |
515 | 557 | $this->opened_dir = null; |
516 | 558 | |
@@ -520,7 +562,10 @@ discard block |
||
520 | 562 | |
521 | 563 | if (!($this->opened_dir = opendir($path))) |
522 | 564 | { |
523 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."($url,$options) opendir('$path') failed!"); |
|
565 | + if (self::LOG_LEVEL > 0) |
|
566 | + { |
|
567 | + error_log(__METHOD__."($url,$options) opendir('$path') failed!"); |
|
568 | + } |
|
524 | 569 | return false; |
525 | 570 | } |
526 | 571 | return true; |
@@ -576,7 +621,10 @@ discard block |
||
576 | 621 | $stat['mode'] = $stat[2] = $stat['mode'] & ~0222; |
577 | 622 | } |
578 | 623 | } |
579 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags) path=$path, mount_mode=".sprintf('0%o',$mode).", mode=".sprintf('0%o',$stat['mode']).'='.Vfs::int2mode($stat['mode'])); |
|
624 | + if (self::LOG_LEVEL > 1) |
|
625 | + { |
|
626 | + error_log(__METHOD__."($url,$flags) path=$path, mount_mode=".sprintf('0%o',$mode).", mode=".sprintf('0%o',$stat['mode']).'='.Vfs::int2mode($stat['mode'])); |
|
627 | + } |
|
580 | 628 | return $stat; |
581 | 629 | } |
582 | 630 | |
@@ -597,14 +645,23 @@ discard block |
||
597 | 645 | |
598 | 646 | $ignore = !($file === false || // stop if no more dirs or |
599 | 647 | ($file != '.' && $file != '..' )); // file not . or .. |
600 | - if (self::LOG_LEVEL > 1 && $ignore) error_log(__METHOD__.'() ignoring '.array2string($file)); |
|
648 | + if (self::LOG_LEVEL > 1 && $ignore) |
|
649 | + { |
|
650 | + error_log(__METHOD__.'() ignoring '.array2string($file)); |
|
651 | + } |
|
601 | 652 | } |
602 | 653 | while ($ignore); |
603 | 654 | |
604 | 655 | // encode special chars messing up url's |
605 | - if ($file !== false) $file = Vfs::encodePathComponent($file); |
|
656 | + if ($file !== false) |
|
657 | + { |
|
658 | + $file = Vfs::encodePathComponent($file); |
|
659 | + } |
|
606 | 660 | |
607 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'() returning '.array2string($file)); |
|
661 | + if (self::LOG_LEVEL > 1) |
|
662 | + { |
|
663 | + error_log(__METHOD__.'() returning '.array2string($file)); |
|
664 | + } |
|
608 | 665 | |
609 | 666 | return $file; |
610 | 667 | } |
@@ -759,9 +816,17 @@ discard block |
||
759 | 816 | list($url,$query) = explode('?',$_url,2); |
760 | 817 | $get = null; |
761 | 818 | parse_str($query,$get); |
762 | - if (empty($get['url'])) return false; // no download url given for this mount-point |
|
819 | + if (empty($get['url'])) |
|
820 | + { |
|
821 | + return false; |
|
822 | + } |
|
823 | + // no download url given for this mount-point |
|
763 | 824 | |
764 | - if (!($mount_url = Vfs::mount_url($_url))) return false; // no mount url found, should not happen |
|
825 | + if (!($mount_url = Vfs::mount_url($_url))) |
|
826 | + { |
|
827 | + return false; |
|
828 | + } |
|
829 | + // no mount url found, should not happen |
|
765 | 830 | list($mount_url) = explode('?',$mount_url); |
766 | 831 | |
767 | 832 | $relpath = substr($url,strlen($mount_url)); |
@@ -37,8 +37,6 @@ discard block |
||
37 | 37 | * Hook called after new accounts have been added |
38 | 38 | * |
39 | 39 | * @param array $data |
40 | - * @param int $data['account_id'] numerical id |
|
41 | - * @param string $data['account_lid'] account-name |
|
42 | 40 | */ |
43 | 41 | static function addAccount($data) |
44 | 42 | { |
@@ -58,9 +56,6 @@ discard block |
||
58 | 56 | * Hook called after accounts has been modified |
59 | 57 | * |
60 | 58 | * @param array $data |
61 | - * @param int $data['account_id'] numerical id |
|
62 | - * @param string $data['account_lid'] new account-name |
|
63 | - * @param string $data['old_loginid'] old account-name |
|
64 | 59 | */ |
65 | 60 | static function editAccount($data) |
66 | 61 | { |
@@ -79,9 +74,6 @@ discard block |
||
79 | 74 | * Hook called before an account get deleted |
80 | 75 | * |
81 | 76 | * @param array $data |
82 | - * @param int $data['account_id'] numerical id |
|
83 | - * @param string $data['account_lid'] account-name |
|
84 | - * @param int $data['new_owner'] account-id of new owner, or false if data should get deleted |
|
85 | 77 | */ |
86 | 78 | static function deleteAccount($data) |
87 | 79 | { |
@@ -114,8 +106,6 @@ discard block |
||
114 | 106 | * Hook called after new groups have been added |
115 | 107 | * |
116 | 108 | * @param array $data |
117 | - * @param int $data['account_id'] numerical id |
|
118 | - * @param string $data['account_lid'] group-name |
|
119 | 109 | */ |
120 | 110 | static function addGroup($data) |
121 | 111 | { |
@@ -140,9 +130,6 @@ discard block |
||
140 | 130 | * or if the group directory exists and creates it if not. |
141 | 131 | * |
142 | 132 | * @param array $data |
143 | - * @param int $data['account_id'] numerical id |
|
144 | - * @param string $data['account_lid'] new group-name |
|
145 | - * @param string $data['old_name'] old account-name |
|
146 | 133 | */ |
147 | 134 | static function editGroup($data) |
148 | 135 | { |
@@ -170,8 +157,6 @@ discard block |
||
170 | 157 | * Hook called before a group get deleted |
171 | 158 | * |
172 | 159 | * @param array $data |
173 | - * @param int $data['account_id'] numerical id |
|
174 | - * @param string $data['account_lid'] account-name |
|
175 | 160 | */ |
176 | 161 | static function deleteGroup($data) |
177 | 162 | { |
@@ -42,7 +42,10 @@ discard block |
||
42 | 42 | */ |
43 | 43 | static function addAccount($data) |
44 | 44 | { |
45 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')'); |
|
45 | + if (self::LOG_LEVEL > 0) |
|
46 | + { |
|
47 | + error_log(__METHOD__.'('.array2string($data).')'); |
|
48 | + } |
|
46 | 49 | // create a user-dir |
47 | 50 | Api\Vfs::$is_root = true; |
48 | 51 | if (Api\Vfs::mkdir($dir='/home/'.$data['account_lid'],0700,0)) |
@@ -64,7 +67,10 @@ discard block |
||
64 | 67 | */ |
65 | 68 | static function editAccount($data) |
66 | 69 | { |
67 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')'); |
|
70 | + if (self::LOG_LEVEL > 0) |
|
71 | + { |
|
72 | + error_log(__METHOD__.'('.array2string($data).')'); |
|
73 | + } |
|
68 | 74 | if (empty($data['account_lid']) || empty($data['old_loginid']) || $data['account_lid'] == $data['old_loginid']) |
69 | 75 | { |
70 | 76 | return; // nothing to do here |
@@ -85,7 +91,10 @@ discard block |
||
85 | 91 | */ |
86 | 92 | static function deleteAccount($data) |
87 | 93 | { |
88 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')'); |
|
94 | + if (self::LOG_LEVEL > 0) |
|
95 | + { |
|
96 | + error_log(__METHOD__.'('.array2string($data).')'); |
|
97 | + } |
|
89 | 98 | Api\Vfs::$is_root = true; |
90 | 99 | if ($data['new_owner'] && ($new_lid = $GLOBALS['egw']->accounts->id2name($data['new_owner']))) |
91 | 100 | { |
@@ -119,8 +128,14 @@ discard block |
||
119 | 128 | */ |
120 | 129 | static function addGroup($data) |
121 | 130 | { |
122 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')'); |
|
123 | - if (empty($data['account_lid'])) throw new Api\Exception\WrongParameter('account_lid must not be empty!'); |
|
131 | + if (self::LOG_LEVEL > 0) |
|
132 | + { |
|
133 | + error_log(__METHOD__.'('.array2string($data).')'); |
|
134 | + } |
|
135 | + if (empty($data['account_lid'])) |
|
136 | + { |
|
137 | + throw new Api\Exception\WrongParameter('account_lid must not be empty!'); |
|
138 | + } |
|
124 | 139 | |
125 | 140 | // create a group-dir |
126 | 141 | Api\Vfs::$is_root = true; |
@@ -146,8 +161,14 @@ discard block |
||
146 | 161 | */ |
147 | 162 | static function editGroup($data) |
148 | 163 | { |
149 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')'); |
|
150 | - if (empty($data['account_lid']) || empty($data['old_name'])) throw new Api\Exception\WrongParameter('account_lid and old_name must not be empty!'); |
|
164 | + if (self::LOG_LEVEL > 0) |
|
165 | + { |
|
166 | + error_log(__METHOD__.'('.array2string($data).')'); |
|
167 | + } |
|
168 | + if (empty($data['account_lid']) || empty($data['old_name'])) |
|
169 | + { |
|
170 | + throw new Api\Exception\WrongParameter('account_lid and old_name must not be empty!'); |
|
171 | + } |
|
151 | 172 | |
152 | 173 | if ($data['account_lid'] == $data['old_name']) |
153 | 174 | { |
@@ -175,7 +196,10 @@ discard block |
||
175 | 196 | */ |
176 | 197 | static function deleteGroup($data) |
177 | 198 | { |
178 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')'); |
|
199 | + if (self::LOG_LEVEL > 0) |
|
200 | + { |
|
201 | + error_log(__METHOD__.'('.array2string($data).')'); |
|
202 | + } |
|
179 | 203 | |
180 | 204 | if(empty($data['account_lid']) || $data['account_lid'] == '/') |
181 | 205 | { |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')'); |
46 | 46 | // create a user-dir |
47 | 47 | Api\Vfs::$is_root = true; |
48 | - if (Api\Vfs::file_exists($dir='/home/'.$data['account_lid']) || Api\Vfs::mkdir($dir, 0700, 0)) |
|
48 | + if (Api\Vfs::file_exists($dir = '/home/'.$data['account_lid']) || Api\Vfs::mkdir($dir, 0700, 0)) |
|
49 | 49 | { |
50 | - Api\Vfs::chown($dir,$data['account_id']); |
|
51 | - Api\Vfs::chgrp($dir,0); |
|
52 | - Api\Vfs::chmod($dir,0700); // only user has access |
|
50 | + Api\Vfs::chown($dir, $data['account_id']); |
|
51 | + Api\Vfs::chgrp($dir, 0); |
|
52 | + Api\Vfs::chmod($dir, 0700); // only user has access |
|
53 | 53 | } |
54 | 54 | Api\Vfs::$is_root = false; |
55 | 55 | } |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')'); |
68 | 68 | if (empty($data['account_lid']) || empty($data['old_loginid']) || $data['account_lid'] == $data['old_loginid']) |
69 | 69 | { |
70 | - return; // nothing to do here |
|
70 | + return; // nothing to do here |
|
71 | 71 | } |
72 | 72 | // rename the user-dir |
73 | 73 | Api\Vfs::$is_root = true; |
74 | - Api\Vfs::rename('/home/'.$data['old_loginid'],'/home/'.$data['account_lid']); |
|
74 | + Api\Vfs::rename('/home/'.$data['old_loginid'], '/home/'.$data['account_lid']); |
|
75 | 75 | Api\Vfs::$is_root = false; |
76 | 76 | } |
77 | 77 | |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | if ($data['new_owner'] && ($new_lid = $GLOBALS['egw']->accounts->id2name($data['new_owner']))) |
91 | 91 | { |
92 | 92 | // copy content of user-dir to new owner's user-dir as old-home-$name |
93 | - for ($i=''; file_exists(Api\Vfs::PREFIX.($new_dir = '/home/'.$new_lid.'/old-home-'.$data['account_lid'].$i)); $i++) |
|
93 | + for ($i = ''; file_exists(Api\Vfs::PREFIX.($new_dir = '/home/'.$new_lid.'/old-home-'.$data['account_lid'].$i)); $i++) |
|
94 | 94 | { |
95 | 95 | |
96 | 96 | } |
97 | - Api\Vfs::rename('/home/'.$data['account_lid'],$new_dir); |
|
97 | + Api\Vfs::rename('/home/'.$data['account_lid'], $new_dir); |
|
98 | 98 | // make the new owner the owner of the dir and it's content |
99 | - Api\Vfs::find($new_dir,array(),array('egw_vfs','chown'),$data['new_owner']); |
|
99 | + Api\Vfs::find($new_dir, array(), array('egw_vfs', 'chown'), $data['new_owner']); |
|
100 | 100 | } |
101 | - elseif(!empty($data['account_lid']) && $data['account_lid'] != '/') |
|
101 | + elseif (!empty($data['account_lid']) && $data['account_lid'] != '/') |
|
102 | 102 | { |
103 | 103 | // delete the user-directory |
104 | 104 | Api\Vfs::remove('/home/'.$data['account_lid']); |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | |
125 | 125 | // create a group-dir |
126 | 126 | Api\Vfs::$is_root = true; |
127 | - if (Api\Vfs::file_exists($dir='/home/'.$data['account_lid']) || Api\Vfs::mkdir($dir, 0070, 0)) |
|
127 | + if (Api\Vfs::file_exists($dir = '/home/'.$data['account_lid']) || Api\Vfs::mkdir($dir, 0070, 0)) |
|
128 | 128 | { |
129 | - Api\Vfs::chown($dir,0); |
|
130 | - Api\Vfs::chgrp($dir,abs($data['account_id'])); // gid in Vfs is positiv! |
|
131 | - Api\Vfs::chmod($dir,0070); // only group has access |
|
129 | + Api\Vfs::chown($dir, 0); |
|
130 | + Api\Vfs::chgrp($dir, abs($data['account_id'])); // gid in Vfs is positiv! |
|
131 | + Api\Vfs::chmod($dir, 0070); // only group has access |
|
132 | 132 | } |
133 | 133 | Api\Vfs::$is_root = false; |
134 | 134 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | { |
162 | 162 | // rename the group-dir |
163 | 163 | Api\Vfs::$is_root = true; |
164 | - Api\Vfs::rename('/home/'.$data['old_name'],'/home/'.$data['account_lid']); |
|
164 | + Api\Vfs::rename('/home/'.$data['old_name'], '/home/'.$data['account_lid']); |
|
165 | 165 | Api\Vfs::$is_root = false; |
166 | 166 | } |
167 | 167 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | { |
178 | 178 | if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')'); |
179 | 179 | |
180 | - if(empty($data['account_lid']) || $data['account_lid'] == '/') |
|
180 | + if (empty($data['account_lid']) || $data['account_lid'] == '/') |
|
181 | 181 | { |
182 | 182 | throw new Api\Exception\AssertionFailed(__METHOD__.'('.array2string($data).') account_lid NOT set!'); |
183 | 183 | } |
@@ -316,7 +316,7 @@ |
||
316 | 316 | * |
317 | 317 | * @param string $url URL that was passed to opendir() and that this object is expected to explore. |
318 | 318 | * @param $options |
319 | - * @return booelan |
|
319 | + * @return boolean |
|
320 | 320 | */ |
321 | 321 | function dir_opendir ( $url, $options ) |
322 | 322 | { |
@@ -26,7 +26,9 @@ discard block |
||
26 | 26 | */ |
27 | 27 | if (!class_exists('EGroupware\\Api\\Vfs\\Links\\LinksParent', false)) |
28 | 28 | { |
29 | - class LinksParent extends Vfs\Sqlfs\StreamWrapper {} |
|
29 | + class LinksParent extends Vfs\Sqlfs\StreamWrapper |
|
30 | + { |
|
31 | +} |
|
30 | 32 | } |
31 | 33 | |
32 | 34 | /** |
@@ -116,7 +118,10 @@ discard block |
||
116 | 118 | $access = Api\Link::file_access($app,$id,$required,$rel_path,Vfs::$user); |
117 | 119 | $what = "from Api\Link::file_access('$app',$id,$required,'$rel_path,".Vfs::$user.")"; |
118 | 120 | } |
119 | - if (self::DEBUG) error_log(__METHOD__."($url,$check) user=".Vfs::$user." ($what) ".($access?"access granted ($app:$id:$rel_path)":'no access!!!')); |
|
121 | + if (self::DEBUG) |
|
122 | + { |
|
123 | + error_log(__METHOD__."($url,$check) user=".Vfs::$user." ($what) ".($access?"access granted ($app:$id:$rel_path)":'no access!!!')); |
|
124 | + } |
|
120 | 125 | return $access; |
121 | 126 | } |
122 | 127 | |
@@ -180,7 +185,10 @@ discard block |
||
180 | 185 | ); |
181 | 186 | } |
182 | 187 | } |
183 | - if (self::DEBUG) error_log(__METHOD__."('$url', $flags) calling parent::url_stat(,,".array2string($eacl_check).') returning '.array2string($ret)); |
|
188 | + if (self::DEBUG) |
|
189 | + { |
|
190 | + error_log(__METHOD__."('$url', $flags) calling parent::url_stat(,,".array2string($eacl_check).') returning '.array2string($ret)); |
|
191 | + } |
|
184 | 192 | return $ret; |
185 | 193 | } |
186 | 194 | |
@@ -238,19 +246,30 @@ discard block |
||
238 | 246 | |
239 | 247 | if($path[0] != '/') |
240 | 248 | { |
241 | - if (strpos($path,'?') !== false) $query = Vfs::parse_url($path,PHP_URL_QUERY); |
|
249 | + if (strpos($path,'?') !== false) |
|
250 | + { |
|
251 | + $query = Vfs::parse_url($path,PHP_URL_QUERY); |
|
252 | + } |
|
242 | 253 | $path = Vfs::parse_url($path,PHP_URL_PATH).($query ? '?'.$query : ''); |
243 | 254 | } |
244 | 255 | list(,$apps,$app,$id) = explode('/',$path); |
245 | 256 | |
246 | 257 | $ret = false; |
247 | - if ($apps == 'apps' && $app && !$id || self::check_extended_acl($path,Vfs::WRITABLE)) // app directory itself is allways ok |
|
258 | + if ($apps == 'apps' && $app && !$id || self::check_extended_acl($path,Vfs::WRITABLE)) |
|
259 | + { |
|
260 | + // app directory itself is allways ok |
|
248 | 261 | { |
249 | - $current_is_root = Vfs::$is_root; Vfs::$is_root = true; |
|
262 | + $current_is_root = Vfs::$is_root; |
|
263 | + } |
|
264 | + Vfs::$is_root = true; |
|
250 | 265 | $current_user = Vfs::$user; Vfs::$user = 0; |
251 | 266 | |
252 | 267 | $ret = parent::mkdir($path,0,$options|STREAM_MKDIR_RECURSIVE); |
253 | - if ($id) parent::chmod($path,0); // no other rights |
|
268 | + if ($id) |
|
269 | + { |
|
270 | + parent::chmod($path,0); |
|
271 | + } |
|
272 | + // no other rights |
|
254 | 273 | |
255 | 274 | Vfs::$user = $current_user; |
256 | 275 | Vfs::$is_root = $current_is_root; |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | * @param int $check mode to check: one or more or'ed together of: 4 = read, 2 = write, 1 = executable |
77 | 77 | * @return boolean |
78 | 78 | */ |
79 | - static function check_extended_acl($url,$check) |
|
79 | + static function check_extended_acl($url, $check) |
|
80 | 80 | { |
81 | 81 | if (Vfs::$is_root) |
82 | 82 | { |
83 | 83 | return true; |
84 | 84 | } |
85 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
85 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
86 | 86 | |
87 | - list(,$apps,$app,$id,$rel_path) = explode('/',$path,5); |
|
87 | + list(,$apps, $app, $id, $rel_path) = explode('/', $path, 5); |
|
88 | 88 | |
89 | 89 | if ($apps != 'apps') |
90 | 90 | { |
91 | - $access = false; // no access to anything, but /apps |
|
91 | + $access = false; // no access to anything, but /apps |
|
92 | 92 | $what = '!= apps'; |
93 | 93 | } |
94 | 94 | elseif (!$app) |
95 | 95 | { |
96 | - $access = !($check & Vfs::WRITABLE); // always grant read access to /apps |
|
96 | + $access = !($check&Vfs::WRITABLE); // always grant read access to /apps |
|
97 | 97 | $what = '!$app'; |
98 | 98 | } |
99 | - elseif(!isset($GLOBALS['egw_info']['user']['apps'][$app])) |
|
99 | + elseif (!isset($GLOBALS['egw_info']['user']['apps'][$app])) |
|
100 | 100 | { |
101 | - $access = false; // user has no access to the $app application |
|
101 | + $access = false; // user has no access to the $app application |
|
102 | 102 | $what = 'no app-rights'; |
103 | 103 | } |
104 | 104 | elseif (!$id) |
105 | 105 | { |
106 | - $access = true; // grant read&write access to /apps/$app |
|
106 | + $access = true; // grant read&write access to /apps/$app |
|
107 | 107 | $what = 'app dir'; |
108 | 108 | } |
109 | 109 | // allow applications to implement their own access control to the file storage |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | else |
113 | 113 | { |
114 | 114 | // vfs & stream-wrapper use posix rights, Api\Link::file_access uses Api\Acl::{EDIT|READ}! |
115 | - $required = $check & Vfs::WRITABLE ? Api\Acl::EDIT : Api\Acl::READ; |
|
116 | - $access = Api\Link::file_access($app,$id,$required,$rel_path,Vfs::$user); |
|
115 | + $required = $check&Vfs::WRITABLE ? Api\Acl::EDIT : Api\Acl::READ; |
|
116 | + $access = Api\Link::file_access($app, $id, $required, $rel_path, Vfs::$user); |
|
117 | 117 | $what = "from Api\Link::file_access('$app',$id,$required,'$rel_path,".Vfs::$user.")"; |
118 | 118 | } |
119 | - if (self::DEBUG) error_log(__METHOD__."($url,$check) user=".Vfs::$user." ($what) ".($access?"access granted ($app:$id:$rel_path)":'no access!!!')); |
|
119 | + if (self::DEBUG) error_log(__METHOD__."($url,$check) user=".Vfs::$user." ($what) ".($access ? "access granted ($app:$id:$rel_path)" : 'no access!!!')); |
|
120 | 120 | return $access; |
121 | 121 | } |
122 | 122 | |
@@ -137,19 +137,19 @@ discard block |
||
137 | 137 | * stat triggers it's own warning anyway, so it makes no sense to trigger one by our stream-wrapper! |
138 | 138 | * @return array |
139 | 139 | */ |
140 | - static function url_stat ( $url, $flags ) |
|
140 | + static function url_stat($url, $flags) |
|
141 | 141 | { |
142 | - $eacl_check=self::check_extended_acl($url,Vfs::READABLE); |
|
142 | + $eacl_check = self::check_extended_acl($url, Vfs::READABLE); |
|
143 | 143 | |
144 | 144 | // return vCard as /.entry |
145 | - if ( $eacl_check && substr($url,-7) == '/.entry' && |
|
146 | - (list($app) = array_slice(explode('/',$url),-3,1)) && $app === 'addressbook') |
|
145 | + if ($eacl_check && substr($url, -7) == '/.entry' && |
|
146 | + (list($app) = array_slice(explode('/', $url), -3, 1)) && $app === 'addressbook') |
|
147 | 147 | { |
148 | 148 | $ret = array( |
149 | 149 | 'ino' => md5($url), |
150 | 150 | 'name' => '.entry', |
151 | - 'mode' => self::MODE_FILE|Vfs::READABLE, // required by the stream wrapper |
|
152 | - 'size' => 1024, // fmail does NOT attach files with size 0! |
|
151 | + 'mode' => self::MODE_FILE|Vfs::READABLE, // required by the stream wrapper |
|
152 | + 'size' => 1024, // fmail does NOT attach files with size 0! |
|
153 | 153 | 'uid' => 0, |
154 | 154 | 'gid' => 0, |
155 | 155 | 'mtime' => time(), |
@@ -160,15 +160,15 @@ discard block |
||
160 | 160 | ); |
161 | 161 | } |
162 | 162 | // if entry directory does not exist --> return fake directory |
163 | - elseif (!($ret = parent::url_stat($url,$flags,$eacl_check)) && $eacl_check) |
|
163 | + elseif (!($ret = parent::url_stat($url, $flags, $eacl_check)) && $eacl_check) |
|
164 | 164 | { |
165 | - list(,/*$apps*/,/*$app*/,$id,$rel_path) = explode('/', Vfs::parse_url($url, PHP_URL_PATH), 5); |
|
165 | + list(,/*$apps*/, /*$app*/, $id, $rel_path) = explode('/', Vfs::parse_url($url, PHP_URL_PATH), 5); |
|
166 | 166 | if ($id && !isset($rel_path)) |
167 | 167 | { |
168 | 168 | $ret = array( |
169 | 169 | 'ino' => md5($url), |
170 | 170 | 'name' => $id, |
171 | - 'mode' => self::MODE_DIR, // required by the stream wrapper |
|
171 | + 'mode' => self::MODE_DIR, // required by the stream wrapper |
|
172 | 172 | 'size' => 0, |
173 | 173 | 'uid' => 0, |
174 | 174 | 'gid' => 0, |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | * @param int $fs_id =null fs_id to use, to not query it again (eg. because it's already deleted) |
196 | 196 | * @return boolean true if acl is set/deleted, false on error |
197 | 197 | */ |
198 | - static function eacl($path,$rights=null,$owner=null,$fs_id=null) |
|
198 | + static function eacl($path, $rights = null, $owner = null, $fs_id = null) |
|
199 | 199 | { |
200 | - unset($path, $rights, $owner, $fs_id); // not used, but required by function signature |
|
200 | + unset($path, $rights, $owner, $fs_id); // not used, but required by function signature |
|
201 | 201 | |
202 | 202 | return false; |
203 | 203 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | static function get_eacl($path) |
214 | 214 | { |
215 | - unset($path); // not used, but required by function signature |
|
215 | + unset($path); // not used, but required by function signature |
|
216 | 216 | |
217 | 217 | return false; |
218 | 218 | } |
@@ -232,25 +232,25 @@ discard block |
||
232 | 232 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE, we allways use recursive! |
233 | 233 | * @return boolean TRUE on success or FALSE on failure |
234 | 234 | */ |
235 | - static function mkdir($path,$mode,$options) |
|
235 | + static function mkdir($path, $mode, $options) |
|
236 | 236 | { |
237 | - unset($mode); // not used, but required by function signature |
|
237 | + unset($mode); // not used, but required by function signature |
|
238 | 238 | |
239 | - if($path[0] != '/') |
|
239 | + if ($path[0] != '/') |
|
240 | 240 | { |
241 | - if (strpos($path,'?') !== false) $query = Vfs::parse_url($path,PHP_URL_QUERY); |
|
242 | - $path = Vfs::parse_url($path,PHP_URL_PATH).($query ? '?'.$query : ''); |
|
241 | + if (strpos($path, '?') !== false) $query = Vfs::parse_url($path, PHP_URL_QUERY); |
|
242 | + $path = Vfs::parse_url($path, PHP_URL_PATH).($query ? '?'.$query : ''); |
|
243 | 243 | } |
244 | - list(,$apps,$app,$id) = explode('/',$path); |
|
244 | + list(,$apps, $app, $id) = explode('/', $path); |
|
245 | 245 | |
246 | 246 | $ret = false; |
247 | - if ($apps == 'apps' && $app && !$id || self::check_extended_acl($path,Vfs::WRITABLE)) // app directory itself is allways ok |
|
247 | + if ($apps == 'apps' && $app && !$id || self::check_extended_acl($path, Vfs::WRITABLE)) // app directory itself is allways ok |
|
248 | 248 | { |
249 | 249 | $current_is_root = Vfs::$is_root; Vfs::$is_root = true; |
250 | 250 | $current_user = Vfs::$user; Vfs::$user = 0; |
251 | 251 | |
252 | - $ret = parent::mkdir($path,0,$options|STREAM_MKDIR_RECURSIVE); |
|
253 | - if ($id) parent::chmod($path,0); // no other rights |
|
252 | + $ret = parent::mkdir($path, 0, $options|STREAM_MKDIR_RECURSIVE); |
|
253 | + if ($id) parent::chmod($path, 0); // no other rights |
|
254 | 254 | |
255 | 255 | Vfs::$user = $current_user; |
256 | 256 | Vfs::$is_root = $current_is_root; |
@@ -274,23 +274,23 @@ discard block |
||
274 | 274 | * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set |
275 | 275 | * @return boolean true if the ressource was opened successful, otherwise false |
276 | 276 | */ |
277 | - function stream_open ( $url, $mode, $options, &$opened_path ) |
|
277 | + function stream_open($url, $mode, $options, &$opened_path) |
|
278 | 278 | { |
279 | 279 | // the following call is necessary to fill sqlfs_stream_wrapper::$stat_cache, WITH the extendes ACL! |
280 | - $stat = self::url_stat($url,0); |
|
280 | + $stat = self::url_stat($url, 0); |
|
281 | 281 | //error_log(__METHOD__."('$url', '$mode', $options) stat=".array2string($stat)); |
282 | 282 | |
283 | 283 | // return vCard as /.entry |
284 | - if ($stat && $mode[0] == 'r' && substr($url,-7) === '/.entry' && |
|
285 | - (list($app) = array_slice(explode('/',$url),-3,1)) && $app === 'addressbook') |
|
284 | + if ($stat && $mode[0] == 'r' && substr($url, -7) === '/.entry' && |
|
285 | + (list($app) = array_slice(explode('/', $url), -3, 1)) && $app === 'addressbook') |
|
286 | 286 | { |
287 | - list($id) = array_slice(explode('/',$url),-2,1); |
|
288 | - $ab_vcard = new addressbook_vcal('addressbook','text/vcard'); |
|
287 | + list($id) = array_slice(explode('/', $url), -2, 1); |
|
288 | + $ab_vcard = new addressbook_vcal('addressbook', 'text/vcard'); |
|
289 | 289 | if (!($charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'])) |
290 | 290 | { |
291 | 291 | $charset = 'utf-8'; |
292 | 292 | } |
293 | - if (!($vcard =& $ab_vcard->getVCard($id, $charset))) |
|
293 | + if (!($vcard = & $ab_vcard->getVCard($id, $charset))) |
|
294 | 294 | { |
295 | 295 | error_log(__METHOD__."('$url', '$mode', $options) addressbook_vcal::getVCard($id) returned false!"); |
296 | 296 | return false; |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | if ($mode[0] != 'r' && ($dir = Vfs::dirname($url)) && |
306 | 306 | !parent::url_stat($dir, 0) && self::check_extended_acl($dir, Vfs::WRITABLE)) |
307 | 307 | { |
308 | - self::mkdir($dir,0,STREAM_MKDIR_RECURSIVE); |
|
308 | + self::mkdir($dir, 0, STREAM_MKDIR_RECURSIVE); |
|
309 | 309 | } |
310 | - return parent::stream_open($url,$mode,$options,$opened_path); |
|
310 | + return parent::stream_open($url, $mode, $options, $opened_path); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param $options |
320 | 320 | * @return booelan |
321 | 321 | */ |
322 | - function dir_opendir ( $url, $options ) |
|
322 | + function dir_opendir($url, $options) |
|
323 | 323 | { |
324 | 324 | if (!parent::url_stat($url, STREAM_URL_STAT_QUIET) && self::url_stat($url, STREAM_URL_STAT_QUIET)) |
325 | 325 | { |
@@ -98,7 +98,6 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * Protected constructor called via self::create_session |
100 | 100 | * |
101 | - * @param string $token |
|
102 | 101 | * @param array $share |
103 | 102 | */ |
104 | 103 | protected function __construct(array $share) |
@@ -109,6 +108,7 @@ discard block |
||
109 | 108 | |
110 | 109 | /** |
111 | 110 | * Get token from url |
111 | + * @return string |
|
112 | 112 | */ |
113 | 113 | public static function get_token() |
114 | 114 | { |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | const WRITABLE = 'share_rw'; |
73 | 73 | |
74 | 74 | /** |
75 | - * Modes for sharing files |
|
76 | - * |
|
77 | - * @var array |
|
78 | - */ |
|
75 | + * Modes for sharing files |
|
76 | + * |
|
77 | + * @var array |
|
78 | + */ |
|
79 | 79 | static $modes = array( |
80 | 80 | self::ATTACH => array( |
81 | 81 | 'label' => 'Attachment', |
@@ -112,16 +112,16 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public static function get_token() |
114 | 114 | { |
115 | - // WebDAV has no concept of a query string and clients (including cadaver) |
|
116 | - // seem to pass '?' unencoded, so we need to extract the path info out |
|
117 | - // of the request URI ourselves |
|
118 | - // if request URI contains a full url, remove schema and domain |
|
115 | + // WebDAV has no concept of a query string and clients (including cadaver) |
|
116 | + // seem to pass '?' unencoded, so we need to extract the path info out |
|
117 | + // of the request URI ourselves |
|
118 | + // if request URI contains a full url, remove schema and domain |
|
119 | 119 | $matches = null; |
120 | - if (preg_match('|^https?://[^/]+(/.*)$|', $path_info=$_SERVER['REQUEST_URI'], $matches)) |
|
121 | - { |
|
122 | - $path_info = $matches[1]; |
|
123 | - } |
|
124 | - $path_info = substr($path_info, strlen($_SERVER['SCRIPT_NAME'])); |
|
120 | + if (preg_match('|^https?://[^/]+(/.*)$|', $path_info=$_SERVER['REQUEST_URI'], $matches)) |
|
121 | + { |
|
122 | + $path_info = $matches[1]; |
|
123 | + } |
|
124 | + $path_info = substr($path_info, strlen($_SERVER['SCRIPT_NAME'])); |
|
125 | 125 | list(, $token/*, $path*/) = preg_split('|[/?]|', $path_info, 3); |
126 | 126 | |
127 | 127 | return $token; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | // of the request URI ourselves |
118 | 118 | // if request URI contains a full url, remove schema and domain |
119 | 119 | $matches = null; |
120 | - if (preg_match('|^https?://[^/]+(/.*)$|', $path_info=$_SERVER['REQUEST_URI'], $matches)) |
|
120 | + if (preg_match('|^https?://[^/]+(/.*)$|', $path_info = $_SERVER['REQUEST_URI'], $matches)) |
|
121 | 121 | { |
122 | 122 | $path_info = $matches[1]; |
123 | 123 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param boolean $keep_session =null null: create a new session, true: try mounting it into existing (already verified) session |
156 | 156 | * @return string with sessionid, does NOT return if no session created |
157 | 157 | */ |
158 | - public static function create_session($keep_session=null) |
|
158 | + public static function create_session($keep_session = null) |
|
159 | 159 | { |
160 | 160 | self::$db = $GLOBALS['egw']->db; |
161 | 161 | |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | // need to reset fs_tab, as resolve_url does NOT work with just share mounted |
209 | 209 | if (count($GLOBALS['egw_info']['server']['vfs_fstab']) <= 1) |
210 | 210 | { |
211 | - unset($GLOBALS['egw_info']['server']['vfs_fstab']); // triggers reset of fstab in mount() |
|
211 | + unset($GLOBALS['egw_info']['server']['vfs_fstab']); // triggers reset of fstab in mount() |
|
212 | 212 | $GLOBALS['egw_info']['server']['vfs_fstab'] = Vfs::mount(); |
213 | 213 | Vfs::clearstatcache(); |
214 | 214 | } |
215 | - $share['resolve_url'] = Vfs::resolve_url($share['share_path'], true, true, true, true); // true = fix evtl. contained url parameter |
|
215 | + $share['resolve_url'] = Vfs::resolve_url($share['share_path'], true, true, true, true); // true = fix evtl. contained url parameter |
|
216 | 216 | // if share not writable append ro=1 to mount url to make it readonly |
217 | 217 | if (!self::$db->from_bool($share['share_writable'])) |
218 | 218 | { |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | |
258 | 258 | // update accessed timestamp |
259 | 259 | self::$db->update(self::TABLE, array( |
260 | - 'share_last_accessed' => $share['share_last_accessed']=time(), |
|
260 | + 'share_last_accessed' => $share['share_last_accessed'] = time(), |
|
261 | 261 | ), array( |
262 | 262 | 'share_id' => $share['share_id'], |
263 | 263 | ), __LINE__, __FILE__); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | if ($keep_session || $sessionid) |
300 | 300 | { |
301 | 301 | $_SESSION[Api\Session::EGW_INFO_CACHE] = $GLOBALS['egw_info']; |
302 | - unset($_SESSION[Api\Session::EGW_INFO_CACHE]['flags']); // dont save the flags, they change on each request |
|
302 | + unset($_SESSION[Api\Session::EGW_INFO_CACHE]['flags']); // dont save the flags, they change on each request |
|
303 | 303 | |
304 | 304 | $_SESSION[Api\Session::EGW_OBJECT_CACHE] = serialize($GLOBALS['egw']); |
305 | 305 | } |
@@ -368,8 +368,7 @@ discard block |
||
368 | 368 | // generate random token (using oppenssl if available otherwise mt_rand based Api\Auth::randomstring) |
369 | 369 | do { |
370 | 370 | $token = function_exists('openssl_random_pseudo_bytes') ? |
371 | - base64_encode(openssl_random_pseudo_bytes(3*self::TOKEN_LENGTH/4)) : |
|
372 | - Api\Auth::randomstring(self::TOKEN_LENGTH); |
|
371 | + base64_encode(openssl_random_pseudo_bytes(3 * self::TOKEN_LENGTH / 4)) : Api\Auth::randomstring(self::TOKEN_LENGTH); |
|
373 | 372 | // base64 can contain chars not allowed in our vfs-urls eg. / or # |
374 | 373 | } while ($token != Vfs::encodePathComponent($token)); |
375 | 374 | |
@@ -389,13 +388,13 @@ discard block |
||
389 | 388 | * @throw Api\Exception\AssertionFailed if user temp. directory does not exist and can not be created |
390 | 389 | * @return array with share data, eg. value for key 'share_token' |
391 | 390 | */ |
392 | - public static function create($path, $mode, $name, $recipients, $extra=array()) |
|
391 | + public static function create($path, $mode, $name, $recipients, $extra = array()) |
|
393 | 392 | { |
394 | 393 | if (!isset(self::$db)) self::$db = $GLOBALS['egw']->db; |
395 | 394 | |
396 | 395 | if (empty($name)) $name = $path; |
397 | 396 | |
398 | - $path2tmp =& Api\Cache::getSession(__CLASS__, 'path2tmp'); |
|
397 | + $path2tmp = & Api\Cache::getSession(__CLASS__, 'path2tmp'); |
|
399 | 398 | |
400 | 399 | // allow filesystem path only for temp_dir |
401 | 400 | $temp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/'; |
@@ -406,7 +405,7 @@ discard block |
||
406 | 405 | } |
407 | 406 | else |
408 | 407 | { |
409 | - if(parse_url($path, PHP_URL_SCHEME) !== 'vfs') |
|
408 | + if (parse_url($path, PHP_URL_SCHEME) !== 'vfs') |
|
410 | 409 | { |
411 | 410 | $path = 'vfs://default'.($path[0] == '/' ? '' : '/').$path; |
412 | 411 | } |
@@ -420,7 +419,7 @@ discard block |
||
420 | 419 | } |
421 | 420 | // check if file has been shared before, with identical attributes |
422 | 421 | if (($mode != self::LINK || isset($path2tmp[$path])) && |
423 | - ($share = self::$db->select(self::TABLE, '*', $extra+array( |
|
422 | + ($share = self::$db->select(self::TABLE, '*', $extra + array( |
|
424 | 423 | 'share_path' => $mode == 'link' ? $path2tmp[$path] : $vfs_path, |
425 | 424 | 'share_owner' => $GLOBALS['egw_info']['user']['account_id'], |
426 | 425 | 'share_expires' => null, |
@@ -431,7 +430,7 @@ discard block |
||
431 | 430 | // if yes, just add additional recipients |
432 | 431 | $share['share_with'] = $share['share_with'] ? explode(',', $share['share_with']) : array(); |
433 | 432 | $need_save = false; |
434 | - foreach((array)$recipients as $recipient) |
|
433 | + foreach ((array)$recipients as $recipient) |
|
435 | 434 | { |
436 | 435 | if (!in_array($recipient, $share['share_with'])) |
437 | 436 | { |
@@ -461,9 +460,9 @@ discard block |
||
461 | 460 | } |
462 | 461 | $n = 0; |
463 | 462 | do { |
464 | - $tmp_file = Vfs::concat($user_tmp, ($n?$n.'.':'').Vfs::basename($name)); |
|
463 | + $tmp_file = Vfs::concat($user_tmp, ($n ? $n.'.' : '').Vfs::basename($name)); |
|
465 | 464 | } |
466 | - while(!(is_dir($path) && Vfs::mkdir($tmp_file, null, STREAM_MKDIR_RECURSIVE) || |
|
465 | + while (!(is_dir($path) && Vfs::mkdir($tmp_file, null, STREAM_MKDIR_RECURSIVE) || |
|
467 | 466 | !is_dir($path) && (!Vfs::file_exists($tmp_file) && ($fp = Vfs::fopen($tmp_file, 'x')) || |
468 | 467 | // do not copy identical files again to users tmp dir, just re-use them |
469 | 468 | Vfs::file_exists($tmp_file) && Vfs::compare(Vfs::PREFIX.$tmp_file, $path))) && $n++ < 100); |
@@ -488,12 +487,12 @@ discard block |
||
488 | 487 | $async = new Api\Asyncservice(); |
489 | 488 | if (!$async->read('egw_sharing-tmp-cleanup')) |
490 | 489 | { |
491 | - $async->set_timer(array('day' => 28),'egw_sharing-tmp_cleanup','egw_sharing::tmp_cleanup',null); |
|
490 | + $async->set_timer(array('day' => 28), 'egw_sharing-tmp_cleanup', 'egw_sharing::tmp_cleanup', null); |
|
492 | 491 | } |
493 | 492 | } |
494 | 493 | |
495 | 494 | $i = 0; |
496 | - while(true) // self::token() can return an existing value |
|
495 | + while (true) // self::token() can return an existing value |
|
497 | 496 | { |
498 | 497 | try { |
499 | 498 | self::$db->insert(self::TABLE, $share = array( |
@@ -502,12 +501,12 @@ discard block |
||
502 | 501 | 'share_owner' => $GLOBALS['egw_info']['user']['account_id'], |
503 | 502 | 'share_with' => implode(',', (array)$recipients), |
504 | 503 | 'share_created' => time(), |
505 | - )+$extra, false, __LINE__, __FILE__); |
|
504 | + ) + $extra, false, __LINE__, __FILE__); |
|
506 | 505 | |
507 | 506 | $share['share_id'] = self::$db->get_last_insert_id(self::TABLE, 'share_id'); |
508 | 507 | break; |
509 | 508 | } |
510 | - catch(Api\Db\Exception $e) { |
|
509 | + catch (Api\Db\Exception $e) { |
|
511 | 510 | if ($i++ > 3) throw $e; |
512 | 511 | unset($e); |
513 | 512 | } |
@@ -550,8 +549,8 @@ discard block |
||
550 | 549 | |
551 | 550 | // get all temp. files, to be able to delete them |
552 | 551 | $tmp_paths = array(); |
553 | - foreach(self::$db->select(self::TABLE, 'share_path', array( |
|
554 | - "share_path LIKE '/home/%/.tmp/%'")+$keys, __LINE__, __FILE__, false) as $row) |
|
552 | + foreach (self::$db->select(self::TABLE, 'share_path', array( |
|
553 | + "share_path LIKE '/home/%/.tmp/%'") + $keys, __LINE__, __FILE__, false) as $row) |
|
555 | 554 | { |
556 | 555 | $tmp_paths[] = $row['share_path']; |
557 | 556 | } |
@@ -563,7 +562,7 @@ discard block |
||
563 | 562 | // check if temp. files are used elsewhere |
564 | 563 | if ($tmp_paths) |
565 | 564 | { |
566 | - foreach(self::$db->select(self::TABLE, 'share_path,COUNT(*) AS cnt', array( |
|
565 | + foreach (self::$db->select(self::TABLE, 'share_path,COUNT(*) AS cnt', array( |
|
567 | 566 | 'share_path' => $tmp_paths, |
568 | 567 | ), __LINE__, __FILE__, false, 'GROUP BY share_path') as $row) |
569 | 568 | { |
@@ -573,7 +572,7 @@ discard block |
||
573 | 572 | } |
574 | 573 | } |
575 | 574 | // if not delete them |
576 | - foreach($tmp_paths as $path) |
|
575 | + foreach ($tmp_paths as $path) |
|
577 | 576 | { |
578 | 577 | Vfs::remove($path); |
579 | 578 | } |
@@ -607,11 +606,11 @@ discard block |
||
607 | 606 | // remove expired tmp-files unconditionally |
608 | 607 | $having = 'HAVING share_expires < '.self::$db->quote(self::$db->to_timestamp(time())).' OR '. |
609 | 608 | // remove without expiration date, when created over 100 days ago AND |
610 | - 'share_expires IS NULL AND share_created < '.self::$db->quote(self::$db->to_timestamp(time()-self::TMP_KEEP)). ' AND '. |
|
609 | + 'share_expires IS NULL AND share_created < '.self::$db->quote(self::$db->to_timestamp(time() - self::TMP_KEEP)).' AND '. |
|
611 | 610 | // (last accessed over 100 days ago OR never) |
612 | - '(share_last_accessed IS NULL OR share_last_accessed < '.self::$db->quote(self::$db->to_timestamp(time()-self::TMP_KEEP)).')'; |
|
611 | + '(share_last_accessed IS NULL OR share_last_accessed < '.self::$db->quote(self::$db->to_timestamp(time() - self::TMP_KEEP)).')'; |
|
613 | 612 | |
614 | - foreach(self::$db->select(self::TABLE, $cols, array( |
|
613 | + foreach (self::$db->select(self::TABLE, $cols, array( |
|
615 | 614 | "share_path LIKE '/home/%/.tmp/%'", |
616 | 615 | ), __LINE__, __FILE__, false, 'GROUP BY share_path '.$having) as $row) |
617 | 616 | { |
@@ -624,7 +623,7 @@ discard block |
||
624 | 623 | else |
625 | 624 | { |
626 | 625 | $share_ids = array(); |
627 | - foreach(self::$db->selec(self::TABLE, 'share_id', array( |
|
626 | + foreach (self::$db->selec(self::TABLE, 'share_id', array( |
|
628 | 627 | 'share_path' => $row['share_path'], |
629 | 628 | ), __LINE__, __FILE__) as $id) |
630 | 629 | { |
@@ -166,7 +166,10 @@ discard block |
||
166 | 166 | if ($token && !$keep_session) |
167 | 167 | { |
168 | 168 | $_SERVER['PHP_AUTH_USER'] = $token; |
169 | - if (!isset($_SERVER['PHP_AUTH_PW'])) $_SERVER['PHP_AUTH_PW'] = ''; |
|
169 | + if (!isset($_SERVER['PHP_AUTH_PW'])) |
|
170 | + { |
|
171 | + $_SERVER['PHP_AUTH_PW'] = ''; |
|
172 | + } |
|
170 | 173 | |
171 | 174 | unset($GLOBALS['egw_info']['flags']['autocreate_session_callback']); |
172 | 175 | if ($GLOBALS['egw']->session->verify() && isset($GLOBALS['egw']->sharing) && |
@@ -220,9 +223,12 @@ discard block |
||
220 | 223 | } |
221 | 224 | //_debug_array($share); |
222 | 225 | |
223 | - if ($keep_session) // add share to existing session |
|
226 | + if ($keep_session) |
|
227 | + { |
|
228 | + // add share to existing session |
|
224 | 229 | { |
225 | 230 | $share['share_root'] = '/'.$share['share_token']; |
231 | + } |
|
226 | 232 | |
227 | 233 | // if current user is not the share owner, we cant just mount share |
228 | 234 | if (Vfs::$user != $share['share_owner']) |
@@ -230,12 +236,15 @@ discard block |
||
230 | 236 | $keep_session = false; |
231 | 237 | } |
232 | 238 | } |
233 | - if (!$keep_session) // do NOT change to else, as we might have set $keep_session=false! |
|
239 | + if (!$keep_session) |
|
240 | + { |
|
241 | + // do NOT change to else, as we might have set $keep_session=false! |
|
234 | 242 | { |
235 | 243 | // only allow filemanager app |
236 | 244 | $GLOBALS['egw_info']['user']['apps'] = array( |
237 | 245 | 'filemanager' => $GLOBALS['egw_info']['apps']['filemanager'] |
238 | 246 | ); |
247 | + } |
|
239 | 248 | |
240 | 249 | $share['share_root'] = '/'; |
241 | 250 | Vfs::$user = $share['share_owner']; |
@@ -391,9 +400,15 @@ discard block |
||
391 | 400 | */ |
392 | 401 | public static function create($path, $mode, $name, $recipients, $extra=array()) |
393 | 402 | { |
394 | - if (!isset(self::$db)) self::$db = $GLOBALS['egw']->db; |
|
403 | + if (!isset(self::$db)) |
|
404 | + { |
|
405 | + self::$db = $GLOBALS['egw']->db; |
|
406 | + } |
|
395 | 407 | |
396 | - if (empty($name)) $name = $path; |
|
408 | + if (empty($name)) |
|
409 | + { |
|
410 | + $name = $path; |
|
411 | + } |
|
397 | 412 | |
398 | 413 | $path2tmp =& Api\Cache::getSession(__CLASS__, 'path2tmp'); |
399 | 414 | |
@@ -472,7 +487,10 @@ discard block |
||
472 | 487 | { |
473 | 488 | throw new Api\Exception\AssertionFailed("Could NOT create temp. file '$tmp_file'!"); |
474 | 489 | } |
475 | - if ($fp) fclose($fp); |
|
490 | + if ($fp) |
|
491 | + { |
|
492 | + fclose($fp); |
|
493 | + } |
|
476 | 494 | |
477 | 495 | if (is_dir($path) && !Vfs::copy_files(array($path), $tmp_file) || |
478 | 496 | !is_dir($path) && !copy($path, Vfs::PREFIX.$tmp_file)) |
@@ -493,7 +511,9 @@ discard block |
||
493 | 511 | } |
494 | 512 | |
495 | 513 | $i = 0; |
496 | - while(true) // self::token() can return an existing value |
|
514 | + while(true) |
|
515 | + { |
|
516 | + // self::token() can return an existing value |
|
497 | 517 | { |
498 | 518 | try { |
499 | 519 | self::$db->insert(self::TABLE, $share = array( |
@@ -503,12 +523,16 @@ discard block |
||
503 | 523 | 'share_with' => implode(',', (array)$recipients), |
504 | 524 | 'share_created' => time(), |
505 | 525 | )+$extra, false, __LINE__, __FILE__); |
526 | + } |
|
506 | 527 | |
507 | 528 | $share['share_id'] = self::$db->get_last_insert_id(self::TABLE, 'share_id'); |
508 | 529 | break; |
509 | 530 | } |
510 | 531 | catch(Api\Db\Exception $e) { |
511 | - if ($i++ > 3) throw $e; |
|
532 | + if ($i++ > 3) |
|
533 | + { |
|
534 | + throw $e; |
|
535 | + } |
|
512 | 536 | unset($e); |
513 | 537 | } |
514 | 538 | } |
@@ -546,7 +570,10 @@ discard block |
||
546 | 570 | { |
547 | 571 | self::$db = $GLOBALS['egw']->db; |
548 | 572 | |
549 | - if (is_scalar($keys)) $keys = array('share_id' => $keys); |
|
573 | + if (is_scalar($keys)) |
|
574 | + { |
|
575 | + $keys = array('share_id' => $keys); |
|
576 | + } |
|
550 | 577 | |
551 | 578 | // get all temp. files, to be able to delete them |
552 | 579 | $tmp_paths = array(); |
@@ -593,7 +620,10 @@ discard block |
||
593 | 620 | */ |
594 | 621 | public static function tmp_cleanup() |
595 | 622 | { |
596 | - if (!isset(self::$db)) self::$db = $GLOBALS['egw']->db; |
|
623 | + if (!isset(self::$db)) |
|
624 | + { |
|
625 | + self::$db = $GLOBALS['egw']->db; |
|
626 | + } |
|
597 | 627 | Vfs::$is_root = true; |
598 | 628 | |
599 | 629 | try { |
@@ -603,7 +633,10 @@ discard block |
||
603 | 633 | 'MAX(share_created) AS share_created', |
604 | 634 | 'MAX(share_last_accessed) AS share_last_accessed', |
605 | 635 | ); |
606 | - if (($group_concat = self::$db->group_concat('share_id'))) $cols[] = $group_concat.' AS share_id'; |
|
636 | + if (($group_concat = self::$db->group_concat('share_id'))) |
|
637 | + { |
|
638 | + $cols[] = $group_concat.' AS share_id'; |
|
639 | + } |
|
607 | 640 | // remove expired tmp-files unconditionally |
608 | 641 | $having = 'HAVING share_expires < '.self::$db->quote(self::$db->to_timestamp(time())).' OR '. |
609 | 642 | // remove without expiration date, when created over 100 days ago AND |
@@ -651,7 +684,10 @@ discard block |
||
651 | 684 | */ |
652 | 685 | public static function share2link($share) |
653 | 686 | { |
654 | - if (is_array($share)) $share = $share['share_token']; |
|
687 | + if (is_array($share)) |
|
688 | + { |
|
689 | + $share = $share['share_token']; |
|
690 | + } |
|
655 | 691 | |
656 | 692 | $link = Api\Framework::link('/share.php').'/'.$share; |
657 | 693 | if ($link[0] == '/') |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * |
455 | 455 | * If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now. |
456 | 456 | * |
457 | - * @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. |
|
457 | + * @return boolean 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. |
|
458 | 458 | */ |
459 | 459 | function stream_flush ( ) |
460 | 460 | { |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | * This method is called immediately when your stream object is created for examining directory contents with opendir(). |
857 | 857 | * |
858 | 858 | * @param string $path URL that was passed to opendir() and that this object is expected to explore. |
859 | - * @return booelan |
|
859 | + * @return boolean |
|
860 | 860 | */ |
861 | 861 | function dir_opendir ( $path, $options ) |
862 | 862 | { |
@@ -1213,7 +1213,7 @@ discard block |
||
1213 | 1213 | * It should reset the output generated by dir_readdir(). i.e.: |
1214 | 1214 | * The next call to dir_readdir() should return the first entry in the location returned by dir_opendir(). |
1215 | 1215 | * |
1216 | - * @return boolean |
|
1216 | + * @return boolean|null |
|
1217 | 1217 | */ |
1218 | 1218 | function dir_rewinddir ( ) |
1219 | 1219 | { |
@@ -1227,7 +1227,7 @@ discard block |
||
1227 | 1227 | * |
1228 | 1228 | * You should release any resources which were locked or allocated during the opening and use of the directory stream. |
1229 | 1229 | * |
1230 | - * @return boolean |
|
1230 | + * @return boolean|null |
|
1231 | 1231 | */ |
1232 | 1232 | function dir_closedir ( ) |
1233 | 1233 | { |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
412 | 412 | * |
413 | 413 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
414 | - * { |
|
414 | + * { |
|
415 | 415 | * $eof = !$eof; |
416 | 416 | * } |
417 | - * |
|
417 | + * |
|
418 | 418 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
419 | 419 | */ |
420 | 420 | function stream_eof ( ) |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1)); |
1054 | 1054 | |
1055 | 1055 | while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) && |
1056 | - ($url = Vfs::dirname($url))) |
|
1056 | + ($url = Vfs::dirname($url))) |
|
1057 | 1057 | { |
1058 | 1058 | if (($stat = self::url_stat($url,0,false,false))) |
1059 | 1059 | { |
@@ -157,14 +157,14 @@ discard block |
||
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 | - static function resolve_url_symlinks($_path,$file_exists=true,$resolve_last_symlink=true,&$stat=null) |
|
160 | + static 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 = self::url_stat($path,$resolve_last_symlink?0:STREAM_URL_STAT_LINK)) && !$file_exists) |
|
164 | + if (!($stat = self::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 |
||
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 && self::parse_url($url,PHP_URL_SCHEME) == self::SCHEME) |
|
175 | + if ($url && self::parse_url($url, PHP_URL_SCHEME) == self::SCHEME) |
|
176 | 176 | { |
177 | - $url = self::resolve_url(self::parse_url($url,PHP_URL_PATH)); |
|
177 | + $url = self::resolve_url(self::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 |
||
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 |
||
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(self::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(self::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 = self::parse_url($url,PHP_URL_SCHEME); |
|
241 | - if (is_null(self::$wrappers) || !in_array($scheme,self::$wrappers)) |
|
240 | + $scheme = self::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 |
||
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 |
||
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 | } |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set |
311 | 311 | * @return boolean true if the ressource was opened successful, otherwise false |
312 | 312 | */ |
313 | - function stream_open ( $path, $mode, $options, &$opened_path ) |
|
313 | + function stream_open($path, $mode, $options, &$opened_path) |
|
314 | 314 | { |
315 | - unset($options,$opened_path); // not used but required by function signature |
|
315 | + unset($options, $opened_path); // not used but required by function signature |
|
316 | 316 | $this->opened_stream = null; |
317 | 317 | |
318 | 318 | $stat = null; |
319 | - if (!($url = self::resolve_url_symlinks($path,$mode[0]=='r',true,$stat))) |
|
319 | + if (!($url = self::resolve_url_symlinks($path, $mode[0] == 'r', true, $stat))) |
|
320 | 320 | { |
321 | 321 | return false; |
322 | 322 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * |
352 | 352 | * VFS calls either "vfs_read", "vfs_added" or "vfs_modified" hook |
353 | 353 | */ |
354 | - function stream_close ( ) |
|
354 | + function stream_close( ) |
|
355 | 355 | { |
356 | 356 | $ret = fclose($this->opened_stream); |
357 | 357 | // clear PHP's stat cache, it contains wrong size of just closed file, |
@@ -361,12 +361,11 @@ discard block |
||
361 | 361 | if (isset($GLOBALS['egw']) && isset($GLOBALS['egw']->hooks)) |
362 | 362 | { |
363 | 363 | Api\Hooks::process(array( |
364 | - 'location' => str_replace('b','',$this->opened_stream_mode) == 'r' ? 'vfs_read' : |
|
365 | - ($this->opened_stream_is_new ? 'vfs_added' : 'vfs_modified'), |
|
364 | + 'location' => str_replace('b', '', $this->opened_stream_mode) == 'r' ? 'vfs_read' : ($this->opened_stream_is_new ? 'vfs_added' : 'vfs_modified'), |
|
366 | 365 | 'path' => $this->opened_stream_path, |
367 | 366 | 'mode' => $this->opened_stream_mode, |
368 | 367 | 'url' => $this->opened_stream_url, |
369 | - ),'',true); |
|
368 | + ), '', true); |
|
370 | 369 | } |
371 | 370 | $this->opened_stream = $this->opened_stream_mode = $this->opened_stream_path = $this->opened_stream_url = $this->opened_stream_is_new = null; |
372 | 371 | |
@@ -384,9 +383,9 @@ discard block |
||
384 | 383 | * @param int $count |
385 | 384 | * @return string/false up to count bytes read or false on EOF |
386 | 385 | */ |
387 | - function stream_read ( $count ) |
|
386 | + function stream_read($count) |
|
388 | 387 | { |
389 | - return fread($this->opened_stream,$count); |
|
388 | + return fread($this->opened_stream, $count); |
|
390 | 389 | } |
391 | 390 | |
392 | 391 | /** |
@@ -400,9 +399,9 @@ discard block |
||
400 | 399 | * @param string $data |
401 | 400 | * @return integer |
402 | 401 | */ |
403 | - function stream_write ( $data ) |
|
402 | + function stream_write($data) |
|
404 | 403 | { |
405 | - return fwrite($this->opened_stream,$data); |
|
404 | + return fwrite($this->opened_stream, $data); |
|
406 | 405 | } |
407 | 406 | |
408 | 407 | /** |
@@ -417,7 +416,7 @@ discard block |
||
417 | 416 | * |
418 | 417 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
419 | 418 | */ |
420 | - function stream_eof ( ) |
|
419 | + function stream_eof( ) |
|
421 | 420 | { |
422 | 421 | return feof($this->opened_stream); |
423 | 422 | } |
@@ -427,7 +426,7 @@ discard block |
||
427 | 426 | * |
428 | 427 | * @return integer current read/write position of the stream |
429 | 428 | */ |
430 | - function stream_tell ( ) |
|
429 | + function stream_tell( ) |
|
431 | 430 | { |
432 | 431 | return ftell($this->opened_stream); |
433 | 432 | } |
@@ -444,9 +443,9 @@ discard block |
||
444 | 443 | * 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.) |
445 | 444 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
446 | 445 | */ |
447 | - function stream_seek ( $offset, $whence ) |
|
446 | + function stream_seek($offset, $whence) |
|
448 | 447 | { |
449 | - return !fseek($this->opened_stream,$offset,$whence); // fseek returns 0 on success and -1 on failure |
|
448 | + return !fseek($this->opened_stream, $offset, $whence); // fseek returns 0 on success and -1 on failure |
|
450 | 449 | } |
451 | 450 | |
452 | 451 | /** |
@@ -456,7 +455,7 @@ discard block |
||
456 | 455 | * |
457 | 456 | * @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. |
458 | 457 | */ |
459 | - function stream_flush ( ) |
|
458 | + function stream_flush( ) |
|
460 | 459 | { |
461 | 460 | return fflush($this->opened_stream); |
462 | 461 | } |
@@ -475,7 +474,7 @@ discard block |
||
475 | 474 | * |
476 | 475 | * @return array containing the same values as appropriate for the stream. |
477 | 476 | */ |
478 | - function stream_stat ( ) |
|
477 | + function stream_stat( ) |
|
479 | 478 | { |
480 | 479 | return fstat($this->opened_stream); |
481 | 480 | } |
@@ -489,9 +488,9 @@ discard block |
||
489 | 488 | * @param string $path |
490 | 489 | * @return boolean TRUE on success or FALSE on failure |
491 | 490 | */ |
492 | - static function unlink ( $path ) |
|
491 | + static function unlink($path) |
|
493 | 492 | { |
494 | - if (!($url = self::resolve_url_symlinks($path,true,false))) // true,false file need to exist, but do not resolve last component |
|
493 | + if (!($url = self::resolve_url_symlinks($path, true, false))) // true,false file need to exist, but do not resolve last component |
|
495 | 494 | { |
496 | 495 | return false; |
497 | 496 | } |
@@ -512,7 +511,7 @@ discard block |
||
512 | 511 | 'path' => $path[0] == '/' ? $path : self::parse_url($path, PHP_URL_PATH), |
513 | 512 | 'url' => $url, |
514 | 513 | 'stat' => $stat, |
515 | - ),'',true); |
|
514 | + ), '', true); |
|
516 | 515 | } |
517 | 516 | return $ok; |
518 | 517 | } |
@@ -529,22 +528,22 @@ discard block |
||
529 | 528 | * @param string $path_to |
530 | 529 | * @return boolean TRUE on success or FALSE on failure |
531 | 530 | */ |
532 | - static function rename ( $path_from, $path_to ) |
|
531 | + static function rename($path_from, $path_to) |
|
533 | 532 | { |
534 | - if (!($url_from = self::resolve_url_symlinks($path_from,true,false)) || |
|
535 | - !($url_to = self::resolve_url_symlinks($path_to,false))) |
|
533 | + if (!($url_from = self::resolve_url_symlinks($path_from, true, false)) || |
|
534 | + !($url_to = self::resolve_url_symlinks($path_to, false))) |
|
536 | 535 | { |
537 | 536 | return false; |
538 | 537 | } |
539 | 538 | // if file is moved from one filesystem / wrapper to an other --> copy it (rename fails cross wrappers) |
540 | - if (self::parse_url($url_from,PHP_URL_SCHEME) == self::parse_url($url_to,PHP_URL_SCHEME)) |
|
539 | + if (self::parse_url($url_from, PHP_URL_SCHEME) == self::parse_url($url_to, PHP_URL_SCHEME)) |
|
541 | 540 | { |
542 | 541 | self::symlinkCache_remove($path_from); |
543 | - $ret = rename($url_from,$url_to); |
|
542 | + $ret = rename($url_from, $url_to); |
|
544 | 543 | } |
545 | - elseif (($from = fopen($url_from,'r')) && ($to = fopen($url_to,'w'))) |
|
544 | + elseif (($from = fopen($url_from, 'r')) && ($to = fopen($url_to, 'w'))) |
|
546 | 545 | { |
547 | - $ret = stream_copy_to_stream($from,$to) !== false; |
|
546 | + $ret = stream_copy_to_stream($from, $to) !== false; |
|
548 | 547 | fclose($from); |
549 | 548 | fclose($to); |
550 | 549 | if ($ret) self::unlink($path_from); |
@@ -566,7 +565,7 @@ discard block |
||
566 | 565 | 'to' => $path_to[0] == '/' ? $path_to : self::parse_url($path_to, PHP_URL_PATH), |
567 | 566 | 'url_from' => $url_from, |
568 | 567 | 'url_to' => $url_to, |
569 | - ),'',true); |
|
568 | + ), '', true); |
|
570 | 569 | } |
571 | 570 | return $ret; |
572 | 571 | } |
@@ -582,13 +581,13 @@ discard block |
||
582 | 581 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE |
583 | 582 | * @return boolean TRUE on success or FALSE on failure |
584 | 583 | */ |
585 | - static function mkdir ( $path, $mode, $options ) |
|
584 | + static function mkdir($path, $mode, $options) |
|
586 | 585 | { |
587 | - if (!($url = self::resolve_url_symlinks($path,false))) // false = directory does not need to exists |
|
586 | + if (!($url = self::resolve_url_symlinks($path, false))) // false = directory does not need to exists |
|
588 | 587 | { |
589 | 588 | return false; |
590 | 589 | } |
591 | - $ret = mkdir($url,$mode,$options); |
|
590 | + $ret = mkdir($url, $mode, $options); |
|
592 | 591 | |
593 | 592 | // call "vfs_mkdir" hook |
594 | 593 | if ($ret && isset($GLOBALS['egw']) && isset($GLOBALS['egw']->hooks)) |
@@ -597,7 +596,7 @@ discard block |
||
597 | 596 | 'location' => 'vfs_mkdir', |
598 | 597 | 'path' => $path[0] == '/' ? $path : self::parse_url($path, PHP_URL_PATH), |
599 | 598 | 'url' => $url, |
600 | - ),'',true); |
|
599 | + ), '', true); |
|
601 | 600 | } |
602 | 601 | return $ret; |
603 | 602 | } |
@@ -612,9 +611,9 @@ discard block |
||
612 | 611 | * @param int $options Possible values include STREAM_REPORT_ERRORS. |
613 | 612 | * @return boolean TRUE on success or FALSE on failure. |
614 | 613 | */ |
615 | - static function rmdir ( $path, $options ) |
|
614 | + static function rmdir($path, $options) |
|
616 | 615 | { |
617 | - unset($options); // not uses but required by function signature |
|
616 | + unset($options); // not uses but required by function signature |
|
618 | 617 | if (!($url = self::resolve_url_symlinks($path))) |
619 | 618 | { |
620 | 619 | return false; |
@@ -636,7 +635,7 @@ discard block |
||
636 | 635 | 'path' => $path[0] == '/' ? $path : self::parse_url($path, PHP_URL_PATH), |
637 | 636 | 'url' => $url, |
638 | 637 | 'stat' => $stat, |
639 | - ),'',true); |
|
638 | + ), '', true); |
|
640 | 639 | } |
641 | 640 | return $ok; |
642 | 641 | } |
@@ -653,60 +652,60 @@ discard block |
||
653 | 652 | * @param int $path_param_key =0 key in params containing the path, default 0 |
654 | 653 | * @return mixed return value of backend or false if function does not exist on backend |
655 | 654 | */ |
656 | - static protected function _call_on_backend($name,$params,$fail_silent=false,$path_param_key=0) |
|
655 | + static protected function _call_on_backend($name, $params, $fail_silent = false, $path_param_key = 0) |
|
657 | 656 | { |
658 | 657 | $pathes = $params[$path_param_key]; |
659 | 658 | |
660 | 659 | $scheme2urls = array(); |
661 | - foreach(is_array($pathes) ? $pathes : array($pathes) as $path) |
|
660 | + foreach (is_array($pathes) ? $pathes : array($pathes) as $path) |
|
662 | 661 | { |
663 | - if (!($url = self::resolve_url_symlinks($path,false,false))) |
|
662 | + if (!($url = self::resolve_url_symlinks($path, false, false))) |
|
664 | 663 | { |
665 | 664 | return false; |
666 | 665 | } |
667 | - $k=(string)self::parse_url($url,PHP_URL_SCHEME); |
|
666 | + $k = (string)self::parse_url($url, PHP_URL_SCHEME); |
|
668 | 667 | if (!(is_array($scheme2urls[$k]))) $scheme2urls[$k] = array(); |
669 | 668 | $scheme2urls[$k][$path] = $url; |
670 | 669 | } |
671 | 670 | $ret = array(); |
672 | - foreach($scheme2urls as $scheme => $urls) |
|
671 | + foreach ($scheme2urls as $scheme => $urls) |
|
673 | 672 | { |
674 | 673 | if ($scheme) |
675 | 674 | { |
676 | - if (!class_exists($class = self::scheme2class($scheme)) || !method_exists($class,$name)) |
|
675 | + if (!class_exists($class = self::scheme2class($scheme)) || !method_exists($class, $name)) |
|
677 | 676 | { |
678 | - if (!$fail_silent) trigger_error("Can't $name for scheme $scheme!\n",E_USER_WARNING); |
|
677 | + if (!$fail_silent) trigger_error("Can't $name for scheme $scheme!\n", E_USER_WARNING); |
|
679 | 678 | return false; |
680 | 679 | } |
681 | 680 | if (!is_array($pathes)) |
682 | 681 | { |
683 | 682 | $params[$path_param_key] = $url; |
684 | 683 | |
685 | - return call_user_func_array(array($class,$name),$params); |
|
684 | + return call_user_func_array(array($class, $name), $params); |
|
686 | 685 | } |
687 | 686 | $params[$path_param_key] = $urls; |
688 | - if (!is_array($r = call_user_func_array(array($class,$name),$params))) |
|
687 | + if (!is_array($r = call_user_func_array(array($class, $name), $params))) |
|
689 | 688 | { |
690 | 689 | return $r; |
691 | 690 | } |
692 | 691 | // we need to re-translate the urls to pathes, as they can eg. contain symlinks |
693 | - foreach($urls as $path => $url) |
|
692 | + foreach ($urls as $path => $url) |
|
694 | 693 | { |
695 | - if (isset($r[$url]) || isset($r[$url=self::parse_url($url,PHP_URL_PATH)])) |
|
694 | + if (isset($r[$url]) || isset($r[$url = self::parse_url($url, PHP_URL_PATH)])) |
|
696 | 695 | { |
697 | 696 | $ret[$path] = $r[$url]; |
698 | 697 | } |
699 | 698 | } |
700 | 699 | } |
701 | 700 | // call the filesystem specific function (dont allow to use arrays!) |
702 | - elseif(!function_exists($name) || is_array($pathes)) |
|
701 | + elseif (!function_exists($name) || is_array($pathes)) |
|
703 | 702 | { |
704 | 703 | return false; |
705 | 704 | } |
706 | 705 | else |
707 | 706 | { |
708 | 707 | $time = null; |
709 | - return $name($url,$time); |
|
708 | + return $name($url, $time); |
|
710 | 709 | } |
711 | 710 | } |
712 | 711 | return $ret; |
@@ -720,9 +719,9 @@ discard block |
||
720 | 719 | * @param int $atime =null access time (unix timestamp), default null = current time, not implemented in the vfs! |
721 | 720 | * @return boolean true on success, false otherwise |
722 | 721 | */ |
723 | - static function touch($path,$time=null,$atime=null) |
|
722 | + static function touch($path, $time = null, $atime = null) |
|
724 | 723 | { |
725 | - return self::_call_on_backend('touch',array($path,$time,$atime)); |
|
724 | + return self::_call_on_backend('touch', array($path, $time, $atime)); |
|
726 | 725 | } |
727 | 726 | |
728 | 727 | /** |
@@ -734,9 +733,9 @@ discard block |
||
734 | 733 | * @param string $mode mode string see Vfs::mode2int |
735 | 734 | * @return boolean true on success, false otherwise |
736 | 735 | */ |
737 | - static function chmod($path,$mode) |
|
736 | + static function chmod($path, $mode) |
|
738 | 737 | { |
739 | - return self::_call_on_backend('chmod',array($path,$mode)); |
|
738 | + return self::_call_on_backend('chmod', array($path, $mode)); |
|
740 | 739 | } |
741 | 740 | |
742 | 741 | /** |
@@ -748,9 +747,9 @@ discard block |
||
748 | 747 | * @param int $owner numeric user id |
749 | 748 | * @return boolean true on success, false otherwise |
750 | 749 | */ |
751 | - static function chown($path,$owner) |
|
750 | + static function chown($path, $owner) |
|
752 | 751 | { |
753 | - return self::_call_on_backend('chown',array($path,$owner)); |
|
752 | + return self::_call_on_backend('chown', array($path, $owner)); |
|
754 | 753 | } |
755 | 754 | |
756 | 755 | /** |
@@ -762,9 +761,9 @@ discard block |
||
762 | 761 | * @param int $group numeric group id |
763 | 762 | * @return boolean true on success, false otherwise |
764 | 763 | */ |
765 | - static function chgrp($path,$group) |
|
764 | + static function chgrp($path, $group) |
|
766 | 765 | { |
767 | - return self::_call_on_backend('chgrp',array($path,$group)); |
|
766 | + return self::_call_on_backend('chgrp', array($path, $group)); |
|
768 | 767 | } |
769 | 768 | |
770 | 769 | /** |
@@ -777,7 +776,7 @@ discard block |
||
777 | 776 | */ |
778 | 777 | static function readlink($path) |
779 | 778 | { |
780 | - $ret = self::_call_on_backend('readlink',array($path),true); // true = fail silent, if backend does not support readlink |
|
779 | + $ret = self::_call_on_backend('readlink', array($path), true); // true = fail silent, if backend does not support readlink |
|
781 | 780 | //error_log(__METHOD__."('$path') returning ".array2string($ret).' '.function_backtrace()); |
782 | 781 | return $ret; |
783 | 782 | } |
@@ -791,9 +790,9 @@ discard block |
||
791 | 790 | * @param string $link path of the link to create |
792 | 791 | * @return boolean true on success, false on error |
793 | 792 | */ |
794 | - static function symlink($target,$link) |
|
793 | + static function symlink($target, $link) |
|
795 | 794 | { |
796 | - if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1))) // 1=path is in $link! |
|
795 | + if (($ret = self::_call_on_backend('symlink', array($target, $link), false, 1))) // 1=path is in $link! |
|
797 | 796 | { |
798 | 797 | self::symlinkCache_remove($link); |
799 | 798 | } |
@@ -813,13 +812,13 @@ discard block |
||
813 | 812 | * @param boolean $recheck =false true = do a new check, false = rely on stored mime type (if existing) |
814 | 813 | * @return string mime-type (self::DIR_MIME_TYPE for directories) |
815 | 814 | */ |
816 | - static function mime_content_type($path,$recheck=false) |
|
815 | + static function mime_content_type($path, $recheck = false) |
|
817 | 816 | { |
818 | 817 | if (!($url = self::resolve_url_symlinks($path))) |
819 | 818 | { |
820 | 819 | return false; |
821 | 820 | } |
822 | - if (($scheme = self::parse_url($url,PHP_URL_SCHEME)) && !$recheck) |
|
821 | + if (($scheme = self::parse_url($url, PHP_URL_SCHEME)) && !$recheck) |
|
823 | 822 | { |
824 | 823 | // check it it's an eGW stream wrapper returning mime-type via url_stat |
825 | 824 | // we need to first check if the constant is defined, as we get a fatal error in php5.3 otherwise |
@@ -827,7 +826,7 @@ discard block |
||
827 | 826 | defined($class.'::STAT_RETURN_MIME_TYPE') && |
828 | 827 | ($mime_attr = constant($class.'::STAT_RETURN_MIME_TYPE'))) |
829 | 828 | { |
830 | - $stat = call_user_func(array($class,'url_stat'),self::parse_url($url,PHP_URL_PATH),0); |
|
829 | + $stat = call_user_func(array($class, 'url_stat'), self::parse_url($url, PHP_URL_PATH), 0); |
|
831 | 830 | if ($stat && $stat[$mime_attr]) |
832 | 831 | { |
833 | 832 | $mime = $stat[$mime_attr]; |
@@ -846,7 +845,7 @@ discard block |
||
846 | 845 | // using EGw's own mime magic (currently only checking the extension!) |
847 | 846 | if (!$mime) |
848 | 847 | { |
849 | - $mime = Api\MimeMagic::filename2mime(self::parse_url($url,PHP_URL_PATH)); |
|
848 | + $mime = Api\MimeMagic::filename2mime(self::parse_url($url, PHP_URL_PATH)); |
|
850 | 849 | } |
851 | 850 | //error_log(__METHOD__."($path,$recheck) mime=$mime"); |
852 | 851 | return $mime; |
@@ -858,7 +857,7 @@ discard block |
||
858 | 857 | * @param string $path URL that was passed to opendir() and that this object is expected to explore. |
859 | 858 | * @return booelan |
860 | 859 | */ |
861 | - function dir_opendir ( $path, $options ) |
|
860 | + function dir_opendir($path, $options) |
|
862 | 861 | { |
863 | 862 | $this->opened_dir = $this->extra_dirs = null; |
864 | 863 | $this->dir_url_params = array(); |
@@ -875,15 +874,15 @@ discard block |
||
875 | 874 | if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!"); |
876 | 875 | return false; |
877 | 876 | } |
878 | - $this->opened_dir_writable = Vfs::check_access($this->opened_dir_url,Vfs::WRITABLE); |
|
877 | + $this->opened_dir_writable = Vfs::check_access($this->opened_dir_url, Vfs::WRITABLE); |
|
879 | 878 | // check our fstab if we need to add some of the mountpoints |
880 | - $basepath = self::parse_url($path,PHP_URL_PATH); |
|
881 | - foreach(array_keys(self::$fstab) as $mounted) |
|
879 | + $basepath = self::parse_url($path, PHP_URL_PATH); |
|
880 | + foreach (array_keys(self::$fstab) as $mounted) |
|
882 | 881 | { |
883 | 882 | if (((Vfs::dirname($mounted) == $basepath || Vfs::dirname($mounted).'/' == $basepath) && $mounted != '/') && |
884 | 883 | // only return children readable by the user, if dir is not writable |
885 | 884 | (!self::HIDE_UNREADABLES || $this->opened_dir_writable || |
886 | - Vfs::check_access($mounted,Vfs::READABLE))) |
|
885 | + Vfs::check_access($mounted, Vfs::READABLE))) |
|
887 | 886 | { |
888 | 887 | $this->extra_dirs[] = basename($mounted); |
889 | 888 | } |
@@ -922,24 +921,24 @@ discard block |
||
922 | 921 | * @param boolean $check_symlink_components =true check if path contains symlinks in path components other then the last one |
923 | 922 | * @return array |
924 | 923 | */ |
925 | - static function url_stat ( $path, $flags, $try_create_home=false, $check_symlink_components=true, $check_symlink_depth=self::MAX_SYMLINK_DEPTH, $try_reconnect=true ) |
|
924 | + static function url_stat($path, $flags, $try_create_home = false, $check_symlink_components = true, $check_symlink_depth = self::MAX_SYMLINK_DEPTH, $try_reconnect = true) |
|
926 | 925 | { |
927 | - if (!($url = self::resolve_url($path,!($flags & STREAM_URL_STAT_LINK), $check_symlink_components))) |
|
926 | + if (!($url = self::resolve_url($path, !($flags&STREAM_URL_STAT_LINK), $check_symlink_components))) |
|
928 | 927 | { |
929 | 928 | if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) can NOT resolve path!"); |
930 | 929 | return false; |
931 | 930 | } |
932 | 931 | |
933 | 932 | try { |
934 | - if ($flags & STREAM_URL_STAT_LINK) |
|
933 | + if ($flags&STREAM_URL_STAT_LINK) |
|
935 | 934 | { |
936 | - $stat = @lstat($url); // suppressed the stat failed warnings |
|
935 | + $stat = @lstat($url); // suppressed the stat failed warnings |
|
937 | 936 | } |
938 | 937 | else |
939 | 938 | { |
940 | - $stat = @stat($url); // suppressed the stat failed warnings |
|
939 | + $stat = @stat($url); // suppressed the stat failed warnings |
|
941 | 940 | |
942 | - if ($stat && ($stat['mode'] & self::MODE_LINK)) |
|
941 | + if ($stat && ($stat['mode']&self::MODE_LINK)) |
|
943 | 942 | { |
944 | 943 | if (!$check_symlink_depth) |
945 | 944 | { |
@@ -950,25 +949,25 @@ discard block |
||
950 | 949 | { |
951 | 950 | if ($lpath[0] != '/') // concat relative path |
952 | 951 | { |
953 | - $lpath = Vfs::concat(self::parse_url($path,PHP_URL_PATH),'../'.$lpath); |
|
952 | + $lpath = Vfs::concat(self::parse_url($path, PHP_URL_PATH), '../'.$lpath); |
|
954 | 953 | } |
955 | - $u_query = parse_url($url,PHP_URL_QUERY); |
|
954 | + $u_query = parse_url($url, PHP_URL_QUERY); |
|
956 | 955 | $url = Vfs::PREFIX.$lpath; |
957 | 956 | 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"); |
958 | 957 | // try reading the stat of the link |
959 | - if (($stat = self::url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth-1))) |
|
958 | + if (($stat = self::url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth - 1))) |
|
960 | 959 | { |
961 | 960 | $stat_query = parse_url($stat['url'], PHP_URL_QUERY); |
962 | - if($u_query || $stat_query) |
|
961 | + if ($u_query || $stat_query) |
|
963 | 962 | { |
964 | 963 | $stat_url = parse_url($stat['url']); |
965 | - parse_str($stat_query,$stat_query); |
|
964 | + parse_str($stat_query, $stat_query); |
|
966 | 965 | parse_str($u_query, $u_query); |
967 | 966 | $stat_query = http_build_query(array_merge($stat_query, $u_query)); |
968 | 967 | $stat['url'] = $stat_url['scheme'].'://'.$stat_url['host'].$stat_url['path'].'?'.$stat_query; |
969 | 968 | } |
970 | - if(isset($stat['url'])) $url = $stat['url']; // if stat returns an url use that, as there might be more links ... |
|
971 | - self::symlinkCache_add($path,$url); |
|
969 | + if (isset($stat['url'])) $url = $stat['url']; // if stat returns an url use that, as there might be more links ... |
|
970 | + self::symlinkCache_add($path, $url); |
|
972 | 971 | } |
973 | 972 | } |
974 | 973 | } |
@@ -988,7 +987,7 @@ discard block |
||
988 | 987 | throw $e; |
989 | 988 | } |
990 | 989 | // check if a failed url_stat was for a home dir, in that case silently create it |
991 | - if (!$stat && $try_create_home && Vfs::dirname(self::parse_url($path,PHP_URL_PATH)) == '/home' && |
|
990 | + if (!$stat && $try_create_home && Vfs::dirname(self::parse_url($path, PHP_URL_PATH)) == '/home' && |
|
992 | 991 | ($id = $GLOBALS['egw']->accounts->name2id(basename($path))) && |
993 | 992 | $GLOBALS['egw']->accounts->id2name($id) == basename($path)) // make sure path has the right case! |
994 | 993 | { |
@@ -998,25 +997,25 @@ discard block |
||
998 | 997 | 'account_lid' => basename($path), |
999 | 998 | 'account_name' => basename($path), |
1000 | 999 | ); |
1001 | - call_user_func(array(__NAMESPACE__.'\\Hooks',$hook_data['location']),$hook_data); |
|
1000 | + call_user_func(array(__NAMESPACE__.'\\Hooks', $hook_data['location']), $hook_data); |
|
1002 | 1001 | unset($hook_data); |
1003 | - $stat = self::url_stat($path,$flags,false); |
|
1002 | + $stat = self::url_stat($path, $flags, false); |
|
1004 | 1003 | } |
1005 | 1004 | $query = parse_url($url, PHP_URL_QUERY); |
1006 | 1005 | if (!$stat && $check_symlink_components) // check if there's a symlink somewhere inbetween the path |
1007 | 1006 | { |
1008 | - $stat = self::check_symlink_components($path,$flags,$url); |
|
1009 | - if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path,$stat['url']); |
|
1007 | + $stat = self::check_symlink_components($path, $flags, $url); |
|
1008 | + if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path, $stat['url']); |
|
1010 | 1009 | } |
1011 | - elseif(is_array($stat) && !isset($stat['url'])) |
|
1010 | + elseif (is_array($stat) && !isset($stat['url'])) |
|
1012 | 1011 | { |
1013 | 1012 | $stat['url'] = $url; |
1014 | 1013 | } |
1015 | - if (($stat['mode'] & 0222) && self::url_is_readonly($stat['url'])) |
|
1014 | + if (($stat['mode']&0222) && self::url_is_readonly($stat['url'])) |
|
1016 | 1015 | { |
1017 | 1016 | $stat['mode'] &= ~0222; |
1018 | 1017 | } |
1019 | - if($stat['url'] && $query && strpos($stat['url'],'?'.$query)===false) |
|
1018 | + if ($stat['url'] && $query && strpos($stat['url'], '?'.$query) === false) |
|
1020 | 1019 | { |
1021 | 1020 | $stat['url'] .= '?'.$query; |
1022 | 1021 | } |
@@ -1043,7 +1042,7 @@ discard block |
||
1043 | 1042 | * @param string &$url=null already resolved path |
1044 | 1043 | * @return array|boolean stat array or false if not found |
1045 | 1044 | */ |
1046 | - static private function check_symlink_components($path,$flags=0,&$url=null) |
|
1045 | + static private function check_symlink_components($path, $flags = 0, &$url = null) |
|
1047 | 1046 | { |
1048 | 1047 | if (is_null($url) && !($url = self::resolve_url($path))) |
1049 | 1048 | { |
@@ -1055,7 +1054,7 @@ discard block |
||
1055 | 1054 | while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) && |
1056 | 1055 | ($url = Vfs::dirname($url))) |
1057 | 1056 | { |
1058 | - if (($stat = self::url_stat($url,0,false,false))) |
|
1057 | + if (($stat = self::url_stat($url, 0, false, false))) |
|
1059 | 1058 | { |
1060 | 1059 | if (is_link($url) && ($lpath = self::readlink($url))) |
1061 | 1060 | { |
@@ -1063,20 +1062,20 @@ discard block |
||
1063 | 1062 | |
1064 | 1063 | if ($lpath[0] != '/') |
1065 | 1064 | { |
1066 | - $lpath = Vfs::concat(self::parse_url($url,PHP_URL_PATH),'../'.$lpath); |
|
1065 | + $lpath = Vfs::concat(self::parse_url($url, PHP_URL_PATH), '../'.$lpath); |
|
1067 | 1066 | } |
1068 | 1067 | //self::symlinkCache_add($path,Vfs::PREFIX.$lpath); |
1069 | - $url = Vfs::PREFIX.Vfs::concat($lpath,$rel_path); |
|
1068 | + $url = Vfs::PREFIX.Vfs::concat($lpath, $rel_path); |
|
1070 | 1069 | if (self::LOG_LEVEL > 1) error_log("$log --> lpath='$lpath', url='$url'"); |
1071 | - return self::url_stat($url,$flags); |
|
1070 | + return self::url_stat($url, $flags); |
|
1072 | 1071 | } |
1073 | - $url = Vfs::concat($url,$rel_path); |
|
1072 | + $url = Vfs::concat($url, $rel_path); |
|
1074 | 1073 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning null"); |
1075 | 1074 | return null; |
1076 | 1075 | } |
1077 | 1076 | } |
1078 | 1077 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning false"); |
1079 | - return false; // $path does not exist |
|
1078 | + return false; // $path does not exist |
|
1080 | 1079 | } |
1081 | 1080 | |
1082 | 1081 | /** |
@@ -1092,13 +1091,13 @@ discard block |
||
1092 | 1091 | * @param string $_path vfs path |
1093 | 1092 | * @param string $target target path |
1094 | 1093 | */ |
1095 | - static protected function symlinkCache_add($_path,$target) |
|
1094 | + static protected function symlinkCache_add($_path, $target) |
|
1096 | 1095 | { |
1097 | 1096 | $path = self::get_path($_path); |
1098 | 1097 | |
1099 | - if (isset(self::$symlink_cache[$path])) return; // nothing to do |
|
1098 | + if (isset(self::$symlink_cache[$path])) return; // nothing to do |
|
1100 | 1099 | |
1101 | - if ($target[0] != '/') $target = self::parse_url($target,PHP_URL_PATH); |
|
1100 | + if ($target[0] != '/') $target = self::parse_url($target, PHP_URL_PATH); |
|
1102 | 1101 | |
1103 | 1102 | self::$symlink_cache[$path] = $target; |
1104 | 1103 | |
@@ -1132,25 +1131,25 @@ discard block |
||
1132 | 1131 | * @param boolean $do_symlink =true is a direct match allowed, default yes (must be false for a lstat or readlink!) |
1133 | 1132 | * @return string target or path, if path not found |
1134 | 1133 | */ |
1135 | - static public function symlinkCache_resolve($_path,$do_symlink=true) |
|
1134 | + static public function symlinkCache_resolve($_path, $do_symlink = true) |
|
1136 | 1135 | { |
1137 | 1136 | // remove vfs scheme, but no other schemes (eg. filesystem!) |
1138 | 1137 | $path = self::get_path($_path); |
1139 | 1138 | |
1140 | 1139 | $strlen_path = strlen($path); |
1141 | 1140 | |
1142 | - foreach(self::$symlink_cache as $p => $t) |
|
1141 | + foreach (self::$symlink_cache as $p => $t) |
|
1143 | 1142 | { |
1144 | - if (($strlen_p = strlen($p)) > $strlen_path) continue; // $path can NOT start with $p |
|
1143 | + if (($strlen_p = strlen($p)) > $strlen_path) continue; // $path can NOT start with $p |
|
1145 | 1144 | |
1146 | 1145 | if ($path == $p) |
1147 | 1146 | { |
1148 | 1147 | if ($do_symlink) $target = $t; |
1149 | 1148 | break; |
1150 | 1149 | } |
1151 | - elseif (substr($path,0,$strlen_p+1) == $p.'/') |
|
1150 | + elseif (substr($path, 0, $strlen_p + 1) == $p.'/') |
|
1152 | 1151 | { |
1153 | - $target = $t . substr($path,$strlen_p); |
|
1152 | + $target = $t.substr($path, $strlen_p); |
|
1154 | 1153 | break; |
1155 | 1154 | } |
1156 | 1155 | } |
@@ -1168,7 +1167,7 @@ discard block |
||
1168 | 1167 | * |
1169 | 1168 | * @param string $path ='/' path of backend, whos cache to clear |
1170 | 1169 | */ |
1171 | - static function clearstatcache($path='/') |
|
1170 | + static function clearstatcache($path = '/') |
|
1172 | 1171 | { |
1173 | 1172 | //error_log(__METHOD__."('$path')"); |
1174 | 1173 | self::$symlink_cache = self::$resolve_url_cache = array(); |
@@ -1186,7 +1185,7 @@ discard block |
||
1186 | 1185 | * |
1187 | 1186 | * @return string |
1188 | 1187 | */ |
1189 | - function dir_readdir ( ) |
|
1188 | + function dir_readdir( ) |
|
1190 | 1189 | { |
1191 | 1190 | if ($this->extra_dirs && count($this->extra_dirs) > $this->extra_dir_ptr) |
1192 | 1191 | { |
@@ -1198,10 +1197,10 @@ discard block |
||
1198 | 1197 | do { |
1199 | 1198 | $file = readdir($this->opened_dir); |
1200 | 1199 | } |
1201 | - while($file !== false && |
|
1202 | - (is_array($this->extra_dirs) && in_array($file,$this->extra_dirs) || // do NOT return extra_dirs twice |
|
1200 | + while ($file !== false && |
|
1201 | + (is_array($this->extra_dirs) && in_array($file, $this->extra_dirs) || // do NOT return extra_dirs twice |
|
1203 | 1202 | self::HIDE_UNREADABLES && !$this->opened_dir_writable && |
1204 | - !Vfs::check_access(Vfs::concat($this->opened_dir_url,$file),Vfs::READABLE))); |
|
1203 | + !Vfs::check_access(Vfs::concat($this->opened_dir_url, $file), Vfs::READABLE))); |
|
1205 | 1204 | } |
1206 | 1205 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $this->opened_dir ) = '$file'"); |
1207 | 1206 | return $file; |
@@ -1215,7 +1214,7 @@ discard block |
||
1215 | 1214 | * |
1216 | 1215 | * @return boolean |
1217 | 1216 | */ |
1218 | - function dir_rewinddir ( ) |
|
1217 | + function dir_rewinddir( ) |
|
1219 | 1218 | { |
1220 | 1219 | $this->extra_dir_ptr = 0; |
1221 | 1220 | |
@@ -1229,7 +1228,7 @@ discard block |
||
1229 | 1228 | * |
1230 | 1229 | * @return boolean |
1231 | 1230 | */ |
1232 | - function dir_closedir ( ) |
|
1231 | + function dir_closedir( ) |
|
1233 | 1232 | { |
1234 | 1233 | $ret = closedir($this->opened_dir); |
1235 | 1234 | |
@@ -1246,9 +1245,9 @@ discard block |
||
1246 | 1245 | */ |
1247 | 1246 | static function load_wrapper($scheme) |
1248 | 1247 | { |
1249 | - if (!in_array($scheme,self::get_wrappers())) |
|
1248 | + if (!in_array($scheme, self::get_wrappers())) |
|
1250 | 1249 | { |
1251 | - switch($scheme) |
|
1250 | + switch ($scheme) |
|
1252 | 1251 | { |
1253 | 1252 | case 'webdav': |
1254 | 1253 | case 'webdavs': |
@@ -1256,16 +1255,16 @@ discard block |
||
1256 | 1255 | self::$wrappers[] = $scheme; |
1257 | 1256 | break; |
1258 | 1257 | case '': |
1259 | - break; // default file, always loaded |
|
1258 | + break; // default file, always loaded |
|
1260 | 1259 | default: |
1261 | 1260 | // check if scheme is buildin in php or one of our own stream wrappers |
1262 | - if (in_array($scheme,stream_get_wrappers()) || class_exists(self::scheme2class($scheme))) |
|
1261 | + if (in_array($scheme, stream_get_wrappers()) || class_exists(self::scheme2class($scheme))) |
|
1263 | 1262 | { |
1264 | 1263 | self::$wrappers[] = $scheme; |
1265 | 1264 | } |
1266 | 1265 | else |
1267 | 1266 | { |
1268 | - trigger_error("Can't load stream-wrapper for scheme '$scheme'!",E_USER_WARNING); |
|
1267 | + trigger_error("Can't load stream-wrapper for scheme '$scheme'!", E_USER_WARNING); |
|
1269 | 1268 | return false; |
1270 | 1269 | } |
1271 | 1270 | } |
@@ -1299,10 +1298,10 @@ discard block |
||
1299 | 1298 | static function scheme2class($scheme) |
1300 | 1299 | { |
1301 | 1300 | list($app, $app_scheme) = explode('.', $scheme); |
1302 | - foreach(array( |
|
1303 | - empty($app_scheme) ? 'EGroupware\\Api\\Vfs\\'.ucfirst($scheme).'\\StreamWrapper' : // streamwrapper in Api\Vfs |
|
1301 | + foreach (array( |
|
1302 | + empty($app_scheme) ? 'EGroupware\\Api\\Vfs\\'.ucfirst($scheme).'\\StreamWrapper' : // streamwrapper in Api\Vfs |
|
1304 | 1303 | 'EGroupware\\'.ucfirst($app).'\\Vfs\\'.ucfirst($app_scheme).'\\StreamWrapper', // streamwrapper in $app\Vfs |
1305 | - str_replace('.','_',$scheme).'_stream_wrapper', // old (flat) name |
|
1304 | + str_replace('.', '_', $scheme).'_stream_wrapper', // old (flat) name |
|
1306 | 1305 | ) as $class) |
1307 | 1306 | { |
1308 | 1307 | //error_log(__METHOD__."('$scheme') class_exists('$class')=".array2string(class_exists($class))); |
@@ -1319,7 +1318,7 @@ discard block |
||
1319 | 1318 | * @param int $component =-1 PHP_URL_* constants |
1320 | 1319 | * @return array|string|boolean on success array or string, if $component given, or false on failure |
1321 | 1320 | */ |
1322 | - static function parse_url($url, $component=-1) |
|
1321 | + static function parse_url($url, $component = -1) |
|
1323 | 1322 | { |
1324 | 1323 | static $component2str = array( |
1325 | 1324 | PHP_URL_SCHEME => 'scheme', |
@@ -1331,9 +1330,9 @@ discard block |
||
1331 | 1330 | PHP_URL_QUERY => 'query', |
1332 | 1331 | PHP_URL_FRAGMENT => 'fragment', |
1333 | 1332 | ); |
1334 | - static $cache = array(); // some caching |
|
1333 | + static $cache = array(); // some caching |
|
1335 | 1334 | |
1336 | - $result =& $cache[$url]; |
|
1335 | + $result = & $cache[$url]; |
|
1337 | 1336 | |
1338 | 1337 | if (!isset($result)) |
1339 | 1338 | { |
@@ -1370,7 +1369,7 @@ discard block |
||
1370 | 1369 | * @param string $only_remove_scheme =self::SCHEME if given only that scheme get's removed |
1371 | 1370 | * @return string path without training slash |
1372 | 1371 | */ |
1373 | - static protected function get_path($path,$only_remove_scheme=self::SCHEME) |
|
1372 | + static protected function get_path($path, $only_remove_scheme = self::SCHEME) |
|
1374 | 1373 | { |
1375 | 1374 | if ($path[0] != '/' && (!$only_remove_scheme || self::parse_url($path, PHP_URL_SCHEME) == $only_remove_scheme)) |
1376 | 1375 | { |
@@ -1381,7 +1380,7 @@ discard block |
||
1381 | 1380 | { |
1382 | 1381 | while (mb_substr($path, -1) == '/' && $path != '/' && ($path[0] == '/' || self::parse_url($path, PHP_URL_PATH) != '/')) |
1383 | 1382 | { |
1384 | - $path = mb_substr($path,0,-1); |
|
1383 | + $path = mb_substr($path, 0, -1); |
|
1385 | 1384 | } |
1386 | 1385 | } |
1387 | 1386 | return $path; |
@@ -1396,7 +1395,7 @@ discard block |
||
1396 | 1395 | static function url_is_readonly($url) |
1397 | 1396 | { |
1398 | 1397 | static $cache = array(); |
1399 | - $ret =& $cache[$url]; |
|
1398 | + $ret = & $cache[$url]; |
|
1400 | 1399 | if (!isset($ret)) |
1401 | 1400 | { |
1402 | 1401 | $matches = null; |
@@ -1411,7 +1410,7 @@ discard block |
||
1411 | 1410 | */ |
1412 | 1411 | static function init_static() |
1413 | 1412 | { |
1414 | - stream_register_wrapper(self::SCHEME,__CLASS__); |
|
1413 | + stream_register_wrapper(self::SCHEME, __CLASS__); |
|
1415 | 1414 | |
1416 | 1415 | if (($fstab = $GLOBALS['egw_info']['server']['vfs_fstab']) && is_array($fstab) && count($fstab)) |
1417 | 1416 | { |
@@ -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(self::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(self::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 | } |
@@ -491,10 +525,13 @@ discard block |
||
491 | 525 | */ |
492 | 526 | static function unlink ( $path ) |
493 | 527 | { |
494 | - if (!($url = self::resolve_url_symlinks($path,true,false))) // true,false file need to exist, but do not resolve last component |
|
528 | + if (!($url = self::resolve_url_symlinks($path,true,false))) |
|
529 | + { |
|
530 | + // true,false file need to exist, but do not resolve last component |
|
495 | 531 | { |
496 | 532 | return false; |
497 | 533 | } |
534 | + } |
|
498 | 535 | if (self::url_is_readonly($url)) |
499 | 536 | { |
500 | 537 | return false; |
@@ -547,7 +584,10 @@ discard block |
||
547 | 584 | $ret = stream_copy_to_stream($from,$to) !== false; |
548 | 585 | fclose($from); |
549 | 586 | fclose($to); |
550 | - if ($ret) self::unlink($path_from); |
|
587 | + if ($ret) |
|
588 | + { |
|
589 | + self::unlink($path_from); |
|
590 | + } |
|
551 | 591 | } |
552 | 592 | else |
553 | 593 | { |
@@ -584,10 +624,13 @@ discard block |
||
584 | 624 | */ |
585 | 625 | static function mkdir ( $path, $mode, $options ) |
586 | 626 | { |
587 | - if (!($url = self::resolve_url_symlinks($path,false))) // false = directory does not need to exists |
|
627 | + if (!($url = self::resolve_url_symlinks($path,false))) |
|
628 | + { |
|
629 | + // false = directory does not need to exists |
|
588 | 630 | { |
589 | 631 | return false; |
590 | 632 | } |
633 | + } |
|
591 | 634 | $ret = mkdir($url,$mode,$options); |
592 | 635 | |
593 | 636 | // call "vfs_mkdir" hook |
@@ -665,7 +708,10 @@ discard block |
||
665 | 708 | return false; |
666 | 709 | } |
667 | 710 | $k=(string)self::parse_url($url,PHP_URL_SCHEME); |
668 | - if (!(is_array($scheme2urls[$k]))) $scheme2urls[$k] = array(); |
|
711 | + if (!(is_array($scheme2urls[$k]))) |
|
712 | + { |
|
713 | + $scheme2urls[$k] = array(); |
|
714 | + } |
|
669 | 715 | $scheme2urls[$k][$path] = $url; |
670 | 716 | } |
671 | 717 | $ret = array(); |
@@ -675,7 +721,10 @@ discard block |
||
675 | 721 | { |
676 | 722 | if (!class_exists($class = self::scheme2class($scheme)) || !method_exists($class,$name)) |
677 | 723 | { |
678 | - if (!$fail_silent) trigger_error("Can't $name for scheme $scheme!\n",E_USER_WARNING); |
|
724 | + if (!$fail_silent) |
|
725 | + { |
|
726 | + trigger_error("Can't $name for scheme $scheme!\n",E_USER_WARNING); |
|
727 | + } |
|
679 | 728 | return false; |
680 | 729 | } |
681 | 730 | if (!is_array($pathes)) |
@@ -793,10 +842,13 @@ discard block |
||
793 | 842 | */ |
794 | 843 | static function symlink($target,$link) |
795 | 844 | { |
796 | - if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1))) // 1=path is in $link! |
|
845 | + if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1))) |
|
846 | + { |
|
847 | + // 1=path is in $link! |
|
797 | 848 | { |
798 | 849 | self::symlinkCache_remove($link); |
799 | 850 | } |
851 | + } |
|
800 | 852 | return $ret; |
801 | 853 | } |
802 | 854 | |
@@ -866,13 +918,19 @@ discard block |
||
866 | 918 | |
867 | 919 | if (!($this->opened_dir_url = self::resolve_url_symlinks($path))) |
868 | 920 | { |
869 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) resolve_url_symlinks() failed!"); |
|
921 | + if (self::LOG_LEVEL > 0) |
|
922 | + { |
|
923 | + error_log(__METHOD__."( $path,$options) resolve_url_symlinks() failed!"); |
|
924 | + } |
|
870 | 925 | return false; |
871 | 926 | } |
872 | 927 | if (!($this->opened_dir = $this->context ? |
873 | 928 | opendir($this->opened_dir_url, $this->context) : opendir($this->opened_dir_url))) |
874 | 929 | { |
875 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!"); |
|
930 | + if (self::LOG_LEVEL > 0) |
|
931 | + { |
|
932 | + error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!"); |
|
933 | + } |
|
876 | 934 | return false; |
877 | 935 | } |
878 | 936 | $this->opened_dir_writable = Vfs::check_access($this->opened_dir_url,Vfs::WRITABLE); |
@@ -890,7 +948,10 @@ discard block |
||
890 | 948 | } |
891 | 949 | |
892 | 950 | |
893 | - 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()); |
|
951 | + if (self::LOG_LEVEL > 1) |
|
952 | + { |
|
953 | + error_log(__METHOD__."( $path,$options): opendir($this->opened_dir_url)=$this->opened_dir, extra_dirs=".array2string($this->extra_dirs).', '.function_backtrace()); |
|
954 | + } |
|
894 | 955 | return true; |
895 | 956 | } |
896 | 957 | |
@@ -926,7 +987,10 @@ discard block |
||
926 | 987 | { |
927 | 988 | if (!($url = self::resolve_url($path,!($flags & STREAM_URL_STAT_LINK), $check_symlink_components))) |
928 | 989 | { |
929 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) can NOT resolve path!"); |
|
990 | + if (self::LOG_LEVEL > 0) |
|
991 | + { |
|
992 | + error_log(__METHOD__."('$path',$flags) can NOT resolve path!"); |
|
993 | + } |
|
930 | 994 | return false; |
931 | 995 | } |
932 | 996 | |
@@ -943,18 +1007,27 @@ discard block |
||
943 | 1007 | { |
944 | 1008 | if (!$check_symlink_depth) |
945 | 1009 | { |
946 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) maximum symlink depth exceeded, might be a circular symlink!"); |
|
1010 | + if (self::LOG_LEVEL > 0) |
|
1011 | + { |
|
1012 | + error_log(__METHOD__."('$path',$flags) maximum symlink depth exceeded, might be a circular symlink!"); |
|
1013 | + } |
|
947 | 1014 | $stat = false; |
948 | 1015 | } |
949 | 1016 | elseif (($lpath = self::readlink($url))) |
950 | 1017 | { |
951 | - if ($lpath[0] != '/') // concat relative path |
|
1018 | + if ($lpath[0] != '/') |
|
1019 | + { |
|
1020 | + // concat relative path |
|
952 | 1021 | { |
953 | 1022 | $lpath = Vfs::concat(self::parse_url($path,PHP_URL_PATH),'../'.$lpath); |
954 | 1023 | } |
1024 | + } |
|
955 | 1025 | $u_query = parse_url($url,PHP_URL_QUERY); |
956 | 1026 | $url = Vfs::PREFIX.$lpath; |
957 | - 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"); |
|
1027 | + if (self::LOG_LEVEL > 1) |
|
1028 | + { |
|
1029 | + 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"); |
|
1030 | + } |
|
958 | 1031 | // try reading the stat of the link |
959 | 1032 | if (($stat = self::url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth-1))) |
960 | 1033 | { |
@@ -967,7 +1040,11 @@ discard block |
||
967 | 1040 | $stat_query = http_build_query(array_merge($stat_query, $u_query)); |
968 | 1041 | $stat['url'] = $stat_url['scheme'].'://'.$stat_url['host'].$stat_url['path'].'?'.$stat_query; |
969 | 1042 | } |
970 | - if(isset($stat['url'])) $url = $stat['url']; // if stat returns an url use that, as there might be more links ... |
|
1043 | + if(isset($stat['url'])) |
|
1044 | + { |
|
1045 | + $url = $stat['url']; |
|
1046 | + } |
|
1047 | + // if stat returns an url use that, as there might be more links ... |
|
971 | 1048 | self::symlinkCache_add($path,$url); |
972 | 1049 | } |
973 | 1050 | } |
@@ -990,7 +1067,9 @@ discard block |
||
990 | 1067 | // check if a failed url_stat was for a home dir, in that case silently create it |
991 | 1068 | if (!$stat && $try_create_home && Vfs::dirname(self::parse_url($path,PHP_URL_PATH)) == '/home' && |
992 | 1069 | ($id = $GLOBALS['egw']->accounts->name2id(basename($path))) && |
993 | - $GLOBALS['egw']->accounts->id2name($id) == basename($path)) // make sure path has the right case! |
|
1070 | + $GLOBALS['egw']->accounts->id2name($id) == basename($path)) |
|
1071 | + { |
|
1072 | + // make sure path has the right case! |
|
994 | 1073 | { |
995 | 1074 | $hook_data = array( |
996 | 1075 | 'location' => $GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'addgroup' : 'addaccount', |
@@ -998,15 +1077,22 @@ discard block |
||
998 | 1077 | 'account_lid' => basename($path), |
999 | 1078 | 'account_name' => basename($path), |
1000 | 1079 | ); |
1080 | + } |
|
1001 | 1081 | call_user_func(array(__NAMESPACE__.'\\Hooks',$hook_data['location']),$hook_data); |
1002 | 1082 | unset($hook_data); |
1003 | 1083 | $stat = self::url_stat($path,$flags,false); |
1004 | 1084 | } |
1005 | 1085 | $query = parse_url($url, PHP_URL_QUERY); |
1006 | - if (!$stat && $check_symlink_components) // check if there's a symlink somewhere inbetween the path |
|
1086 | + if (!$stat && $check_symlink_components) |
|
1087 | + { |
|
1088 | + // check if there's a symlink somewhere inbetween the path |
|
1007 | 1089 | { |
1008 | 1090 | $stat = self::check_symlink_components($path,$flags,$url); |
1009 | - if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path,$stat['url']); |
|
1091 | + } |
|
1092 | + if ($stat && isset($stat['url']) && !$query) |
|
1093 | + { |
|
1094 | + self::symlinkCache_add($path,$stat['url']); |
|
1095 | + } |
|
1010 | 1096 | } |
1011 | 1097 | elseif(is_array($stat) && !isset($stat['url'])) |
1012 | 1098 | { |
@@ -1021,7 +1107,10 @@ discard block |
||
1021 | 1107 | $stat['url'] .= '?'.$query; |
1022 | 1108 | } |
1023 | 1109 | |
1024 | - 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)); |
|
1110 | + if (self::LOG_LEVEL > 1) |
|
1111 | + { |
|
1112 | + error_log(__METHOD__."('$path',$flags,try_create_home=$try_create_home,check_symlink_components=$check_symlink_components) returning ".array2string($stat)); |
|
1113 | + } |
|
1025 | 1114 | |
1026 | 1115 | return $stat; |
1027 | 1116 | |
@@ -1047,10 +1136,16 @@ discard block |
||
1047 | 1136 | { |
1048 | 1137 | if (is_null($url) && !($url = self::resolve_url($path))) |
1049 | 1138 | { |
1050 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags,'$url') can NOT resolve path: ".function_backtrace(1)); |
|
1139 | + if (self::LOG_LEVEL > 0) |
|
1140 | + { |
|
1141 | + error_log(__METHOD__."('$path',$flags,'$url') can NOT resolve path: ".function_backtrace(1)); |
|
1142 | + } |
|
1051 | 1143 | return false; |
1052 | 1144 | } |
1053 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1)); |
|
1145 | + if (self::LOG_LEVEL > 1) |
|
1146 | + { |
|
1147 | + error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1)); |
|
1148 | + } |
|
1054 | 1149 | |
1055 | 1150 | while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) && |
1056 | 1151 | ($url = Vfs::dirname($url))) |
@@ -1059,7 +1154,10 @@ discard block |
||
1059 | 1154 | { |
1060 | 1155 | if (is_link($url) && ($lpath = self::readlink($url))) |
1061 | 1156 | { |
1062 | - if (self::LOG_LEVEL > 1) $log = "rel_path='$rel_path', url='$url': lpath='$lpath'"; |
|
1157 | + if (self::LOG_LEVEL > 1) |
|
1158 | + { |
|
1159 | + $log = "rel_path='$rel_path', url='$url': lpath='$lpath'"; |
|
1160 | + } |
|
1063 | 1161 | |
1064 | 1162 | if ($lpath[0] != '/') |
1065 | 1163 | { |
@@ -1067,15 +1165,24 @@ discard block |
||
1067 | 1165 | } |
1068 | 1166 | //self::symlinkCache_add($path,Vfs::PREFIX.$lpath); |
1069 | 1167 | $url = Vfs::PREFIX.Vfs::concat($lpath,$rel_path); |
1070 | - if (self::LOG_LEVEL > 1) error_log("$log --> lpath='$lpath', url='$url'"); |
|
1168 | + if (self::LOG_LEVEL > 1) |
|
1169 | + { |
|
1170 | + error_log("$log --> lpath='$lpath', url='$url'"); |
|
1171 | + } |
|
1071 | 1172 | return self::url_stat($url,$flags); |
1072 | 1173 | } |
1073 | 1174 | $url = Vfs::concat($url,$rel_path); |
1074 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning null"); |
|
1175 | + if (self::LOG_LEVEL > 1) |
|
1176 | + { |
|
1177 | + error_log(__METHOD__."('$path',$flags,'$url') returning null"); |
|
1178 | + } |
|
1075 | 1179 | return null; |
1076 | 1180 | } |
1077 | 1181 | } |
1078 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning false"); |
|
1182 | + if (self::LOG_LEVEL > 1) |
|
1183 | + { |
|
1184 | + error_log(__METHOD__."('$path',$flags,'$url') returning false"); |
|
1185 | + } |
|
1079 | 1186 | return false; // $path does not exist |
1080 | 1187 | } |
1081 | 1188 | |
@@ -1096,9 +1203,16 @@ discard block |
||
1096 | 1203 | { |
1097 | 1204 | $path = self::get_path($_path); |
1098 | 1205 | |
1099 | - if (isset(self::$symlink_cache[$path])) return; // nothing to do |
|
1206 | + if (isset(self::$symlink_cache[$path])) |
|
1207 | + { |
|
1208 | + return; |
|
1209 | + } |
|
1210 | + // nothing to do |
|
1100 | 1211 | |
1101 | - if ($target[0] != '/') $target = self::parse_url($target,PHP_URL_PATH); |
|
1212 | + if ($target[0] != '/') |
|
1213 | + { |
|
1214 | + $target = self::parse_url($target,PHP_URL_PATH); |
|
1215 | + } |
|
1102 | 1216 | |
1103 | 1217 | self::$symlink_cache[$path] = $target; |
1104 | 1218 | |
@@ -1107,7 +1221,10 @@ discard block |
||
1107 | 1221 | { |
1108 | 1222 | return strlen($a) - strlen($b); |
1109 | 1223 | }); |
1110 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache)); |
|
1224 | + if (self::LOG_LEVEL > 1) |
|
1225 | + { |
|
1226 | + error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache)); |
|
1227 | + } |
|
1111 | 1228 | } |
1112 | 1229 | |
1113 | 1230 | /** |
@@ -1120,7 +1237,10 @@ discard block |
||
1120 | 1237 | $path = self::get_path($_path); |
1121 | 1238 | |
1122 | 1239 | unset(self::$symlink_cache[$path]); |
1123 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path) cache now ".array2string(self::$symlink_cache)); |
|
1240 | + if (self::LOG_LEVEL > 1) |
|
1241 | + { |
|
1242 | + error_log(__METHOD__."($path) cache now ".array2string(self::$symlink_cache)); |
|
1243 | + } |
|
1124 | 1244 | } |
1125 | 1245 | |
1126 | 1246 | /** |
@@ -1141,11 +1261,18 @@ discard block |
||
1141 | 1261 | |
1142 | 1262 | foreach(self::$symlink_cache as $p => $t) |
1143 | 1263 | { |
1144 | - if (($strlen_p = strlen($p)) > $strlen_path) continue; // $path can NOT start with $p |
|
1264 | + if (($strlen_p = strlen($p)) > $strlen_path) |
|
1265 | + { |
|
1266 | + continue; |
|
1267 | + } |
|
1268 | + // $path can NOT start with $p |
|
1145 | 1269 | |
1146 | 1270 | if ($path == $p) |
1147 | 1271 | { |
1148 | - if ($do_symlink) $target = $t; |
|
1272 | + if ($do_symlink) |
|
1273 | + { |
|
1274 | + $target = $t; |
|
1275 | + } |
|
1149 | 1276 | break; |
1150 | 1277 | } |
1151 | 1278 | elseif (substr($path,0,$strlen_p+1) == $p.'/') |
@@ -1154,7 +1281,10 @@ discard block |
||
1154 | 1281 | break; |
1155 | 1282 | } |
1156 | 1283 | } |
1157 | - if (self::LOG_LEVEL > 1 && isset($target)) error_log(__METHOD__."($path) = $target"); |
|
1284 | + if (self::LOG_LEVEL > 1 && isset($target)) |
|
1285 | + { |
|
1286 | + error_log(__METHOD__."($path) = $target"); |
|
1287 | + } |
|
1158 | 1288 | return isset($target) ? $target : $path; |
1159 | 1289 | } |
1160 | 1290 | |
@@ -1203,7 +1333,10 @@ discard block |
||
1203 | 1333 | self::HIDE_UNREADABLES && !$this->opened_dir_writable && |
1204 | 1334 | !Vfs::check_access(Vfs::concat($this->opened_dir_url,$file),Vfs::READABLE))); |
1205 | 1335 | } |
1206 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $this->opened_dir ) = '$file'"); |
|
1336 | + if (self::LOG_LEVEL > 1) |
|
1337 | + { |
|
1338 | + error_log(__METHOD__."( $this->opened_dir ) = '$file'"); |
|
1339 | + } |
|
1207 | 1340 | return $file; |
1208 | 1341 | } |
1209 | 1342 | |
@@ -1306,7 +1439,10 @@ discard block |
||
1306 | 1439 | ) as $class) |
1307 | 1440 | { |
1308 | 1441 | //error_log(__METHOD__."('$scheme') class_exists('$class')=".array2string(class_exists($class))); |
1309 | - if (class_exists($class)) return $class; |
|
1442 | + if (class_exists($class)) |
|
1443 | + { |
|
1444 | + return $class; |
|
1445 | + } |
|
1310 | 1446 | } |
1311 | 1447 | } |
1312 | 1448 | |
@@ -1341,7 +1477,10 @@ discard block |
||
1341 | 1477 | static $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%24', '%2C', '%2F', '%3F', '%23', '%5B', '%5D'); |
1342 | 1478 | static $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "$", ",", "/", "?", "#", "[", "]"); |
1343 | 1479 | static $str_replace = null; |
1344 | - if (!isset($str_replace)) $str_replace = function_exists('mb_str_replace') ? 'mb_str_replace' : 'str_replace'; |
|
1480 | + if (!isset($str_replace)) |
|
1481 | + { |
|
1482 | + $str_replace = function_exists('mb_str_replace') ? 'mb_str_replace' : 'str_replace'; |
|
1483 | + } |
|
1345 | 1484 | |
1346 | 1485 | // Create encoded URL with special URL characters decoded so it can be parsed |
1347 | 1486 | // All other characters will be encoded |
@@ -45,6 +45,7 @@ discard block |
||
45 | 45 | * This method is called when the stream is closed, using fclose(). |
46 | 46 | * |
47 | 47 | * You must release any resources that were locked or allocated by the stream. |
48 | + * @return boolean |
|
48 | 49 | */ |
49 | 50 | function stream_close ( ); |
50 | 51 | |
@@ -57,7 +58,7 @@ discard block |
||
57 | 58 | * You must also update the read/write position of the stream by the number of bytes that were successfully read. |
58 | 59 | * |
59 | 60 | * @param int $count |
60 | - * @return string/false up to count bytes read or false on EOF |
|
61 | + * @return string|false up to count bytes read or false on EOF |
|
61 | 62 | */ |
62 | 63 | function stream_read ( $count ); |
63 | 64 | |
@@ -114,7 +115,7 @@ discard block |
||
114 | 115 | * |
115 | 116 | * If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now. |
116 | 117 | * |
117 | - * @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. |
|
118 | + * @return boolean 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. |
|
118 | 119 | */ |
119 | 120 | function stream_flush ( ); |
120 | 121 | |
@@ -188,7 +189,7 @@ discard block |
||
188 | 189 | * This method is called immediately when your stream object is created for examining directory contents with opendir(). |
189 | 190 | * |
190 | 191 | * @param string $path URL that was passed to opendir() and that this object is expected to explore. |
191 | - * @return booelan |
|
192 | + * @return boolean |
|
192 | 193 | */ |
193 | 194 | function dir_opendir ( $path, $options ); |
194 | 195 |
@@ -80,10 +80,10 @@ |
||
80 | 80 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
81 | 81 | * |
82 | 82 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
83 | - * { |
|
83 | + * { |
|
84 | 84 | * $eof = !$eof; |
85 | 85 | * } |
86 | - * |
|
86 | + * |
|
87 | 87 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
88 | 88 | */ |
89 | 89 | function stream_eof ( ); |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set |
40 | 40 | * @return boolean true if the ressource was opened successful, otherwise false |
41 | 41 | */ |
42 | - function stream_open ( $path, $mode, $options, &$opened_path ); |
|
42 | + function stream_open($path, $mode, $options, &$opened_path); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * This method is called when the stream is closed, using fclose(). |
46 | 46 | * |
47 | 47 | * You must release any resources that were locked or allocated by the stream. |
48 | 48 | */ |
49 | - function stream_close ( ); |
|
49 | + function stream_close( ); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * This method is called in response to fread() and fgets() calls on the stream. |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param int $count |
60 | 60 | * @return string/false up to count bytes read or false on EOF |
61 | 61 | */ |
62 | - function stream_read ( $count ); |
|
62 | + function stream_read($count); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * This method is called in response to fwrite() calls on the stream. |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param string $data |
73 | 73 | * @return integer |
74 | 74 | */ |
75 | - function stream_write ( $data ); |
|
75 | + function stream_write($data); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * This method is called in response to feof() calls on the stream. |
@@ -86,14 +86,14 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
88 | 88 | */ |
89 | - function stream_eof ( ); |
|
89 | + function stream_eof( ); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * This method is called in response to ftell() calls on the stream. |
93 | 93 | * |
94 | 94 | * @return integer current read/write position of the stream |
95 | 95 | */ |
96 | - function stream_tell ( ); |
|
96 | + function stream_tell( ); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * This method is called in response to fseek() calls on the stream. |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * SEEK_END - 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.) |
108 | 108 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
109 | 109 | */ |
110 | - function stream_seek ( $offset, $whence ); |
|
110 | + function stream_seek($offset, $whence); |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * This method is called in response to fflush() calls on the stream. |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @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. |
118 | 118 | */ |
119 | - function stream_flush ( ); |
|
119 | + function stream_flush( ); |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * This method is called in response to fstat() calls on the stream. |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return array containing the same values as appropriate for the stream. |
134 | 134 | */ |
135 | - function stream_stat ( ); |
|
135 | + function stream_stat( ); |
|
136 | 136 | |
137 | 137 | /** |
138 | 138 | * This method is called in response to unlink() calls on URL paths associated with the wrapper. |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param string $path |
144 | 144 | * @return boolean TRUE on success or FALSE on failure |
145 | 145 | */ |
146 | - static function unlink ( $path ); |
|
146 | + static function unlink($path); |
|
147 | 147 | |
148 | 148 | /** |
149 | 149 | * This method is called in response to rename() calls on URL paths associated with the wrapper. |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param string $path_to |
158 | 158 | * @return boolean TRUE on success or FALSE on failure |
159 | 159 | */ |
160 | - static function rename ( $path_from, $path_to ); |
|
160 | + static function rename($path_from, $path_to); |
|
161 | 161 | |
162 | 162 | /** |
163 | 163 | * This method is called in response to mkdir() calls on URL paths associated with the wrapper. |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE |
171 | 171 | * @return boolean TRUE on success or FALSE on failure |
172 | 172 | */ |
173 | - static function mkdir ( $path, $mode, $options ); |
|
173 | + static function mkdir($path, $mode, $options); |
|
174 | 174 | |
175 | 175 | /** |
176 | 176 | * This method is called in response to rmdir() calls on URL paths associated with the wrapper. |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @param int $options Possible values include STREAM_REPORT_ERRORS. |
183 | 183 | * @return boolean TRUE on success or FALSE on failure. |
184 | 184 | */ |
185 | - static function rmdir ( $path, $options ); |
|
185 | + static function rmdir($path, $options); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * This method is called immediately when your stream object is created for examining directory contents with opendir(). |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @param string $path URL that was passed to opendir() and that this object is expected to explore. |
191 | 191 | * @return booelan |
192 | 192 | */ |
193 | - function dir_opendir ( $path, $options ); |
|
193 | + function dir_opendir($path, $options); |
|
194 | 194 | |
195 | 195 | /** |
196 | 196 | * This method is called in response to stat() calls on the URL paths associated with the wrapper. |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * stat triggers it's own warning anyway, so it makes no sense to trigger one by our stream-wrapper! |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - static function url_stat ( $path, $flags ); |
|
221 | + static function url_stat($path, $flags); |
|
222 | 222 | |
223 | 223 | /** |
224 | 224 | * This method is called in response to readdir(). |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @return string |
229 | 229 | */ |
230 | - function dir_readdir ( ); |
|
230 | + function dir_readdir( ); |
|
231 | 231 | |
232 | 232 | /** |
233 | 233 | * This method is called in response to rewinddir(). |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return boolean |
239 | 239 | */ |
240 | - function dir_rewinddir ( ); |
|
240 | + function dir_rewinddir( ); |
|
241 | 241 | |
242 | 242 | /** |
243 | 243 | * This method is called in response to closedir(). |
@@ -246,5 +246,5 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @return boolean |
248 | 248 | */ |
249 | - function dir_closedir ( ); |
|
249 | + function dir_closedir( ); |
|
250 | 250 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * Reimplemented to not check our vfs base path with realpath and connect to mysql DB |
58 | 58 | * |
59 | 59 | * @access public |
60 | - * @param $prefix =null prefix filesystem path with given path, eg. "/webdav" for owncloud 4.5 remote.php |
|
60 | + * @param string $prefix =null prefix filesystem path with given path, eg. "/webdav" for owncloud 4.5 remote.php |
|
61 | 61 | */ |
62 | 62 | function ServeRequest($prefix=null) |
63 | 63 | { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * DELETE method handler |
77 | 77 | * |
78 | 78 | * @param array general parameter passing array |
79 | - * @return bool true on success |
|
79 | + * @return string true on success |
|
80 | 80 | */ |
81 | 81 | function DELETE($options) |
82 | 82 | { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * Reimplemented to NOT use dirname/basename, which has problems with utf-8 chars |
117 | 117 | * |
118 | 118 | * @param array general parameter passing array |
119 | - * @return bool true on success |
|
119 | + * @return string true on success |
|
120 | 120 | */ |
121 | 121 | function MKCOL($options) |
122 | 122 | { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * COPY method handler |
152 | 152 | * |
153 | 153 | * @param array general parameter passing array |
154 | - * @return bool true on success |
|
154 | + * @return string true on success |
|
155 | 155 | */ |
156 | 156 | function COPY($options, $del=false) |
157 | 157 | { |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * but in the regular vfs attributes. |
478 | 478 | * |
479 | 479 | * @param array general parameter passing array |
480 | - * @return bool true on success |
|
480 | + * @return string true on success |
|
481 | 481 | */ |
482 | 482 | function PROPPATCH(&$options) |
483 | 483 | { |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | * LOCK method handler |
558 | 558 | * |
559 | 559 | * @param array general parameter passing array |
560 | - * @return bool true on success |
|
560 | + * @return string|boolean true on success |
|
561 | 561 | */ |
562 | 562 | function LOCK(&$options) |
563 | 563 | { |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | * UNLOCK method handler |
584 | 584 | * |
585 | 585 | * @param array general parameter passing array |
586 | - * @return bool true on success |
|
586 | + * @return string true on success |
|
587 | 587 | */ |
588 | 588 | function UNLOCK(&$options) |
589 | 589 | { |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | * Reimplement to add a Content-Disposition header, if ?download is appended to the REQUEST_URI |
641 | 641 | * |
642 | 642 | * @param array parameter passing array |
643 | - * @return bool true on success |
|
643 | + * @return boolean|null true on success |
|
644 | 644 | */ |
645 | 645 | function GET(&$options) |
646 | 646 | { |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | var $debug = 0; |
53 | 53 | |
54 | 54 | /** |
55 | - * Serve a webdav request |
|
56 | - * |
|
57 | - * Reimplemented to not check our vfs base path with realpath and connect to mysql DB |
|
58 | - * |
|
59 | - * @access public |
|
60 | - * @param $prefix =null prefix filesystem path with given path, eg. "/webdav" for owncloud 4.5 remote.php |
|
61 | - */ |
|
55 | + * Serve a webdav request |
|
56 | + * |
|
57 | + * Reimplemented to not check our vfs base path with realpath and connect to mysql DB |
|
58 | + * |
|
59 | + * @access public |
|
60 | + * @param $prefix =null prefix filesystem path with given path, eg. "/webdav" for owncloud 4.5 remote.php |
|
61 | + */ |
|
62 | 62 | function ServeRequest($prefix=null) |
63 | 63 | { |
64 | 64 | // special treatment for litmus compliance test |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | - * DELETE method handler |
|
77 | - * |
|
78 | - * @param array general parameter passing array |
|
79 | - * @return bool true on success |
|
80 | - */ |
|
76 | + * DELETE method handler |
|
77 | + * |
|
78 | + * @param array general parameter passing array |
|
79 | + * @return bool true on success |
|
80 | + */ |
|
81 | 81 | function DELETE($options) |
82 | 82 | { |
83 | 83 | $path = $this->base . $options['path']; |
@@ -110,165 +110,165 @@ discard block |
||
110 | 110 | return '204 No Content'; |
111 | 111 | } |
112 | 112 | |
113 | - /** |
|
114 | - * MKCOL method handler |
|
115 | - * |
|
116 | - * Reimplemented to NOT use dirname/basename, which has problems with utf-8 chars |
|
117 | - * |
|
118 | - * @param array general parameter passing array |
|
119 | - * @return bool true on success |
|
120 | - */ |
|
121 | - function MKCOL($options) |
|
122 | - { |
|
123 | - $path = $this->_unslashify($this->base .$options["path"]); |
|
124 | - $parent = Vfs::dirname($path); |
|
125 | - |
|
126 | - if (!file_exists($parent)) { |
|
127 | - return "409 Conflict"; |
|
128 | - } |
|
129 | - |
|
130 | - if (!is_dir($parent)) { |
|
131 | - return "403 Forbidden"; |
|
132 | - } |
|
133 | - |
|
134 | - if ( file_exists($path) ) { |
|
135 | - return "405 Method not allowed"; |
|
136 | - } |
|
137 | - |
|
138 | - if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
139 | - return "415 Unsupported media type"; |
|
140 | - } |
|
141 | - |
|
142 | - $stat = mkdir($path, 0777); |
|
143 | - if (!$stat) { |
|
144 | - return "403 Forbidden"; |
|
145 | - } |
|
146 | - |
|
147 | - return ("201 Created"); |
|
148 | - } |
|
113 | + /** |
|
114 | + * MKCOL method handler |
|
115 | + * |
|
116 | + * Reimplemented to NOT use dirname/basename, which has problems with utf-8 chars |
|
117 | + * |
|
118 | + * @param array general parameter passing array |
|
119 | + * @return bool true on success |
|
120 | + */ |
|
121 | + function MKCOL($options) |
|
122 | + { |
|
123 | + $path = $this->_unslashify($this->base .$options["path"]); |
|
124 | + $parent = Vfs::dirname($path); |
|
125 | + |
|
126 | + if (!file_exists($parent)) { |
|
127 | + return "409 Conflict"; |
|
128 | + } |
|
129 | + |
|
130 | + if (!is_dir($parent)) { |
|
131 | + return "403 Forbidden"; |
|
132 | + } |
|
133 | + |
|
134 | + if ( file_exists($path) ) { |
|
135 | + return "405 Method not allowed"; |
|
136 | + } |
|
137 | + |
|
138 | + if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
139 | + return "415 Unsupported media type"; |
|
140 | + } |
|
141 | + |
|
142 | + $stat = mkdir($path, 0777); |
|
143 | + if (!$stat) { |
|
144 | + return "403 Forbidden"; |
|
145 | + } |
|
146 | + |
|
147 | + return ("201 Created"); |
|
148 | + } |
|
149 | 149 | |
150 | 150 | /** |
151 | - * COPY method handler |
|
152 | - * |
|
153 | - * @param array general parameter passing array |
|
154 | - * @return bool true on success |
|
155 | - */ |
|
156 | - function COPY($options, $del=false) |
|
157 | - { |
|
158 | - // TODO Property updates still broken (Litmus should detect this?) |
|
159 | - |
|
160 | - if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
161 | - return "415 Unsupported media type"; |
|
162 | - } |
|
163 | - |
|
164 | - // no copying to different WebDAV Servers yet |
|
165 | - if (isset($options["dest_url"])) { |
|
166 | - return "502 bad gateway"; |
|
167 | - } |
|
168 | - |
|
169 | - $source = $this->base .$options["path"]; |
|
170 | - if (!file_exists($source)) return "404 Not found"; |
|
171 | - |
|
172 | - if (is_dir($source)) { // resource is a collection |
|
173 | - switch ($options["depth"]) { |
|
174 | - case "infinity": // valid |
|
175 | - break; |
|
176 | - case "0": // valid for COPY only |
|
177 | - if ($del) { // MOVE? |
|
178 | - return "400 Bad request"; |
|
179 | - } |
|
180 | - break; |
|
181 | - case "1": // invalid for both COPY and MOVE |
|
182 | - default: |
|
183 | - return "400 Bad request"; |
|
184 | - } |
|
185 | - } |
|
186 | - |
|
187 | - $dest = $this->base . $options["dest"]; |
|
188 | - $destdir = dirname($dest); |
|
189 | - |
|
190 | - if (!file_exists($destdir) || !is_dir($destdir)) { |
|
191 | - return "409 Conflict"; |
|
192 | - } |
|
193 | - |
|
194 | - $new = !file_exists($dest); |
|
195 | - $existing_col = false; |
|
196 | - |
|
197 | - if (!$new) { |
|
198 | - if ($del && is_dir($dest)) { |
|
199 | - if (!$options["overwrite"]) { |
|
200 | - return "412 precondition failed"; |
|
201 | - } |
|
202 | - $dest .= basename($source); |
|
203 | - if (file_exists($dest)) { |
|
204 | - $options["dest"] .= basename($source); |
|
205 | - } else { |
|
206 | - $new = true; |
|
207 | - $existing_col = true; |
|
208 | - } |
|
209 | - } |
|
210 | - } |
|
211 | - |
|
212 | - if (!$new) { |
|
213 | - if ($options["overwrite"]) { |
|
214 | - $stat = $this->DELETE(array("path" => $options["dest"])); |
|
215 | - if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) { |
|
216 | - return $stat; |
|
217 | - } |
|
218 | - } else { |
|
219 | - return "412 precondition failed"; |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - if ($del) { |
|
224 | - if (!rename($source, $dest)) { |
|
225 | - return "500 Internal server error"; |
|
226 | - } |
|
227 | - } else { |
|
228 | - if (is_dir($source) && $options['depth'] == 'infinity') { |
|
229 | - $files = Vfs::find($source,array('depth' => true,'url' => true)); // depth=true: return dirs first, url=true: allow urls! |
|
230 | - } else { |
|
231 | - $files = array($source); |
|
232 | - } |
|
233 | - |
|
234 | - if (!is_array($files) || empty($files)) { |
|
235 | - return "500 Internal server error"; |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - foreach ($files as $file) { |
|
240 | - if (is_dir($file)) { |
|
241 | - $file = $this->_slashify($file); |
|
242 | - } |
|
243 | - |
|
244 | - $destfile = str_replace($source, $dest, $file); |
|
245 | - |
|
246 | - if (is_dir($file)) { |
|
247 | - if (!is_dir($destfile)) { |
|
248 | - // TODO "mkdir -p" here? (only natively supported by PHP 5) |
|
249 | - if (!@mkdir($destfile)) { |
|
250 | - return "409 Conflict"; |
|
251 | - } |
|
252 | - } |
|
253 | - } else { |
|
254 | - if (!@copy($file, $destfile)) { |
|
255 | - return "409 Conflict"; |
|
256 | - } |
|
257 | - } |
|
258 | - } |
|
259 | - } |
|
260 | - // adding Location header as shown in example in rfc2518 section 8.9.5 |
|
151 | + * COPY method handler |
|
152 | + * |
|
153 | + * @param array general parameter passing array |
|
154 | + * @return bool true on success |
|
155 | + */ |
|
156 | + function COPY($options, $del=false) |
|
157 | + { |
|
158 | + // TODO Property updates still broken (Litmus should detect this?) |
|
159 | + |
|
160 | + if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
161 | + return "415 Unsupported media type"; |
|
162 | + } |
|
163 | + |
|
164 | + // no copying to different WebDAV Servers yet |
|
165 | + if (isset($options["dest_url"])) { |
|
166 | + return "502 bad gateway"; |
|
167 | + } |
|
168 | + |
|
169 | + $source = $this->base .$options["path"]; |
|
170 | + if (!file_exists($source)) return "404 Not found"; |
|
171 | + |
|
172 | + if (is_dir($source)) { // resource is a collection |
|
173 | + switch ($options["depth"]) { |
|
174 | + case "infinity": // valid |
|
175 | + break; |
|
176 | + case "0": // valid for COPY only |
|
177 | + if ($del) { // MOVE? |
|
178 | + return "400 Bad request"; |
|
179 | + } |
|
180 | + break; |
|
181 | + case "1": // invalid for both COPY and MOVE |
|
182 | + default: |
|
183 | + return "400 Bad request"; |
|
184 | + } |
|
185 | + } |
|
186 | + |
|
187 | + $dest = $this->base . $options["dest"]; |
|
188 | + $destdir = dirname($dest); |
|
189 | + |
|
190 | + if (!file_exists($destdir) || !is_dir($destdir)) { |
|
191 | + return "409 Conflict"; |
|
192 | + } |
|
193 | + |
|
194 | + $new = !file_exists($dest); |
|
195 | + $existing_col = false; |
|
196 | + |
|
197 | + if (!$new) { |
|
198 | + if ($del && is_dir($dest)) { |
|
199 | + if (!$options["overwrite"]) { |
|
200 | + return "412 precondition failed"; |
|
201 | + } |
|
202 | + $dest .= basename($source); |
|
203 | + if (file_exists($dest)) { |
|
204 | + $options["dest"] .= basename($source); |
|
205 | + } else { |
|
206 | + $new = true; |
|
207 | + $existing_col = true; |
|
208 | + } |
|
209 | + } |
|
210 | + } |
|
211 | + |
|
212 | + if (!$new) { |
|
213 | + if ($options["overwrite"]) { |
|
214 | + $stat = $this->DELETE(array("path" => $options["dest"])); |
|
215 | + if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) { |
|
216 | + return $stat; |
|
217 | + } |
|
218 | + } else { |
|
219 | + return "412 precondition failed"; |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + if ($del) { |
|
224 | + if (!rename($source, $dest)) { |
|
225 | + return "500 Internal server error"; |
|
226 | + } |
|
227 | + } else { |
|
228 | + if (is_dir($source) && $options['depth'] == 'infinity') { |
|
229 | + $files = Vfs::find($source,array('depth' => true,'url' => true)); // depth=true: return dirs first, url=true: allow urls! |
|
230 | + } else { |
|
231 | + $files = array($source); |
|
232 | + } |
|
233 | + |
|
234 | + if (!is_array($files) || empty($files)) { |
|
235 | + return "500 Internal server error"; |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + foreach ($files as $file) { |
|
240 | + if (is_dir($file)) { |
|
241 | + $file = $this->_slashify($file); |
|
242 | + } |
|
243 | + |
|
244 | + $destfile = str_replace($source, $dest, $file); |
|
245 | + |
|
246 | + if (is_dir($file)) { |
|
247 | + if (!is_dir($destfile)) { |
|
248 | + // TODO "mkdir -p" here? (only natively supported by PHP 5) |
|
249 | + if (!@mkdir($destfile)) { |
|
250 | + return "409 Conflict"; |
|
251 | + } |
|
252 | + } |
|
253 | + } else { |
|
254 | + if (!@copy($file, $destfile)) { |
|
255 | + return "409 Conflict"; |
|
256 | + } |
|
257 | + } |
|
258 | + } |
|
259 | + } |
|
260 | + // adding Location header as shown in example in rfc2518 section 8.9.5 |
|
261 | 261 | header('Location: '.$this->base_uri.$options['dest']); |
262 | 262 | |
263 | - return ($new && !$existing_col) ? "201 Created" : "204 No Content"; |
|
264 | - } |
|
263 | + return ($new && !$existing_col) ? "201 Created" : "204 No Content"; |
|
264 | + } |
|
265 | 265 | |
266 | - /** |
|
267 | - * Get properties for a single file/resource |
|
268 | - * |
|
269 | - * @param string $_path resource path |
|
270 | - * @return array resource properties |
|
271 | - */ |
|
266 | + /** |
|
267 | + * Get properties for a single file/resource |
|
268 | + * |
|
269 | + * @param string $_path resource path |
|
270 | + * @return array resource properties |
|
271 | + */ |
|
272 | 272 | function fileinfo($_path) |
273 | 273 | { |
274 | 274 | // internally we require some url-encoding, as vfs_stream_wrapper uses URL's internally |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | $info['props'][] = self::mkprop ('creationdate', filectime($fspath)); |
297 | 297 | $info['props'][] = self::mkprop ('getlastmodified', filemtime($fspath)); |
298 | 298 | |
299 | - // Microsoft extensions: last access time and 'hidden' status |
|
300 | - $info["props"][] = self::mkprop("lastaccessed", fileatime($fspath)); |
|
301 | - $info["props"][] = self::mkprop("ishidden", Vfs::is_hidden($fspath)); |
|
299 | + // Microsoft extensions: last access time and 'hidden' status |
|
300 | + $info["props"][] = self::mkprop("lastaccessed", fileatime($fspath)); |
|
301 | + $info["props"][] = self::mkprop("ishidden", Vfs::is_hidden($fspath)); |
|
302 | 302 | |
303 | 303 | // type and size (caller already made sure that path exists) |
304 | 304 | if (is_dir($fspath)) { |
@@ -436,38 +436,38 @@ discard block |
||
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
439 | - * Used eg. by get |
|
440 | - * |
|
441 | - * @todo replace all calls to _mimetype with Vfs::mime_content_type() |
|
442 | - * @param string $path |
|
443 | - * @return string |
|
444 | - */ |
|
439 | + * Used eg. by get |
|
440 | + * |
|
441 | + * @todo replace all calls to _mimetype with Vfs::mime_content_type() |
|
442 | + * @param string $path |
|
443 | + * @return string |
|
444 | + */ |
|
445 | 445 | function _mimetype($path) |
446 | 446 | { |
447 | 447 | return Vfs::mime_content_type($path); |
448 | 448 | } |
449 | 449 | |
450 | - /** |
|
451 | - * Check if path is readable by current user |
|
452 | - * |
|
453 | - * @param string $fspath |
|
454 | - * @return boolean |
|
455 | - */ |
|
456 | - function _is_readable($fspath) |
|
457 | - { |
|
458 | - return Vfs::is_readable($fspath); |
|
459 | - } |
|
460 | - |
|
461 | - /** |
|
462 | - * Check if path is writable by current user |
|
463 | - * |
|
464 | - * @param string $fspath |
|
465 | - * @return boolean |
|
466 | - */ |
|
467 | - function _is_writable($fspath) |
|
468 | - { |
|
469 | - return Vfs::is_writable($fspath); |
|
470 | - } |
|
450 | + /** |
|
451 | + * Check if path is readable by current user |
|
452 | + * |
|
453 | + * @param string $fspath |
|
454 | + * @return boolean |
|
455 | + */ |
|
456 | + function _is_readable($fspath) |
|
457 | + { |
|
458 | + return Vfs::is_readable($fspath); |
|
459 | + } |
|
460 | + |
|
461 | + /** |
|
462 | + * Check if path is writable by current user |
|
463 | + * |
|
464 | + * @param string $fspath |
|
465 | + * @return boolean |
|
466 | + */ |
|
467 | + function _is_writable($fspath) |
|
468 | + { |
|
469 | + return Vfs::is_writable($fspath); |
|
470 | + } |
|
471 | 471 | |
472 | 472 | /** |
473 | 473 | * PROPPATCH method handler |
@@ -610,13 +610,13 @@ discard block |
||
610 | 610 | * @param string directory path |
611 | 611 | * @return void function has to handle HTTP response itself |
612 | 612 | */ |
613 | - function GetDir($fspath, &$options) |
|
614 | - { |
|
613 | + function GetDir($fspath, &$options) |
|
614 | + { |
|
615 | 615 | // add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv) |
616 | 616 | header('Content-type: text/html; charset='.Api\Translation::charset()); |
617 | 617 | |
618 | 618 | parent::GetDir($fspath, $options); |
619 | - } |
|
619 | + } |
|
620 | 620 | |
621 | 621 | private $force_download = false; |
622 | 622 |
@@ -171,16 +171,16 @@ |
||
171 | 171 | |
172 | 172 | if (is_dir($source)) { // resource is a collection |
173 | 173 | switch ($options["depth"]) { |
174 | - case "infinity": // valid |
|
175 | - break; |
|
176 | - case "0": // valid for COPY only |
|
177 | - if ($del) { // MOVE? |
|
178 | - return "400 Bad request"; |
|
179 | - } |
|
180 | - break; |
|
181 | - case "1": // invalid for both COPY and MOVE |
|
182 | - default: |
|
183 | - return "400 Bad request"; |
|
174 | + case "infinity": // valid |
|
175 | + break; |
|
176 | + case "0": // valid for COPY only |
|
177 | + if ($del) { // MOVE? |
|
178 | + return "400 Bad request"; |
|
179 | + } |
|
180 | + break; |
|
181 | + case "1": // invalid for both COPY and MOVE |
|
182 | + default: |
|
183 | + return "400 Bad request"; |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @access public |
60 | 60 | * @param $prefix =null prefix filesystem path with given path, eg. "/webdav" for owncloud 4.5 remote.php |
61 | 61 | */ |
62 | - function ServeRequest($prefix=null) |
|
62 | + function ServeRequest($prefix = null) |
|
63 | 63 | { |
64 | 64 | // special treatment for litmus compliance test |
65 | 65 | // reply on its identifier header |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | function DELETE($options) |
82 | 82 | { |
83 | - $path = $this->base . $options['path']; |
|
83 | + $path = $this->base.$options['path']; |
|
84 | 84 | |
85 | 85 | if (!file_exists($path)) |
86 | 86 | { |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | function MKCOL($options) |
122 | 122 | { |
123 | - $path = $this->_unslashify($this->base .$options["path"]); |
|
123 | + $path = $this->_unslashify($this->base.$options["path"]); |
|
124 | 124 | $parent = Vfs::dirname($path); |
125 | 125 | |
126 | 126 | if (!file_exists($parent)) { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | return "403 Forbidden"; |
132 | 132 | } |
133 | 133 | |
134 | - if ( file_exists($path) ) { |
|
134 | + if (file_exists($path)) { |
|
135 | 135 | return "405 Method not allowed"; |
136 | 136 | } |
137 | 137 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param array general parameter passing array |
154 | 154 | * @return bool true on success |
155 | 155 | */ |
156 | - function COPY($options, $del=false) |
|
156 | + function COPY($options, $del = false) |
|
157 | 157 | { |
158 | 158 | // TODO Property updates still broken (Litmus should detect this?) |
159 | 159 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | return "502 bad gateway"; |
167 | 167 | } |
168 | 168 | |
169 | - $source = $this->base .$options["path"]; |
|
169 | + $source = $this->base.$options["path"]; |
|
170 | 170 | if (!file_exists($source)) return "404 Not found"; |
171 | 171 | |
172 | 172 | if (is_dir($source)) { // resource is a collection |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | - $dest = $this->base . $options["dest"]; |
|
187 | + $dest = $this->base.$options["dest"]; |
|
188 | 188 | $destdir = dirname($dest); |
189 | 189 | |
190 | 190 | if (!file_exists($destdir) || !is_dir($destdir)) { |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | } |
227 | 227 | } else { |
228 | 228 | if (is_dir($source) && $options['depth'] == 'infinity') { |
229 | - $files = Vfs::find($source,array('depth' => true,'url' => true)); // depth=true: return dirs first, url=true: allow urls! |
|
229 | + $files = Vfs::find($source, array('depth' => true, 'url' => true)); // depth=true: return dirs first, url=true: allow urls! |
|
230 | 230 | } else { |
231 | 231 | $files = array($source); |
232 | 232 | } |
@@ -272,16 +272,16 @@ discard block |
||
272 | 272 | function fileinfo($_path) |
273 | 273 | { |
274 | 274 | // internally we require some url-encoding, as vfs_stream_wrapper uses URL's internally |
275 | - $path = str_replace(array('#','?'),array('%23','%3F'),$_path); |
|
275 | + $path = str_replace(array('#', '?'), array('%23', '%3F'), $_path); |
|
276 | 276 | |
277 | 277 | //error_log(__METHOD__."($path)"); |
278 | 278 | // map URI path to filesystem path |
279 | - $fspath = $this->base . $path; |
|
279 | + $fspath = $this->base.$path; |
|
280 | 280 | |
281 | 281 | // create result array |
282 | 282 | $info = array(); |
283 | 283 | // TODO remove slash append code when base class is able to do it itself |
284 | - $info['path'] = is_dir($fspath) ? $this->_slashify($path) : $path; |
|
284 | + $info['path'] = is_dir($fspath) ? $this->_slashify($path) : $path; |
|
285 | 285 | |
286 | 286 | // remove all urlencoding we need internally in EGw, HTTP_WebDAV_Server will add it's own! |
287 | 287 | // rawurldecode does NOT touch + |
@@ -290,32 +290,32 @@ discard block |
||
290 | 290 | $info['props'] = array(); |
291 | 291 | |
292 | 292 | // no special beautified displayname here ... |
293 | - $info['props'][] = self::mkprop ('displayname', Vfs::basename(self::_unslashify($info['path']))); |
|
293 | + $info['props'][] = self::mkprop('displayname', Vfs::basename(self::_unslashify($info['path']))); |
|
294 | 294 | |
295 | 295 | // creation and modification time |
296 | - $info['props'][] = self::mkprop ('creationdate', filectime($fspath)); |
|
297 | - $info['props'][] = self::mkprop ('getlastmodified', filemtime($fspath)); |
|
296 | + $info['props'][] = self::mkprop('creationdate', filectime($fspath)); |
|
297 | + $info['props'][] = self::mkprop('getlastmodified', filemtime($fspath)); |
|
298 | 298 | |
299 | 299 | // Microsoft extensions: last access time and 'hidden' status |
300 | - $info["props"][] = self::mkprop("lastaccessed", fileatime($fspath)); |
|
301 | - $info["props"][] = self::mkprop("ishidden", Vfs::is_hidden($fspath)); |
|
300 | + $info["props"][] = self::mkprop("lastaccessed", fileatime($fspath)); |
|
301 | + $info["props"][] = self::mkprop("ishidden", Vfs::is_hidden($fspath)); |
|
302 | 302 | |
303 | 303 | // type and size (caller already made sure that path exists) |
304 | 304 | if (is_dir($fspath)) { |
305 | 305 | // directory (WebDAV collection) |
306 | - $info['props'][] = self::mkprop ('resourcetype', array( |
|
306 | + $info['props'][] = self::mkprop('resourcetype', array( |
|
307 | 307 | self::mkprop('collection', ''))); |
308 | - $info['props'][] = self::mkprop ('getcontenttype', 'httpd/unix-directory'); |
|
308 | + $info['props'][] = self::mkprop('getcontenttype', 'httpd/unix-directory'); |
|
309 | 309 | } else { |
310 | 310 | // plain file (WebDAV resource) |
311 | - $info['props'][] = self::mkprop ('resourcetype', ''); |
|
311 | + $info['props'][] = self::mkprop('resourcetype', ''); |
|
312 | 312 | if (Vfs::is_readable($path)) { |
313 | - $info['props'][] = self::mkprop ('getcontenttype', Vfs::mime_content_type($path)); |
|
313 | + $info['props'][] = self::mkprop('getcontenttype', Vfs::mime_content_type($path)); |
|
314 | 314 | } else { |
315 | 315 | error_log(__METHOD__."($path) $fspath is not readable!"); |
316 | - $info['props'][] = self::mkprop ('getcontenttype', 'application/x-non-readable'); |
|
316 | + $info['props'][] = self::mkprop('getcontenttype', 'application/x-non-readable'); |
|
317 | 317 | } |
318 | - $info['props'][] = self::mkprop ('getcontentlength', filesize($fspath)); |
|
318 | + $info['props'][] = self::mkprop('getcontentlength', filesize($fspath)); |
|
319 | 319 | } |
320 | 320 | // generate etag from inode (sqlfs: fs_id), modification time and size |
321 | 321 | $stat = stat($fspath); |
@@ -369,21 +369,21 @@ discard block |
||
369 | 369 | */ |
370 | 370 | function PROPFIND(&$options, &$files) |
371 | 371 | { |
372 | - if (!parent::PROPFIND($options,$files)) |
|
372 | + if (!parent::PROPFIND($options, $files)) |
|
373 | 373 | { |
374 | 374 | return false; |
375 | 375 | } |
376 | 376 | $path2n = array(); |
377 | - foreach($files['files'] as $n => $info) |
|
377 | + foreach ($files['files'] as $n => $info) |
|
378 | 378 | { |
379 | 379 | // do NOT report /clientsync/.favorites/, as it fails |
380 | - if (strpos($info['path'],'/clientsync/.favorites/') === 0) |
|
380 | + if (strpos($info['path'], '/clientsync/.favorites/') === 0) |
|
381 | 381 | { |
382 | 382 | unset($files['files'][$n]); |
383 | 383 | continue; |
384 | 384 | } |
385 | 385 | $_path = $info['path']; |
386 | - if (!$n && $info['path'] != '/' && substr($info['path'],-1) == '/') $_path = substr($info['path'],0,-1); |
|
386 | + if (!$n && $info['path'] != '/' && substr($info['path'], -1) == '/') $_path = substr($info['path'], 0, -1); |
|
387 | 387 | |
388 | 388 | // need to encode path again, as $info['path'] is NOT encoded, but Vfs::(stat|propfind) require it |
389 | 389 | // otherwise pathes containing url special chars like ? or # will not stat |
@@ -393,21 +393,21 @@ discard block |
||
393 | 393 | // adding some properties used instead of regular DAV times |
394 | 394 | if (($stat = Vfs::stat($path))) |
395 | 395 | { |
396 | - $fileprops =& $files['files'][$path2n[$path]]['props']; |
|
397 | - foreach(self::$auto_props as $attr => $props) |
|
396 | + $fileprops = & $files['files'][$path2n[$path]]['props']; |
|
397 | + foreach (self::$auto_props as $attr => $props) |
|
398 | 398 | { |
399 | - switch($attr) |
|
399 | + switch ($attr) |
|
400 | 400 | { |
401 | 401 | case 'ctime': |
402 | 402 | case 'mtime': |
403 | 403 | case 'atime': |
404 | - $value = gmdate('D, d M Y H:i:s T',$stat[$attr]); |
|
404 | + $value = gmdate('D, d M Y H:i:s T', $stat[$attr]); |
|
405 | 405 | break; |
406 | 406 | |
407 | 407 | default: |
408 | 408 | continue 2; |
409 | 409 | } |
410 | - foreach($props as $prop) |
|
410 | + foreach ($props as $prop) |
|
411 | 411 | { |
412 | 412 | $prop['val'] = $value; |
413 | 413 | $fileprops[] = $prop; |
@@ -415,17 +415,17 @@ discard block |
||
415 | 415 | } |
416 | 416 | } |
417 | 417 | } |
418 | - if ($path2n && ($path2props = Vfs::propfind(array_keys($path2n),null))) |
|
418 | + if ($path2n && ($path2props = Vfs::propfind(array_keys($path2n), null))) |
|
419 | 419 | { |
420 | - foreach($path2props as $path => $props) |
|
420 | + foreach ($path2props as $path => $props) |
|
421 | 421 | { |
422 | - $fileprops =& $files['files'][$path2n[$path]]['props']; |
|
423 | - foreach($props as $prop) |
|
422 | + $fileprops = & $files['files'][$path2n[$path]]['props']; |
|
423 | + foreach ($props as $prop) |
|
424 | 424 | { |
425 | 425 | if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'][0] == '#') // eGW's customfields |
426 | 426 | { |
427 | 427 | $prop['ns'] .= 'customfields/'; |
428 | - $prop['name'] = substr($prop['name'],1); |
|
428 | + $prop['name'] = substr($prop['name'], 1); |
|
429 | 429 | } |
430 | 430 | $fileprops[] = $prop; |
431 | 431 | } |
@@ -481,36 +481,36 @@ discard block |
||
481 | 481 | */ |
482 | 482 | function PROPPATCH(&$options) |
483 | 483 | { |
484 | - $path = Api\Translation::convert($options['path'],'utf-8'); |
|
484 | + $path = Api\Translation::convert($options['path'], 'utf-8'); |
|
485 | 485 | |
486 | 486 | foreach ($options['props'] as $key => $prop) { |
487 | 487 | $attributes = array(); |
488 | - switch($prop['ns']) |
|
488 | + switch ($prop['ns']) |
|
489 | 489 | { |
490 | 490 | // allow Webdrive to set creation and modification time |
491 | 491 | case 'http://www.southrivertech.com/': |
492 | - switch($prop['name']) |
|
492 | + switch ($prop['name']) |
|
493 | 493 | { |
494 | 494 | case 'srt_modifiedtime': |
495 | 495 | case 'getlastmodified': |
496 | - Vfs::touch($path,strtotime($prop['val'])); |
|
496 | + Vfs::touch($path, strtotime($prop['val'])); |
|
497 | 497 | break; |
498 | 498 | //case 'srt_creationtime': |
499 | 499 | // no streamwrapper interface / php function to set the ctime currently |
500 | 500 | //$attributes['created'] = strtotime($prop['val']); |
501 | 501 | //break; |
502 | 502 | default: |
503 | - if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
503 | + if (!Vfs::proppatch($path, array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
504 | 504 | break; |
505 | 505 | } |
506 | 506 | break; |
507 | 507 | |
508 | 508 | case 'DAV:': |
509 | - switch($prop['name']) |
|
509 | + switch ($prop['name']) |
|
510 | 510 | { |
511 | 511 | // allow netdrive to change the modification time |
512 | 512 | case 'getlastmodified': |
513 | - Vfs::touch($path,strtotime($prop['val'])); |
|
513 | + Vfs::touch($path, strtotime($prop['val'])); |
|
514 | 514 | break; |
515 | 515 | // not sure why, the filesystem example of the WebDAV class does it ... |
516 | 516 | default: |
@@ -520,16 +520,16 @@ discard block |
||
520 | 520 | break; |
521 | 521 | |
522 | 522 | case 'urn:schemas-microsoft-com:': |
523 | - switch($prop['name']) |
|
523 | + switch ($prop['name']) |
|
524 | 524 | { |
525 | 525 | case 'Win32LastModifiedTime': |
526 | - Vfs::touch($path,strtotime($prop['val'])); |
|
526 | + Vfs::touch($path, strtotime($prop['val'])); |
|
527 | 527 | break; |
528 | 528 | case 'Win32CreationTime': // eg. "Wed, 14 Sep 2011 15:48:26 GMT" |
529 | 529 | case 'Win32LastAccessTime': |
530 | 530 | case 'Win32FileAttributes': // not sure what that is, it was always "00000000" |
531 | 531 | default: |
532 | - if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
532 | + if (!Vfs::proppatch($path, array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
533 | 533 | break; |
534 | 534 | } |
535 | 535 | break; |
@@ -539,18 +539,18 @@ discard block |
||
539 | 539 | $prop['name'] = '#'.$prop['name']; |
540 | 540 | // fall through |
541 | 541 | default: |
542 | - if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
542 | + if (!Vfs::proppatch($path, array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
543 | 543 | break; |
544 | 544 | } |
545 | 545 | if ($this->debug) $props[] = '('.$prop['ns'].')'.$prop['name'].'='.$prop['val']; |
546 | 546 | } |
547 | 547 | if ($this->debug) |
548 | 548 | { |
549 | - error_log(__METHOD__.": path=$options[path], props=".implode(', ',$props)); |
|
550 | - if ($attributes) error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n",' ',print_r($attributes,true))); |
|
549 | + error_log(__METHOD__.": path=$options[path], props=".implode(', ', $props)); |
|
550 | + if ($attributes) error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n", ' ', print_r($attributes, true))); |
|
551 | 551 | } |
552 | 552 | |
553 | - return ''; // this is as the filesystem example handler does it, no true or false ... |
|
553 | + return ''; // this is as the filesystem example handler does it, no true or false ... |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -561,18 +561,18 @@ discard block |
||
561 | 561 | */ |
562 | 562 | function LOCK(&$options) |
563 | 563 | { |
564 | - if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')'); |
|
564 | + if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n", ' '), '', print_r($options, true)).')'); |
|
565 | 565 | // TODO recursive locks on directories not supported yet |
566 | - if (is_dir($this->base . $options['path']) && !empty($options['depth'])) |
|
566 | + if (is_dir($this->base.$options['path']) && !empty($options['depth'])) |
|
567 | 567 | { |
568 | 568 | return '409 Conflict'; |
569 | 569 | } |
570 | - $options['timeout'] = time()+300; // 5min. hardcoded |
|
570 | + $options['timeout'] = time() + 300; // 5min. hardcoded |
|
571 | 571 | |
572 | 572 | // dont know why, but HTTP_WebDAV_Server passes the owner in D:href tags, which get's passed unchanged to checkLock/PROPFIND |
573 | 573 | // that's wrong according to the standard and cadaver does not show it on discover --> strip_tags removes eventual tags |
574 | - if (($ret = Vfs::lock($options['path'],$options['locktoken'],$options['timeout'],strip_tags($options['owner']), |
|
575 | - $options['scope'],$options['type'],isset($options['update']))) && !isset($options['update'])) |
|
574 | + if (($ret = Vfs::lock($options['path'], $options['locktoken'], $options['timeout'], strip_tags($options['owner']), |
|
575 | + $options['scope'], $options['type'], isset($options['update']))) && !isset($options['update'])) |
|
576 | 576 | { |
577 | 577 | return $ret ? '200 OK' : '409 Conflict'; |
578 | 578 | } |
@@ -587,8 +587,8 @@ discard block |
||
587 | 587 | */ |
588 | 588 | function UNLOCK(&$options) |
589 | 589 | { |
590 | - if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')'); |
|
591 | - return Vfs::unlock($options['path'],$options['token']) ? '204 No Content' : '409 Conflict'; |
|
590 | + if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n", ' '), '', print_r($options, true)).')'); |
|
591 | + return Vfs::unlock($options['path'], $options['token']) ? '204 No Content' : '409 Conflict'; |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
@@ -627,9 +627,9 @@ discard block |
||
627 | 627 | */ |
628 | 628 | function __construct() |
629 | 629 | { |
630 | - if ($_SERVER['REQUEST_METHOD'] == 'GET' && (($this->force_download = strpos($_SERVER['REQUEST_URI'],'?download')) !== false)) |
|
630 | + if ($_SERVER['REQUEST_METHOD'] == 'GET' && (($this->force_download = strpos($_SERVER['REQUEST_URI'], '?download')) !== false)) |
|
631 | 631 | { |
632 | - $_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'],0,$this->force_download); |
|
632 | + $_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], 0, $this->force_download); |
|
633 | 633 | } |
634 | 634 | parent::__construct(); |
635 | 635 | } |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | */ |
645 | 645 | function GET(&$options) |
646 | 646 | { |
647 | - if (is_dir($this->base . $options["path"])) |
|
647 | + if (is_dir($this->base.$options["path"])) |
|
648 | 648 | { |
649 | 649 | return $this->autoindex($options); |
650 | 650 | } |
@@ -652,11 +652,11 @@ discard block |
||
652 | 652 | { |
653 | 653 | // mitigate risks of serving javascript or css from our domain |
654 | 654 | Api\Header\Content::safe($options['stream'], $options['path'], $options['mimetype'], $options['size'], false, |
655 | - $this->force_download, true); // true = do not send content-type and content-length header, but modify values |
|
655 | + $this->force_download, true); // true = do not send content-type and content-length header, but modify values |
|
656 | 656 | |
657 | 657 | if (!is_resource($options['stream'])) |
658 | 658 | { |
659 | - $options['data'] =& $options['stream']; |
|
659 | + $options['data'] = & $options['stream']; |
|
660 | 660 | unset($options['stream']); |
661 | 661 | } |
662 | 662 | } |
@@ -675,9 +675,9 @@ discard block |
||
675 | 675 | 'depth' => 1, |
676 | 676 | ); |
677 | 677 | $files = array(); |
678 | - if (($ret = $this->PROPFIND($propfind_options,$files)) !== true) |
|
678 | + if (($ret = $this->PROPFIND($propfind_options, $files)) !== true) |
|
679 | 679 | { |
680 | - return $ret; // no collection |
|
680 | + return $ret; // no collection |
|
681 | 681 | } |
682 | 682 | header('Content-type: text/html; charset='.Api\Translation::charset()); |
683 | 683 | echo "<html>\n<head>\n\t<title>".'EGroupware WebDAV server '.htmlspecialchars($options['path'])."</title>\n"; |
@@ -689,10 +689,10 @@ discard block |
||
689 | 689 | echo '<h1>WebDAV '; |
690 | 690 | list(,$base) = explode(parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH), $this->base_uri, 2); |
691 | 691 | $path = $base; |
692 | - foreach(explode('/',$this->_unslashify($options['path'])) as $n => $name) |
|
692 | + foreach (explode('/', $this->_unslashify($options['path'])) as $n => $name) |
|
693 | 693 | { |
694 | 694 | $path .= ($n != 1 ? '/' : '').$name; |
695 | - echo Api\Html::a_href(htmlspecialchars($name.'/'),$path); |
|
695 | + echo Api\Html::a_href(htmlspecialchars($name.'/'), $path); |
|
696 | 696 | } |
697 | 697 | echo "</h1>\n"; |
698 | 698 | |
@@ -709,18 +709,18 @@ discard block |
||
709 | 709 | ); |
710 | 710 | $n = 0; |
711 | 711 | $collection_props = null; |
712 | - foreach($files['files'] as $file) |
|
712 | + foreach ($files['files'] as $file) |
|
713 | 713 | { |
714 | 714 | if (!isset($collection_props)) |
715 | 715 | { |
716 | 716 | $collection_props = $this->props2array($file['props']); |
717 | 717 | echo '<h3>'.lang('Collection listing').': '.htmlspecialchars($collection_props['DAV:displayname'])."</h3>\n"; |
718 | - continue; // own entry --> displaying properies later |
|
718 | + continue; // own entry --> displaying properies later |
|
719 | 719 | } |
720 | - if(!$n++) |
|
720 | + if (!$n++) |
|
721 | 721 | { |
722 | 722 | echo "<table>\n\t<tr class='th'>\n\t\t<th>#</th>\n\t\t<th>".lang('Name')."</th>"; |
723 | - foreach($props2show as $label) |
|
723 | + foreach ($props2show as $label) |
|
724 | 724 | { |
725 | 725 | echo "\t\t<th>".lang($label)."</th>\n"; |
726 | 726 | } |
@@ -730,9 +730,9 @@ discard block |
||
730 | 730 | //echo $file['path']; _debug_array($props); |
731 | 731 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
732 | 732 | |
733 | - if (substr($file['path'],-1) == '/') |
|
733 | + if (substr($file['path'], -1) == '/') |
|
734 | 734 | { |
735 | - $name = basename(substr($file['path'],0,-1)).'/'; |
|
735 | + $name = basename(substr($file['path'], 0, -1)).'/'; |
|
736 | 736 | } |
737 | 737 | else |
738 | 738 | { |
@@ -740,14 +740,14 @@ discard block |
||
740 | 740 | } |
741 | 741 | |
742 | 742 | echo "\t<tr class='$class'>\n\t\t<td>$n</td>\n\t\t<td>". |
743 | - Api\Html::a_href(htmlspecialchars($name),$base.strtr($file['path'], array( |
|
743 | + Api\Html::a_href(htmlspecialchars($name), $base.strtr($file['path'], array( |
|
744 | 744 | '%' => '%25', |
745 | 745 | '#' => '%23', |
746 | 746 | '?' => '%3F', |
747 | 747 | )))."</td>\n"; |
748 | - foreach($props2show as $prop => $label) |
|
748 | + foreach ($props2show as $prop => $label) |
|
749 | 749 | { |
750 | - echo "\t\t<td>".($prop=='DAV:getlastmodified'&&!empty($props[$prop])?date('Y-m-d H:i:s',$props[$prop]):$props[$prop])."</td>\n"; |
|
750 | + echo "\t\t<td>".($prop == 'DAV:getlastmodified' && !empty($props[$prop]) ? date('Y-m-d H:i:s', $props[$prop]) : $props[$prop])."</td>\n"; |
|
751 | 751 | } |
752 | 752 | echo "\t</tr>\n"; |
753 | 753 | } |
@@ -761,12 +761,12 @@ discard block |
||
761 | 761 | } |
762 | 762 | echo '<h3>'.lang('Properties')."</h3>\n"; |
763 | 763 | echo "<table>\n\t<tr class='th'><th>".lang('Namespace')."</th><th>".lang('Name')."</th><th>".lang('Value')."</th></tr>\n"; |
764 | - foreach($collection_props as $name => $value) |
|
764 | + foreach ($collection_props as $name => $value) |
|
765 | 765 | { |
766 | 766 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
767 | - $parts = explode(':',$name); |
|
767 | + $parts = explode(':', $name); |
|
768 | 768 | $name = array_pop($parts); |
769 | - $ns = implode(':',$parts); |
|
769 | + $ns = implode(':', $parts); |
|
770 | 770 | echo "\t<tr class='$class'>\n\t\t<td>".htmlspecialchars($ns)."</td><td style='white-space: nowrap'>".htmlspecialchars($name)."</td>\n"; |
771 | 771 | echo "\t\t<td>".$value."</td>\n\t</tr>\n"; |
772 | 772 | } |
@@ -809,11 +809,11 @@ discard block |
||
809 | 809 | 'wrap' => 0, |
810 | 810 | )); |
811 | 811 | } |
812 | - if (($href=preg_match('/\<(D:)?href\>[^<]+\<\/(D:)?href\>/i',$value))) |
|
812 | + if (($href = preg_match('/\<(D:)?href\>[^<]+\<\/(D:)?href\>/i', $value))) |
|
813 | 813 | { |
814 | - $value = preg_replace('/\<(D:)?href\>('.preg_quote($this->base_uri.'/','/').')?([^<]+)\<\/(D:)?href\>/i','<\\1href><a href="\\2\\3">\\3</a></\\4href>',$value); |
|
814 | + $value = preg_replace('/\<(D:)?href\>('.preg_quote($this->base_uri.'/', '/').')?([^<]+)\<\/(D:)?href\>/i', '<\\1href><a href="\\2\\3">\\3</a></\\4href>', $value); |
|
815 | 815 | } |
816 | - $ret = $value[0] == '<' || strpos($value, "\n") !== false ? |
|
816 | + $ret = $value[0] == '<' || strpos($value, "\n") !== false ? |
|
817 | 817 | '<pre>'.htmlspecialchars($value).'</pre>' : htmlspecialchars($value); |
818 | 818 | |
819 | 819 | if ($href) |
@@ -833,10 +833,10 @@ discard block |
||
833 | 833 | protected function props2array(array $props) |
834 | 834 | { |
835 | 835 | $arr = array(); |
836 | - foreach($props as $prop) |
|
836 | + foreach ($props as $prop) |
|
837 | 837 | { |
838 | 838 | $ns_hash = array('DAV:' => 'D'); |
839 | - switch($prop['ns']) |
|
839 | + switch ($prop['ns']) |
|
840 | 840 | { |
841 | 841 | case 'DAV:'; |
842 | 842 | $ns = 'DAV'; |
@@ -846,10 +846,10 @@ discard block |
||
846 | 846 | } |
847 | 847 | if (is_array($prop['val'])) |
848 | 848 | { |
849 | - $prop['val'] = $this->_hierarchical_prop_encode($prop['val'], $prop['ns'], $ns_defs='', $ns_hash); |
|
849 | + $prop['val'] = $this->_hierarchical_prop_encode($prop['val'], $prop['ns'], $ns_defs = '', $ns_hash); |
|
850 | 850 | // hack to show real namespaces instead of not (visibly) defined shortcuts |
851 | 851 | unset($ns_hash['DAV:']); |
852 | - $value = strtr($v=$this->prop_value($prop['val']),array_flip($ns_hash)); |
|
852 | + $value = strtr($v = $this->prop_value($prop['val']), array_flip($ns_hash)); |
|
853 | 853 | } |
854 | 854 | else |
855 | 855 | { |
@@ -64,7 +64,8 @@ discard block |
||
64 | 64 | // special treatment for litmus compliance test |
65 | 65 | // reply on its identifier header |
66 | 66 | // not needed for the test itself but eases debugging |
67 | - if (isset($this->_SERVER['HTTP_X_LITMUS'])) { |
|
67 | + if (isset($this->_SERVER['HTTP_X_LITMUS'])) |
|
68 | + { |
|
68 | 69 | error_log("Litmus test ".$this->_SERVER['HTTP_X_LITMUS']); |
69 | 70 | header("X-Litmus-reply: ".$this->_SERVER['HTTP_X_LITMUS']); |
70 | 71 | } |
@@ -123,24 +124,30 @@ discard block |
||
123 | 124 | $path = $this->_unslashify($this->base .$options["path"]); |
124 | 125 | $parent = Vfs::dirname($path); |
125 | 126 | |
126 | - if (!file_exists($parent)) { |
|
127 | + if (!file_exists($parent)) |
|
128 | + { |
|
127 | 129 | return "409 Conflict"; |
128 | 130 | } |
129 | 131 | |
130 | - if (!is_dir($parent)) { |
|
132 | + if (!is_dir($parent)) |
|
133 | + { |
|
131 | 134 | return "403 Forbidden"; |
132 | 135 | } |
133 | 136 | |
134 | - if ( file_exists($path) ) { |
|
137 | + if ( file_exists($path) ) |
|
138 | + { |
|
135 | 139 | return "405 Method not allowed"; |
136 | 140 | } |
137 | 141 | |
138 | - if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
142 | + if (!empty($this->_SERVER["CONTENT_LENGTH"])) |
|
143 | + { |
|
144 | +// no body parsing yet |
|
139 | 145 | return "415 Unsupported media type"; |
140 | 146 | } |
141 | 147 | |
142 | 148 | $stat = mkdir($path, 0777); |
143 | - if (!$stat) { |
|
149 | + if (!$stat) |
|
150 | + { |
|
144 | 151 | return "403 Forbidden"; |
145 | 152 | } |
146 | 153 | |
@@ -157,24 +164,35 @@ discard block |
||
157 | 164 | { |
158 | 165 | // TODO Property updates still broken (Litmus should detect this?) |
159 | 166 | |
160 | - if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
167 | + if (!empty($this->_SERVER["CONTENT_LENGTH"])) |
|
168 | + { |
|
169 | +// no body parsing yet |
|
161 | 170 | return "415 Unsupported media type"; |
162 | 171 | } |
163 | 172 | |
164 | 173 | // no copying to different WebDAV Servers yet |
165 | - if (isset($options["dest_url"])) { |
|
174 | + if (isset($options["dest_url"])) |
|
175 | + { |
|
166 | 176 | return "502 bad gateway"; |
167 | 177 | } |
168 | 178 | |
169 | 179 | $source = $this->base .$options["path"]; |
170 | - if (!file_exists($source)) return "404 Not found"; |
|
180 | + if (!file_exists($source)) |
|
181 | + { |
|
182 | + return "404 Not found"; |
|
183 | + } |
|
171 | 184 | |
172 | - if (is_dir($source)) { // resource is a collection |
|
173 | - switch ($options["depth"]) { |
|
185 | + if (is_dir($source)) |
|
186 | + { |
|
187 | +// resource is a collection |
|
188 | + switch ($options["depth"]) |
|
189 | + { |
|
174 | 190 | case "infinity": // valid |
175 | 191 | break; |
176 | 192 | case "0": // valid for COPY only |
177 | - if ($del) { // MOVE? |
|
193 | + if ($del) |
|
194 | + { |
|
195 | +// MOVE? |
|
178 | 196 | return "400 Bad request"; |
179 | 197 | } |
180 | 198 | break; |
@@ -187,71 +205,99 @@ discard block |
||
187 | 205 | $dest = $this->base . $options["dest"]; |
188 | 206 | $destdir = dirname($dest); |
189 | 207 | |
190 | - if (!file_exists($destdir) || !is_dir($destdir)) { |
|
208 | + if (!file_exists($destdir) || !is_dir($destdir)) |
|
209 | + { |
|
191 | 210 | return "409 Conflict"; |
192 | 211 | } |
193 | 212 | |
194 | 213 | $new = !file_exists($dest); |
195 | 214 | $existing_col = false; |
196 | 215 | |
197 | - if (!$new) { |
|
198 | - if ($del && is_dir($dest)) { |
|
199 | - if (!$options["overwrite"]) { |
|
216 | + if (!$new) |
|
217 | + { |
|
218 | + if ($del && is_dir($dest)) |
|
219 | + { |
|
220 | + if (!$options["overwrite"]) |
|
221 | + { |
|
200 | 222 | return "412 precondition failed"; |
201 | 223 | } |
202 | 224 | $dest .= basename($source); |
203 | - if (file_exists($dest)) { |
|
225 | + if (file_exists($dest)) |
|
226 | + { |
|
204 | 227 | $options["dest"] .= basename($source); |
205 | - } else { |
|
228 | + } |
|
229 | + else |
|
230 | + { |
|
206 | 231 | $new = true; |
207 | 232 | $existing_col = true; |
208 | 233 | } |
209 | 234 | } |
210 | 235 | } |
211 | 236 | |
212 | - if (!$new) { |
|
213 | - if ($options["overwrite"]) { |
|
237 | + if (!$new) |
|
238 | + { |
|
239 | + if ($options["overwrite"]) |
|
240 | + { |
|
214 | 241 | $stat = $this->DELETE(array("path" => $options["dest"])); |
215 | - if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) { |
|
242 | + if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) |
|
243 | + { |
|
216 | 244 | return $stat; |
217 | 245 | } |
218 | - } else { |
|
246 | + } |
|
247 | + else |
|
248 | + { |
|
219 | 249 | return "412 precondition failed"; |
220 | 250 | } |
221 | 251 | } |
222 | 252 | |
223 | - if ($del) { |
|
224 | - if (!rename($source, $dest)) { |
|
253 | + if ($del) |
|
254 | + { |
|
255 | + if (!rename($source, $dest)) |
|
256 | + { |
|
225 | 257 | return "500 Internal server error"; |
226 | 258 | } |
227 | - } else { |
|
228 | - if (is_dir($source) && $options['depth'] == 'infinity') { |
|
259 | + } |
|
260 | + else |
|
261 | + { |
|
262 | + if (is_dir($source) && $options['depth'] == 'infinity') |
|
263 | + { |
|
229 | 264 | $files = Vfs::find($source,array('depth' => true,'url' => true)); // depth=true: return dirs first, url=true: allow urls! |
230 | - } else { |
|
265 | + } |
|
266 | + else |
|
267 | + { |
|
231 | 268 | $files = array($source); |
232 | 269 | } |
233 | 270 | |
234 | - if (!is_array($files) || empty($files)) { |
|
271 | + if (!is_array($files) || empty($files)) |
|
272 | + { |
|
235 | 273 | return "500 Internal server error"; |
236 | 274 | } |
237 | 275 | |
238 | 276 | |
239 | - foreach ($files as $file) { |
|
240 | - if (is_dir($file)) { |
|
277 | + foreach ($files as $file) |
|
278 | + { |
|
279 | + if (is_dir($file)) |
|
280 | + { |
|
241 | 281 | $file = $this->_slashify($file); |
242 | 282 | } |
243 | 283 | |
244 | 284 | $destfile = str_replace($source, $dest, $file); |
245 | 285 | |
246 | - if (is_dir($file)) { |
|
247 | - if (!is_dir($destfile)) { |
|
286 | + if (is_dir($file)) |
|
287 | + { |
|
288 | + if (!is_dir($destfile)) |
|
289 | + { |
|
248 | 290 | // TODO "mkdir -p" here? (only natively supported by PHP 5) |
249 | - if (!@mkdir($destfile)) { |
|
291 | + if (!@mkdir($destfile)) |
|
292 | + { |
|
250 | 293 | return "409 Conflict"; |
251 | 294 | } |
252 | 295 | } |
253 | - } else { |
|
254 | - if (!@copy($file, $destfile)) { |
|
296 | + } |
|
297 | + else |
|
298 | + { |
|
299 | + if (!@copy($file, $destfile)) |
|
300 | + { |
|
255 | 301 | return "409 Conflict"; |
256 | 302 | } |
257 | 303 | } |
@@ -301,17 +347,23 @@ discard block |
||
301 | 347 | $info["props"][] = self::mkprop("ishidden", Vfs::is_hidden($fspath)); |
302 | 348 | |
303 | 349 | // type and size (caller already made sure that path exists) |
304 | - if (is_dir($fspath)) { |
|
350 | + if (is_dir($fspath)) |
|
351 | + { |
|
305 | 352 | // directory (WebDAV collection) |
306 | 353 | $info['props'][] = self::mkprop ('resourcetype', array( |
307 | 354 | self::mkprop('collection', ''))); |
308 | 355 | $info['props'][] = self::mkprop ('getcontenttype', 'httpd/unix-directory'); |
309 | - } else { |
|
356 | + } |
|
357 | + else |
|
358 | + { |
|
310 | 359 | // plain file (WebDAV resource) |
311 | 360 | $info['props'][] = self::mkprop ('resourcetype', ''); |
312 | - if (Vfs::is_readable($path)) { |
|
361 | + if (Vfs::is_readable($path)) |
|
362 | + { |
|
313 | 363 | $info['props'][] = self::mkprop ('getcontenttype', Vfs::mime_content_type($path)); |
314 | - } else { |
|
364 | + } |
|
365 | + else |
|
366 | + { |
|
315 | 367 | error_log(__METHOD__."($path) $fspath is not readable!"); |
316 | 368 | $info['props'][] = self::mkprop ('getcontenttype', 'application/x-non-readable'); |
317 | 369 | } |
@@ -383,7 +435,10 @@ discard block |
||
383 | 435 | continue; |
384 | 436 | } |
385 | 437 | $_path = $info['path']; |
386 | - if (!$n && $info['path'] != '/' && substr($info['path'],-1) == '/') $_path = substr($info['path'],0,-1); |
|
438 | + if (!$n && $info['path'] != '/' && substr($info['path'],-1) == '/') |
|
439 | + { |
|
440 | + $_path = substr($info['path'],0,-1); |
|
441 | + } |
|
387 | 442 | |
388 | 443 | // need to encode path again, as $info['path'] is NOT encoded, but Vfs::(stat|propfind) require it |
389 | 444 | // otherwise pathes containing url special chars like ? or # will not stat |
@@ -422,16 +477,22 @@ discard block |
||
422 | 477 | $fileprops =& $files['files'][$path2n[$path]]['props']; |
423 | 478 | foreach($props as $prop) |
424 | 479 | { |
425 | - if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'][0] == '#') // eGW's customfields |
|
480 | + if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'][0] == '#') |
|
481 | + { |
|
482 | + // eGW's customfields |
|
426 | 483 | { |
427 | 484 | $prop['ns'] .= 'customfields/'; |
485 | + } |
|
428 | 486 | $prop['name'] = substr($prop['name'],1); |
429 | 487 | } |
430 | 488 | $fileprops[] = $prop; |
431 | 489 | } |
432 | 490 | } |
433 | 491 | } |
434 | - if ($this->debug) error_log(__METHOD__."() props=".array2string($files['files'])); |
|
492 | + if ($this->debug) |
|
493 | + { |
|
494 | + error_log(__METHOD__."() props=".array2string($files['files'])); |
|
495 | + } |
|
435 | 496 | return true; |
436 | 497 | } |
437 | 498 | |
@@ -483,7 +544,8 @@ discard block |
||
483 | 544 | { |
484 | 545 | $path = Api\Translation::convert($options['path'],'utf-8'); |
485 | 546 | |
486 | - foreach ($options['props'] as $key => $prop) { |
|
547 | + foreach ($options['props'] as $key => $prop) |
|
548 | + { |
|
487 | 549 | $attributes = array(); |
488 | 550 | switch($prop['ns']) |
489 | 551 | { |
@@ -500,7 +562,10 @@ discard block |
||
500 | 562 | //$attributes['created'] = strtotime($prop['val']); |
501 | 563 | //break; |
502 | 564 | default: |
503 | - if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
565 | + if (!Vfs::proppatch($path,array($prop))) |
|
566 | + { |
|
567 | + $options['props'][$key]['status'] = '403 Forbidden'; |
|
568 | + } |
|
504 | 569 | break; |
505 | 570 | } |
506 | 571 | break; |
@@ -529,7 +594,10 @@ discard block |
||
529 | 594 | case 'Win32LastAccessTime': |
530 | 595 | case 'Win32FileAttributes': // not sure what that is, it was always "00000000" |
531 | 596 | default: |
532 | - if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
597 | + if (!Vfs::proppatch($path,array($prop))) |
|
598 | + { |
|
599 | + $options['props'][$key]['status'] = '403 Forbidden'; |
|
600 | + } |
|
533 | 601 | break; |
534 | 602 | } |
535 | 603 | break; |
@@ -539,15 +607,24 @@ discard block |
||
539 | 607 | $prop['name'] = '#'.$prop['name']; |
540 | 608 | // fall through |
541 | 609 | default: |
542 | - if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
610 | + if (!Vfs::proppatch($path,array($prop))) |
|
611 | + { |
|
612 | + $options['props'][$key]['status'] = '403 Forbidden'; |
|
613 | + } |
|
543 | 614 | break; |
544 | 615 | } |
545 | - if ($this->debug) $props[] = '('.$prop['ns'].')'.$prop['name'].'='.$prop['val']; |
|
616 | + if ($this->debug) |
|
617 | + { |
|
618 | + $props[] = '('.$prop['ns'].')'.$prop['name'].'='.$prop['val']; |
|
619 | + } |
|
546 | 620 | } |
547 | 621 | if ($this->debug) |
548 | 622 | { |
549 | 623 | error_log(__METHOD__.": path=$options[path], props=".implode(', ',$props)); |
550 | - if ($attributes) error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n",' ',print_r($attributes,true))); |
|
624 | + if ($attributes) |
|
625 | + { |
|
626 | + error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n",' ',print_r($attributes,true))); |
|
627 | + } |
|
551 | 628 | } |
552 | 629 | |
553 | 630 | return ''; // this is as the filesystem example handler does it, no true or false ... |
@@ -561,7 +638,10 @@ discard block |
||
561 | 638 | */ |
562 | 639 | function LOCK(&$options) |
563 | 640 | { |
564 | - if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')'); |
|
641 | + if ($this->debug) |
|
642 | + { |
|
643 | + error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')'); |
|
644 | + } |
|
565 | 645 | // TODO recursive locks on directories not supported yet |
566 | 646 | if (is_dir($this->base . $options['path']) && !empty($options['depth'])) |
567 | 647 | { |
@@ -587,7 +667,10 @@ discard block |
||
587 | 667 | */ |
588 | 668 | function UNLOCK(&$options) |
589 | 669 | { |
590 | - if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')'); |
|
670 | + if ($this->debug) |
|
671 | + { |
|
672 | + error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')'); |
|
673 | + } |
|
591 | 674 | return Vfs::unlock($options['path'],$options['token']) ? '204 No Content' : '409 Conflict'; |
592 | 675 | } |
593 | 676 |