@@ -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 | { |
@@ -228,10 +228,10 @@ |
||
228 | 228 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
229 | 229 | * |
230 | 230 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
231 | - * { |
|
231 | + * { |
|
232 | 232 | * $eof = !$eof; |
233 | 233 | * } |
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 | 237 | 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 = $this->url_stat($url,0)) || $mode[0] == 'x') // file not found or file should NOT exist |
|
134 | + if (!($stat = $this->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=$this->url_stat($dir,0))) // or we are not allowed to create it |
|
139 | + !Vfs::check_access($dir, Vfs::WRITABLE, $dir_stat = $this->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 $this->url_stat($this->opened_stream_url,0); |
|
297 | + return $this->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 | - function unlink ( $url ) |
|
309 | + 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 | - function rename ( $url_from, $url_to ) |
|
334 | + 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 = $this->url_stat($url_from,0)) || !($dir = Vfs::dirname($url_from)) || !Vfs::check_access($dir,Vfs::WRITABLE)) |
|
340 | + if (!($from_stat = $this->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 = $this->url_stat($to_dir,0))) |
|
345 | + if (!($to_dir = Vfs::dirname($url_to)) || !Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = $this->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 = $this->url_stat($to['path'],0)) && |
|
357 | + if (($to_stat = $this->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 | - function mkdir ( $url, $mode, $options ) |
|
384 | + 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 | - function rmdir ( $url, $options ) |
|
418 | + 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) |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | { |
450 | 450 | if ($option != STREAM_META_TOUCH) |
451 | 451 | { |
452 | - return false; // not implemented / supported |
|
452 | + return false; // not implemented / supported |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | $path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)); |
@@ -473,13 +473,13 @@ discard block |
||
473 | 473 | * @param int $options |
474 | 474 | * @return booelan |
475 | 475 | */ |
476 | - function dir_opendir ( $url, $options ) |
|
476 | + function dir_opendir($url, $options) |
|
477 | 477 | { |
478 | 478 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options)"); |
479 | 479 | |
480 | 480 | $this->opened_dir = null; |
481 | 481 | |
482 | - $path = Vfs::decodePath(Vfs::parse_url($this->opened_dir_url = $url,PHP_URL_PATH)); |
|
482 | + $path = Vfs::decodePath(Vfs::parse_url($this->opened_dir_url = $url, PHP_URL_PATH)); |
|
483 | 483 | |
484 | 484 | // ToDo: check access rights |
485 | 485 | |
@@ -517,31 +517,31 @@ discard block |
||
517 | 517 | * stat triggers it's own warning anyway, so it makes no sense to trigger one by our stream-wrapper! |
518 | 518 | * @return array |
519 | 519 | */ |
520 | - function url_stat ( $url, $flags ) |
|
520 | + function url_stat($url, $flags) |
|
521 | 521 | { |
522 | 522 | $parts = Vfs::parse_url($url); |
523 | 523 | $path = Vfs::decodePath($parts['path']); |
524 | 524 | |
525 | - $stat = @stat($path); // suppressed the stat failed warnings |
|
525 | + $stat = @stat($path); // suppressed the stat failed warnings |
|
526 | 526 | |
527 | 527 | if ($stat) |
528 | 528 | { |
529 | 529 | // set owner, group and mode from mount options |
530 | 530 | $uid = $gid = $mode = null; |
531 | - if (!self::parse_query($parts['query'],$uid,$gid,$mode)) |
|
531 | + if (!self::parse_query($parts['query'], $uid, $gid, $mode)) |
|
532 | 532 | { |
533 | 533 | return false; |
534 | 534 | } |
535 | 535 | $stat['uid'] = $stat[4] = $uid; |
536 | 536 | $stat['gid'] = $stat[5] = $gid; |
537 | - $stat['mode'] = $stat[2] = $stat['mode'] & self::MODE_DIR ? self::MODE_DIR | $mode : self::MODE_FILE | ($mode & ~0111); |
|
537 | + $stat['mode'] = $stat[2] = $stat['mode']&self::MODE_DIR ? self::MODE_DIR|$mode : self::MODE_FILE|($mode&~0111); |
|
538 | 538 | // write rights also depend on the write rights of the webserver |
539 | 539 | if (!is_writable($path)) |
540 | 540 | { |
541 | - $stat['mode'] = $stat[2] = $stat['mode'] & ~0222; |
|
541 | + $stat['mode'] = $stat[2] = $stat['mode']&~0222; |
|
542 | 542 | } |
543 | 543 | } |
544 | - 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'])); |
|
544 | + 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'])); |
|
545 | 545 | return $stat; |
546 | 546 | } |
547 | 547 | |
@@ -555,13 +555,13 @@ discard block |
||
555 | 555 | * |
556 | 556 | * @return string |
557 | 557 | */ |
558 | - function dir_readdir ( ) |
|
558 | + function dir_readdir( ) |
|
559 | 559 | { |
560 | 560 | do { |
561 | 561 | $file = readdir($this->opened_dir); |
562 | 562 | |
563 | - $ignore = !($file === false || // stop if no more dirs or |
|
564 | - ($file != '.' && $file != '..' )); // file not . or .. |
|
563 | + $ignore = !($file === false || // stop if no more dirs or |
|
564 | + ($file != '.' && $file != '..')); // file not . or .. |
|
565 | 565 | if (self::LOG_LEVEL > 1 && $ignore) error_log(__METHOD__.'() ignoring '.array2string($file)); |
566 | 566 | } |
567 | 567 | while ($ignore); |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | * |
583 | 583 | * @return boolean |
584 | 584 | */ |
585 | - function dir_rewinddir ( ) |
|
585 | + function dir_rewinddir( ) |
|
586 | 586 | { |
587 | 587 | return rewinddir($this->opened_dir); |
588 | 588 | } |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | * |
595 | 595 | * @return boolean |
596 | 596 | */ |
597 | - function dir_closedir ( ) |
|
597 | + function dir_closedir( ) |
|
598 | 598 | { |
599 | 599 | closedir($this->opened_dir); |
600 | 600 | |
@@ -612,18 +612,18 @@ discard block |
||
612 | 612 | * @param int &$mode default if not set is 05 r-x for others |
613 | 613 | * @return boolean true on successfull parse, false on error |
614 | 614 | */ |
615 | - static function parse_query($query,&$uid,&$gid,&$mode) |
|
615 | + static function parse_query($query, &$uid, &$gid, &$mode) |
|
616 | 616 | { |
617 | 617 | $params = null; |
618 | - parse_str(is_array($query) ? $query['query'] : $query,$params); |
|
618 | + parse_str(is_array($query) ? $query['query'] : $query, $params); |
|
619 | 619 | |
620 | 620 | // setting the default perms root.root r-x for other |
621 | 621 | $uid = $gid = 0; |
622 | 622 | $mode = 05; |
623 | 623 | |
624 | - foreach($params as $name => $value) |
|
624 | + foreach ($params as $name => $value) |
|
625 | 625 | { |
626 | - switch($name) |
|
626 | + switch ($name) |
|
627 | 627 | { |
628 | 628 | case 'user': |
629 | 629 | if (!is_numeric($value)) |
@@ -632,10 +632,10 @@ discard block |
||
632 | 632 | { |
633 | 633 | $value = 0; |
634 | 634 | } |
635 | - elseif (($value = $GLOBALS['egw']->accounts->name2id($value,'account_lid','u')) === false) |
|
635 | + elseif (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'u')) === false) |
|
636 | 636 | { |
637 | 637 | error_log(__METHOD__."('$query') unknown user-name '$value'!"); |
638 | - return false; // wrong user-name |
|
638 | + return false; // wrong user-name |
|
639 | 639 | } |
640 | 640 | } |
641 | 641 | // fall-through |
@@ -654,12 +654,12 @@ discard block |
||
654 | 654 | { |
655 | 655 | $value = 0; |
656 | 656 | } |
657 | - elseif (($value = $GLOBALS['egw']->accounts->name2id($value,'account_lid','g')) === false) |
|
657 | + elseif (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'g')) === false) |
|
658 | 658 | { |
659 | 659 | error_log(__METHOD__."('$query') unknown group-name '$value'!"); |
660 | - return false; // wrong group-name |
|
660 | + return false; // wrong group-name |
|
661 | 661 | } |
662 | - $value = -$value; // vfs uses positiv gid's! |
|
662 | + $value = -$value; // vfs uses positiv gid's! |
|
663 | 663 | } |
664 | 664 | // fall-through |
665 | 665 | case 'gid': |
@@ -695,9 +695,9 @@ discard block |
||
695 | 695 | { |
696 | 696 | $parts = Vfs::parse_url($url); |
697 | 697 | $get = null; |
698 | - parse_str($parts['query'],$get); |
|
698 | + parse_str($parts['query'], $get); |
|
699 | 699 | |
700 | - $deny = !$get['exec'] && preg_match(self::SCRIPT_EXTENSIONS_PREG,$parts['path']); |
|
700 | + $deny = !$get['exec'] && preg_match(self::SCRIPT_EXTENSIONS_PREG, $parts['path']); |
|
701 | 701 | |
702 | 702 | if (self::LOG_LEVEL > 1 || self::LOG_LEVEL > 0 && $deny) |
703 | 703 | { |
@@ -717,21 +717,21 @@ discard block |
||
717 | 717 | * @todo get $force_download working through webdav |
718 | 718 | * @return string|false string with full download url or false to use default webdav.php url |
719 | 719 | */ |
720 | - static function download_url($_url,$force_download=false) |
|
720 | + static function download_url($_url, $force_download = false) |
|
721 | 721 | { |
722 | - unset($force_download); // not used, but required by interface |
|
722 | + unset($force_download); // not used, but required by interface |
|
723 | 723 | |
724 | - list($url,$query) = explode('?',$_url,2); |
|
724 | + list($url, $query) = explode('?', $_url, 2); |
|
725 | 725 | $get = null; |
726 | - parse_str($query,$get); |
|
727 | - if (empty($get['url'])) return false; // no download url given for this mount-point |
|
726 | + parse_str($query, $get); |
|
727 | + if (empty($get['url'])) return false; // no download url given for this mount-point |
|
728 | 728 | |
729 | - if (!($mount_url = Vfs::mount_url($_url))) return false; // no mount url found, should not happen |
|
730 | - list($mount_url) = explode('?',$mount_url); |
|
729 | + if (!($mount_url = Vfs::mount_url($_url))) return false; // no mount url found, should not happen |
|
730 | + list($mount_url) = explode('?', $mount_url); |
|
731 | 731 | |
732 | - $relpath = substr($url,strlen($mount_url)); |
|
732 | + $relpath = substr($url, strlen($mount_url)); |
|
733 | 733 | |
734 | - $download_url = Vfs::concat($get['url'],$relpath); |
|
734 | + $download_url = Vfs::concat($get['url'], $relpath); |
|
735 | 735 | if ($download_url[0] == '/') |
736 | 736 | { |
737 | 737 | $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 = $this->url_stat($url,0)) || $mode[0] == 'x') // file not found or file should NOT exist |
|
134 | + if (!($stat = $this->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=$this->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 = $this->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 = $this->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); |
@@ -448,7 +484,7 @@ discard block |
||
448 | 484 | function stream_metadata($url, $option, $value) |
449 | 485 | { |
450 | 486 | if ($option != STREAM_META_TOUCH) |
451 | - { |
|
487 | + { |
|
452 | 488 | return false; // not implemented / supported |
453 | 489 | } |
454 | 490 | |
@@ -458,7 +494,10 @@ discard block |
||
458 | 494 | // check access rights (in real filesystem AND by mount perms) |
459 | 495 | if (!file_exists($path) || !is_writable($parent) || !($dir = Vfs::dirname($url)) || !Vfs::check_access($dir, Vfs::WRITABLE)) |
460 | 496 | { |
461 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
|
497 | + if (self::LOG_LEVEL) |
|
498 | + { |
|
499 | + error_log(__METHOD__."($url) permission denied!"); |
|
500 | + } |
|
462 | 501 | return false; |
463 | 502 | } |
464 | 503 | |
@@ -475,7 +514,10 @@ discard block |
||
475 | 514 | */ |
476 | 515 | function dir_opendir ( $url, $options ) |
477 | 516 | { |
478 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options)"); |
|
517 | + if (self::LOG_LEVEL > 1) |
|
518 | + { |
|
519 | + error_log(__METHOD__."($url,$options)"); |
|
520 | + } |
|
479 | 521 | |
480 | 522 | $this->opened_dir = null; |
481 | 523 | |
@@ -485,7 +527,10 @@ discard block |
||
485 | 527 | |
486 | 528 | if (!($this->opened_dir = opendir($path))) |
487 | 529 | { |
488 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."($url,$options) opendir('$path') failed!"); |
|
530 | + if (self::LOG_LEVEL > 0) |
|
531 | + { |
|
532 | + error_log(__METHOD__."($url,$options) opendir('$path') failed!"); |
|
533 | + } |
|
489 | 534 | return false; |
490 | 535 | } |
491 | 536 | return true; |
@@ -541,7 +586,10 @@ discard block |
||
541 | 586 | $stat['mode'] = $stat[2] = $stat['mode'] & ~0222; |
542 | 587 | } |
543 | 588 | } |
544 | - 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'])); |
|
589 | + if (self::LOG_LEVEL > 1) |
|
590 | + { |
|
591 | + error_log(__METHOD__."($url,$flags) path=$path, mount_mode=".sprintf('0%o',$mode).", mode=".sprintf('0%o',$stat['mode']).'='.Vfs::int2mode($stat['mode'])); |
|
592 | + } |
|
545 | 593 | return $stat; |
546 | 594 | } |
547 | 595 | |
@@ -562,14 +610,23 @@ discard block |
||
562 | 610 | |
563 | 611 | $ignore = !($file === false || // stop if no more dirs or |
564 | 612 | ($file != '.' && $file != '..' )); // file not . or .. |
565 | - if (self::LOG_LEVEL > 1 && $ignore) error_log(__METHOD__.'() ignoring '.array2string($file)); |
|
613 | + if (self::LOG_LEVEL > 1 && $ignore) |
|
614 | + { |
|
615 | + error_log(__METHOD__.'() ignoring '.array2string($file)); |
|
616 | + } |
|
566 | 617 | } |
567 | 618 | while ($ignore); |
568 | 619 | |
569 | 620 | // encode special chars messing up url's |
570 | - if ($file !== false) $file = Vfs::encodePathComponent($file); |
|
621 | + if ($file !== false) |
|
622 | + { |
|
623 | + $file = Vfs::encodePathComponent($file); |
|
624 | + } |
|
571 | 625 | |
572 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'() returning '.array2string($file)); |
|
626 | + if (self::LOG_LEVEL > 1) |
|
627 | + { |
|
628 | + error_log(__METHOD__.'() returning '.array2string($file)); |
|
629 | + } |
|
573 | 630 | |
574 | 631 | return $file; |
575 | 632 | } |
@@ -724,9 +781,17 @@ discard block |
||
724 | 781 | list($url,$query) = explode('?',$_url,2); |
725 | 782 | $get = null; |
726 | 783 | parse_str($query,$get); |
727 | - if (empty($get['url'])) return false; // no download url given for this mount-point |
|
784 | + if (empty($get['url'])) |
|
785 | + { |
|
786 | + return false; |
|
787 | + } |
|
788 | + // no download url given for this mount-point |
|
728 | 789 | |
729 | - if (!($mount_url = Vfs::mount_url($_url))) return false; // no mount url found, should not happen |
|
790 | + if (!($mount_url = Vfs::mount_url($_url))) |
|
791 | + { |
|
792 | + return false; |
|
793 | + } |
|
794 | + // no mount url found, should not happen |
|
730 | 795 | list($mount_url) = explode('?',$mount_url); |
731 | 796 | |
732 | 797 | $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 | { |
@@ -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,(int)$data['account_id']); |
|
51 | - Api\Vfs::chgrp($dir,0); |
|
52 | - Api\Vfs::chmod($dir,0700); // only user has access |
|
50 | + Api\Vfs::chown($dir, (int)$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 | 99 | Api\Vfs::find($new_dir, array(), 'EGroupware\Api\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 | } |
@@ -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::file_exists($dir='/home/'.$data['account_lid']) || Api\Vfs::mkdir($dir, 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 | { |
@@ -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,20 +246,31 @@ 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)) |
|
248 | 259 | { |
249 | - $current_is_root = Vfs::$is_root; Vfs::$is_root = true; |
|
260 | + // app directory itself is allways ok |
|
261 | + { |
|
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 | $sqlfs = new parent(); |
253 | 268 | $ret = $sqlfs->mkdir($path,0,$options|STREAM_MKDIR_RECURSIVE); |
254 | - if ($id) $sqlfs->chmod($path,0); // no other rights |
|
269 | + if ($id) |
|
270 | + { |
|
271 | + $sqlfs->chmod($path,0); |
|
272 | + } |
|
273 | + // no other rights |
|
255 | 274 | |
256 | 275 | Vfs::$user = $current_user; |
257 | 276 | Vfs::$is_root = $current_is_root; |
@@ -339,10 +358,13 @@ discard block |
||
339 | 358 | */ |
340 | 359 | protected function touch($url,$time=null,$atime=null) |
341 | 360 | { |
342 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$time,$atime)"); |
|
361 | + if (self::LOG_LEVEL > 1) |
|
362 | + { |
|
363 | + error_log(__METHOD__."($url,$time,$atime)"); |
|
364 | + } |
|
343 | 365 | |
344 | 366 | if (!($stat = $this->url_stat($url,STREAM_URL_STAT_QUIET))) |
345 | - { |
|
367 | + { |
|
346 | 368 | // file does not exist --> create an empty one |
347 | 369 | if (!($f = fopen(self::SCHEME.'://default'.Vfs::parse_url($url,PHP_URL_PATH),'w')) || !fclose($f)) |
348 | 370 | { |
@@ -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 | - function url_stat ( $url, $flags ) |
|
140 | + 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,26 +232,26 @@ 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 | - function mkdir($path,$mode,$options) |
|
235 | + 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 | 252 | $sqlfs = new parent(); |
253 | - $ret = $sqlfs->mkdir($path,0,$options|STREAM_MKDIR_RECURSIVE); |
|
254 | - if ($id) $sqlfs->chmod($path,0); // no other rights |
|
253 | + $ret = $sqlfs->mkdir($path, 0, $options|STREAM_MKDIR_RECURSIVE); |
|
254 | + if ($id) $sqlfs->chmod($path, 0); // no other rights |
|
255 | 255 | |
256 | 256 | Vfs::$user = $current_user; |
257 | 257 | Vfs::$is_root = $current_is_root; |
@@ -275,23 +275,23 @@ discard block |
||
275 | 275 | * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set |
276 | 276 | * @return boolean true if the ressource was opened successful, otherwise false |
277 | 277 | */ |
278 | - function stream_open ( $url, $mode, $options, &$opened_path ) |
|
278 | + function stream_open($url, $mode, $options, &$opened_path) |
|
279 | 279 | { |
280 | 280 | // the following call is necessary to fill sqlfs_stream_wrapper::$stat_cache, WITH the extendes ACL! |
281 | - $stat = $this->url_stat($url,0); |
|
281 | + $stat = $this->url_stat($url, 0); |
|
282 | 282 | //error_log(__METHOD__."('$url', '$mode', $options) stat=".array2string($stat)); |
283 | 283 | |
284 | 284 | // return vCard as /.entry |
285 | - if ($stat && $mode[0] == 'r' && substr($url,-7) === '/.entry' && |
|
286 | - (list($app) = array_slice(explode('/',$url),-3,1)) && $app === 'addressbook') |
|
285 | + if ($stat && $mode[0] == 'r' && substr($url, -7) === '/.entry' && |
|
286 | + (list($app) = array_slice(explode('/', $url), -3, 1)) && $app === 'addressbook') |
|
287 | 287 | { |
288 | - list($id) = array_slice(explode('/',$url),-2,1); |
|
289 | - $ab_vcard = new addressbook_vcal('addressbook','text/vcard'); |
|
288 | + list($id) = array_slice(explode('/', $url), -2, 1); |
|
289 | + $ab_vcard = new addressbook_vcal('addressbook', 'text/vcard'); |
|
290 | 290 | if (!($charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'])) |
291 | 291 | { |
292 | 292 | $charset = 'utf-8'; |
293 | 293 | } |
294 | - if (!($vcard =& $ab_vcard->getVCard($id, $charset))) |
|
294 | + if (!($vcard = & $ab_vcard->getVCard($id, $charset))) |
|
295 | 295 | { |
296 | 296 | error_log(__METHOD__."('$url', '$mode', $options) addressbook_vcal::getVCard($id) returned false!"); |
297 | 297 | return false; |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | if ($mode[0] != 'r' && ($dir = Vfs::dirname($url)) && |
307 | 307 | !parent::url_stat($dir, 0) && self::check_extended_acl($dir, Vfs::WRITABLE)) |
308 | 308 | { |
309 | - $this->mkdir($dir,0,STREAM_MKDIR_RECURSIVE); |
|
309 | + $this->mkdir($dir, 0, STREAM_MKDIR_RECURSIVE); |
|
310 | 310 | } |
311 | - return parent::stream_open($url,$mode,$options,$opened_path); |
|
311 | + return parent::stream_open($url, $mode, $options, $opened_path); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * @param $options |
321 | 321 | * @return booelan |
322 | 322 | */ |
323 | - function dir_opendir ( $url, $options ) |
|
323 | + function dir_opendir($url, $options) |
|
324 | 324 | { |
325 | 325 | if (!parent::url_stat($url, STREAM_URL_STAT_QUIET) && $this->url_stat($url, STREAM_URL_STAT_QUIET)) |
326 | 326 | { |
@@ -337,20 +337,20 @@ discard block |
||
337 | 337 | * @param int $time =null modification time (unix timestamp), default null = current time |
338 | 338 | * @param int $atime =null access time (unix timestamp), default null = current time, not implemented in the vfs! |
339 | 339 | */ |
340 | - protected function touch($url,$time=null,$atime=null) |
|
340 | + protected function touch($url, $time = null, $atime = null) |
|
341 | 341 | { |
342 | 342 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$time,$atime)"); |
343 | 343 | |
344 | - if (!($stat = $this->url_stat($url,STREAM_URL_STAT_QUIET))) |
|
344 | + if (!($stat = $this->url_stat($url, STREAM_URL_STAT_QUIET))) |
|
345 | 345 | { |
346 | 346 | // file does not exist --> create an empty one |
347 | - if (!($f = fopen(self::SCHEME.'://default'.Vfs::parse_url($url,PHP_URL_PATH),'w')) || !fclose($f)) |
|
347 | + if (!($f = fopen(self::SCHEME.'://default'.Vfs::parse_url($url, PHP_URL_PATH), 'w')) || !fclose($f)) |
|
348 | 348 | { |
349 | 349 | return false; |
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
353 | - return is_null($time) ? true : parent::touch($url,$time,$atime); |
|
353 | + return is_null($time) ? true : parent::touch($url, $time, $atime); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -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','EGroupware\\Api\\Vfs\\Sharing::tmp_cleanup',null); |
|
490 | + $async->set_timer(array('day' => 28), 'egw_sharing-tmp_cleanup', 'EGroupware\\Api\\Vfs\\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 MAX(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 | - 'MAX(share_expires) IS NULL AND MAX(share_created) < '.self::$db->quote(self::$db->to_timestamp(time()-self::TMP_KEEP)). ' AND '. |
|
609 | + 'MAX(share_expires) IS NULL AND MAX(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 | - '(MAX(share_last_accessed) IS NULL OR MAX(share_last_accessed) < '.self::$db->quote(self::$db->to_timestamp(time()-self::TMP_KEEP)).')'; |
|
611 | + '(MAX(share_last_accessed) IS NULL OR MAX(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 MAX(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 | { |
@@ -165,7 +165,10 @@ discard block |
||
165 | 165 | { |
166 | 166 | $url = null; |
167 | 167 | $stat = self::check_symlink_components($path,0,$url); |
168 | - if (self::LOG_LEVEL > 1) $log = " (check_symlink_components('$path',0,'$url') = $stat)"; |
|
168 | + if (self::LOG_LEVEL > 1) |
|
169 | + { |
|
170 | + $log = " (check_symlink_components('$path',0,'$url') = $stat)"; |
|
171 | + } |
|
169 | 172 | } |
170 | 173 | else |
171 | 174 | { |
@@ -176,7 +179,10 @@ discard block |
||
176 | 179 | { |
177 | 180 | $url = self::resolve_url(Vfs::parse_url($url,PHP_URL_PATH)); |
178 | 181 | } |
179 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,file_exists=$file_exists,resolve_last_symlink=$resolve_last_symlink) = '$url'$log"); |
|
182 | + if (self::LOG_LEVEL > 1) |
|
183 | + { |
|
184 | + error_log(__METHOD__."($path,file_exists=$file_exists,resolve_last_symlink=$resolve_last_symlink) = '$url'$log"); |
|
185 | + } |
|
180 | 186 | return $url; |
181 | 187 | } |
182 | 188 | |
@@ -204,7 +210,10 @@ discard block |
||
204 | 210 | // we do some caching here |
205 | 211 | if (isset(self::$resolve_url_cache[$path]) && $replace_user_pass_host) |
206 | 212 | { |
207 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '".self::$resolve_url_cache[$path]."' (from cache)"); |
|
213 | + if (self::LOG_LEVEL > 1) |
|
214 | + { |
|
215 | + error_log(__METHOD__."('$path') = '".self::$resolve_url_cache[$path]."' (from cache)"); |
|
216 | + } |
|
208 | 217 | return self::$resolve_url_cache[$path]; |
209 | 218 | } |
210 | 219 | // check if we can already resolve path (or a part of it) with a known symlinks |
@@ -224,14 +233,24 @@ discard block |
||
224 | 233 | ); |
225 | 234 | } |
226 | 235 | $parts = array_merge(Vfs::parse_url($path),$defaults); |
227 | - if (!$parts['host']) $parts['host'] = 'default'; // otherwise we get an invalid url (scheme:///path/to/something)! |
|
236 | + if (!$parts['host']) |
|
237 | + { |
|
238 | + $parts['host'] = 'default'; |
|
239 | + } |
|
240 | + // otherwise we get an invalid url (scheme:///path/to/something)! |
|
228 | 241 | |
229 | 242 | if (!empty($parts['scheme']) && $parts['scheme'] != self::SCHEME) |
230 | 243 | { |
231 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$path' (path is already an url)"); |
|
244 | + if (self::LOG_LEVEL > 1) |
|
245 | + { |
|
246 | + error_log(__METHOD__."('$path') = '$path' (path is already an url)"); |
|
247 | + } |
|
232 | 248 | return $path; // path is already a non-vfs url --> nothing to do |
233 | 249 | } |
234 | - if (empty($parts['path'])) $parts['path'] = '/'; |
|
250 | + if (empty($parts['path'])) |
|
251 | + { |
|
252 | + $parts['path'] = '/'; |
|
253 | + } |
|
235 | 254 | |
236 | 255 | foreach(array_reverse(self::$fstab) as $mounted => $url) |
237 | 256 | { |
@@ -257,17 +276,32 @@ discard block |
||
257 | 276 | { |
258 | 277 | $url = str_replace(array('$user','$pass','$host','$home'),array($parts['user'],$parts['pass'],$parts['host'],$parts['home']),$url); |
259 | 278 | } |
260 | - if ($parts['query']) $url .= '?'.$parts['query']; |
|
261 | - if ($parts['fragment']) $url .= '#'.$parts['fragment']; |
|
279 | + if ($parts['query']) |
|
280 | + { |
|
281 | + $url .= '?'.$parts['query']; |
|
282 | + } |
|
283 | + if ($parts['fragment']) |
|
284 | + { |
|
285 | + $url .= '#'.$parts['fragment']; |
|
286 | + } |
|
262 | 287 | |
263 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$url'"); |
|
288 | + if (self::LOG_LEVEL > 1) |
|
289 | + { |
|
290 | + error_log(__METHOD__."('$path') = '$url'"); |
|
291 | + } |
|
264 | 292 | |
265 | - if ($replace_user_pass_host) self::$resolve_url_cache[$path] = $url; |
|
293 | + if ($replace_user_pass_host) |
|
294 | + { |
|
295 | + self::$resolve_url_cache[$path] = $url; |
|
296 | + } |
|
266 | 297 | |
267 | 298 | return $url; |
268 | 299 | } |
269 | 300 | } |
270 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path') can't resolve path!\n"); |
|
301 | + if (self::LOG_LEVEL > 0) |
|
302 | + { |
|
303 | + error_log(__METHOD__."('$path') can't resolve path!\n"); |
|
304 | + } |
|
271 | 305 | trigger_error(__METHOD__."($path) can't resolve path!\n",E_USER_WARNING); |
272 | 306 | return false; |
273 | 307 | } |
@@ -488,15 +522,21 @@ discard block |
||
488 | 522 | */ |
489 | 523 | function stream_metadata($path, $option, $value) |
490 | 524 | { |
491 | - if (!($url = $this->resolve_url_symlinks($path, $option != STREAM_META_TOUCH, false))) // true,false file need to exist, but do not resolve last component |
|
525 | + if (!($url = $this->resolve_url_symlinks($path, $option != STREAM_META_TOUCH, false))) |
|
526 | + { |
|
527 | + // true,false file need to exist, but do not resolve last component |
|
492 | 528 | { |
493 | 529 | return false; |
494 | 530 | } |
531 | + } |
|
495 | 532 | if (self::url_is_readonly($url)) |
496 | 533 | { |
497 | 534 | return false; |
498 | 535 | } |
499 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path', $option, ".array2string($value).") url=$url"); |
|
536 | + if (self::LOG_LEVEL > 1) |
|
537 | + { |
|
538 | + error_log(__METHOD__."('$path', $option, ".array2string($value).") url=$url"); |
|
539 | + } |
|
500 | 540 | |
501 | 541 | switch($option) |
502 | 542 | { |
@@ -508,14 +548,18 @@ discard block |
||
508 | 548 | |
509 | 549 | case STREAM_META_OWNER_NAME: |
510 | 550 | if (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'u')) === false) |
511 | - return false; |
|
551 | + { |
|
552 | + return false; |
|
553 | + } |
|
512 | 554 | // fall through |
513 | 555 | case STREAM_META_OWNER: |
514 | 556 | return chown($url, $value); |
515 | 557 | |
516 | 558 | case STREAM_META_GROUP_NAME: |
517 | 559 | if (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'g')) === false) |
518 | - return false; |
|
560 | + { |
|
561 | + return false; |
|
562 | + } |
|
519 | 563 | // fall through |
520 | 564 | case STREAM_META_GROUP: |
521 | 565 | return chgrp($url, $value); |
@@ -534,10 +578,13 @@ discard block |
||
534 | 578 | */ |
535 | 579 | function unlink ( $path ) |
536 | 580 | { |
537 | - if (!($url = $this->resolve_url_symlinks($path,true,false))) // true,false file need to exist, but do not resolve last component |
|
581 | + if (!($url = $this->resolve_url_symlinks($path,true,false))) |
|
582 | + { |
|
583 | + // true,false file need to exist, but do not resolve last component |
|
538 | 584 | { |
539 | 585 | return false; |
540 | 586 | } |
587 | + } |
|
541 | 588 | if (self::url_is_readonly($url)) |
542 | 589 | { |
543 | 590 | return false; |
@@ -590,7 +637,10 @@ discard block |
||
590 | 637 | $ret = stream_copy_to_stream($from,$to) !== false; |
591 | 638 | fclose($from); |
592 | 639 | fclose($to); |
593 | - if ($ret) $this->unlink($path_from); |
|
640 | + if ($ret) |
|
641 | + { |
|
642 | + $this->unlink($path_from); |
|
643 | + } |
|
594 | 644 | } |
595 | 645 | else |
596 | 646 | { |
@@ -627,17 +677,23 @@ discard block |
||
627 | 677 | */ |
628 | 678 | function mkdir ( $path, $mode, $options ) |
629 | 679 | { |
630 | - if (!($url = $this->resolve_url_symlinks($path,false))) // false = directory does not need to exists |
|
680 | + if (!($url = $this->resolve_url_symlinks($path,false))) |
|
681 | + { |
|
682 | + // false = directory does not need to exists |
|
631 | 683 | { |
632 | 684 | return false; |
633 | 685 | } |
686 | + } |
|
634 | 687 | // check if recursive option is set and needed |
635 | 688 | if (($options & STREAM_MKDIR_RECURSIVE) && |
636 | 689 | ($parent_url = Vfs::dirname($url)) && |
637 | 690 | !($this->url_stat($parent_url, STREAM_URL_STAT_QUIET)) && |
638 | 691 | Vfs::parse_url($parent_url, PHP_URL_PATH) !== '/') |
639 | 692 | { |
640 | - if (!mkdir($parent_url, $mode, $options)) return false; |
|
693 | + if (!mkdir($parent_url, $mode, $options)) |
|
694 | + { |
|
695 | + return false; |
|
696 | + } |
|
641 | 697 | } |
642 | 698 | // unset it now, as it was handled above |
643 | 699 | $options &= ~STREAM_MKDIR_RECURSIVE; |
@@ -709,13 +765,19 @@ discard block |
||
709 | 765 | |
710 | 766 | if (!($this->opened_dir_url = $this->resolve_url_symlinks($path))) |
711 | 767 | { |
712 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) resolve_url_symlinks() failed!"); |
|
768 | + if (self::LOG_LEVEL > 0) |
|
769 | + { |
|
770 | + error_log(__METHOD__."( $path,$options) resolve_url_symlinks() failed!"); |
|
771 | + } |
|
713 | 772 | return false; |
714 | 773 | } |
715 | 774 | if (!($this->opened_dir = $this->context ? |
716 | 775 | opendir($this->opened_dir_url, $this->context) : opendir($this->opened_dir_url))) |
717 | 776 | { |
718 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!"); |
|
777 | + if (self::LOG_LEVEL > 0) |
|
778 | + { |
|
779 | + error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!"); |
|
780 | + } |
|
719 | 781 | return false; |
720 | 782 | } |
721 | 783 | $this->opened_dir_writable = Vfs::check_access($this->opened_dir_url,Vfs::WRITABLE); |
@@ -733,7 +795,10 @@ discard block |
||
733 | 795 | } |
734 | 796 | |
735 | 797 | |
736 | - 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()); |
|
798 | + if (self::LOG_LEVEL > 1) |
|
799 | + { |
|
800 | + error_log(__METHOD__."( $path,$options): opendir($this->opened_dir_url)=$this->opened_dir, extra_dirs=".array2string($this->extra_dirs).', '.function_backtrace()); |
|
801 | + } |
|
737 | 802 | return true; |
738 | 803 | } |
739 | 804 | |
@@ -769,7 +834,10 @@ discard block |
||
769 | 834 | { |
770 | 835 | if (!($url = self::resolve_url($path,!($flags & STREAM_URL_STAT_LINK), $check_symlink_components))) |
771 | 836 | { |
772 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) can NOT resolve path!"); |
|
837 | + if (self::LOG_LEVEL > 0) |
|
838 | + { |
|
839 | + error_log(__METHOD__."('$path',$flags) can NOT resolve path!"); |
|
840 | + } |
|
773 | 841 | return false; |
774 | 842 | } |
775 | 843 | |
@@ -786,18 +854,27 @@ discard block |
||
786 | 854 | { |
787 | 855 | if (!$check_symlink_depth) |
788 | 856 | { |
789 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) maximum symlink depth exceeded, might be a circular symlink!"); |
|
857 | + if (self::LOG_LEVEL > 0) |
|
858 | + { |
|
859 | + error_log(__METHOD__."('$path',$flags) maximum symlink depth exceeded, might be a circular symlink!"); |
|
860 | + } |
|
790 | 861 | $stat = false; |
791 | 862 | } |
792 | 863 | elseif (($lpath = Vfs::readlink($url))) |
793 | 864 | { |
794 | - if ($lpath[0] != '/') // concat relative path |
|
865 | + if ($lpath[0] != '/') |
|
866 | + { |
|
867 | + // concat relative path |
|
795 | 868 | { |
796 | 869 | $lpath = Vfs::concat(Vfs::parse_url($path,PHP_URL_PATH),'../'.$lpath); |
797 | 870 | } |
871 | + } |
|
798 | 872 | $u_query = parse_url($url,PHP_URL_QUERY); |
799 | 873 | $url = Vfs::PREFIX.$lpath; |
800 | - 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"); |
|
874 | + if (self::LOG_LEVEL > 1) |
|
875 | + { |
|
876 | + 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"); |
|
877 | + } |
|
801 | 878 | // try reading the stat of the link |
802 | 879 | if (($stat = $this->url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth-1))) |
803 | 880 | { |
@@ -810,7 +887,11 @@ discard block |
||
810 | 887 | $stat_query = http_build_query(array_merge($stat_query, $u_query)); |
811 | 888 | $stat['url'] = $stat_url['scheme'].'://'.$stat_url['host'].$stat_url['path'].'?'.$stat_query; |
812 | 889 | } |
813 | - if(isset($stat['url'])) $url = $stat['url']; // if stat returns an url use that, as there might be more links ... |
|
890 | + if(isset($stat['url'])) |
|
891 | + { |
|
892 | + $url = $stat['url']; |
|
893 | + } |
|
894 | + // if stat returns an url use that, as there might be more links ... |
|
814 | 895 | self::symlinkCache_add($path,$url); |
815 | 896 | } |
816 | 897 | } |
@@ -833,7 +914,9 @@ discard block |
||
833 | 914 | // check if a failed url_stat was for a home dir, in that case silently create it |
834 | 915 | if (!$stat && $try_create_home && Vfs::dirname(Vfs::parse_url($path,PHP_URL_PATH)) == '/home' && |
835 | 916 | ($id = $GLOBALS['egw']->accounts->name2id(basename($path))) && |
836 | - $GLOBALS['egw']->accounts->id2name($id) == basename($path)) // make sure path has the right case! |
|
917 | + $GLOBALS['egw']->accounts->id2name($id) == basename($path)) |
|
918 | + { |
|
919 | + // make sure path has the right case! |
|
837 | 920 | { |
838 | 921 | $hook_data = array( |
839 | 922 | 'location' => $GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'addgroup' : 'addaccount', |
@@ -841,15 +924,22 @@ discard block |
||
841 | 924 | 'account_lid' => basename($path), |
842 | 925 | 'account_name' => basename($path), |
843 | 926 | ); |
927 | + } |
|
844 | 928 | call_user_func(array(__NAMESPACE__.'\\Hooks',$hook_data['location']),$hook_data); |
845 | 929 | unset($hook_data); |
846 | 930 | $stat = $this->url_stat($path,$flags,false); |
847 | 931 | } |
848 | 932 | $query = parse_url($url, PHP_URL_QUERY); |
849 | - if (!$stat && $check_symlink_components) // check if there's a symlink somewhere inbetween the path |
|
933 | + if (!$stat && $check_symlink_components) |
|
934 | + { |
|
935 | + // check if there's a symlink somewhere inbetween the path |
|
850 | 936 | { |
851 | 937 | $stat = self::check_symlink_components($path,$flags,$url); |
852 | - if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path,$stat['url']); |
|
938 | + } |
|
939 | + if ($stat && isset($stat['url']) && !$query) |
|
940 | + { |
|
941 | + self::symlinkCache_add($path,$stat['url']); |
|
942 | + } |
|
853 | 943 | } |
854 | 944 | elseif(is_array($stat) && !isset($stat['url'])) |
855 | 945 | { |
@@ -864,7 +954,10 @@ discard block |
||
864 | 954 | $stat['url'] .= '?'.$query; |
865 | 955 | } |
866 | 956 | |
867 | - 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)); |
|
957 | + if (self::LOG_LEVEL > 1) |
|
958 | + { |
|
959 | + error_log(__METHOD__."('$path',$flags,try_create_home=$try_create_home,check_symlink_components=$check_symlink_components) returning ".array2string($stat)); |
|
960 | + } |
|
868 | 961 | |
869 | 962 | return $stat; |
870 | 963 | |
@@ -890,10 +983,16 @@ discard block |
||
890 | 983 | { |
891 | 984 | if (is_null($url) && !($url = self::resolve_url($path))) |
892 | 985 | { |
893 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags,'$url') can NOT resolve path: ".function_backtrace(1)); |
|
986 | + if (self::LOG_LEVEL > 0) |
|
987 | + { |
|
988 | + error_log(__METHOD__."('$path',$flags,'$url') can NOT resolve path: ".function_backtrace(1)); |
|
989 | + } |
|
894 | 990 | return false; |
895 | 991 | } |
896 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1)); |
|
992 | + if (self::LOG_LEVEL > 1) |
|
993 | + { |
|
994 | + error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1)); |
|
995 | + } |
|
897 | 996 | |
898 | 997 | while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) && |
899 | 998 | ($url = Vfs::dirname($url))) |
@@ -902,7 +1001,10 @@ discard block |
||
902 | 1001 | { |
903 | 1002 | if (is_link($url) && ($lpath = Vfs::readlink($url))) |
904 | 1003 | { |
905 | - if (self::LOG_LEVEL > 1) $log = "rel_path='$rel_path', url='$url': lpath='$lpath'"; |
|
1004 | + if (self::LOG_LEVEL > 1) |
|
1005 | + { |
|
1006 | + $log = "rel_path='$rel_path', url='$url': lpath='$lpath'"; |
|
1007 | + } |
|
906 | 1008 | |
907 | 1009 | if ($lpath[0] != '/') |
908 | 1010 | { |
@@ -910,15 +1012,24 @@ discard block |
||
910 | 1012 | } |
911 | 1013 | //self::symlinkCache_add($path,Vfs::PREFIX.$lpath); |
912 | 1014 | $url = Vfs::PREFIX.Vfs::concat($lpath,$rel_path); |
913 | - if (self::LOG_LEVEL > 1) error_log("$log --> lpath='$lpath', url='$url'"); |
|
1015 | + if (self::LOG_LEVEL > 1) |
|
1016 | + { |
|
1017 | + error_log("$log --> lpath='$lpath', url='$url'"); |
|
1018 | + } |
|
914 | 1019 | return $this->url_stat($url,$flags); |
915 | 1020 | } |
916 | 1021 | $url = Vfs::concat($url,$rel_path); |
917 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning null"); |
|
1022 | + if (self::LOG_LEVEL > 1) |
|
1023 | + { |
|
1024 | + error_log(__METHOD__."('$path',$flags,'$url') returning null"); |
|
1025 | + } |
|
918 | 1026 | return null; |
919 | 1027 | } |
920 | 1028 | } |
921 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning false"); |
|
1029 | + if (self::LOG_LEVEL > 1) |
|
1030 | + { |
|
1031 | + error_log(__METHOD__."('$path',$flags,'$url') returning false"); |
|
1032 | + } |
|
922 | 1033 | return false; // $path does not exist |
923 | 1034 | } |
924 | 1035 | |
@@ -939,9 +1050,16 @@ discard block |
||
939 | 1050 | { |
940 | 1051 | $path = self::get_path($_path); |
941 | 1052 | |
942 | - if (isset(self::$symlink_cache[$path])) return; // nothing to do |
|
1053 | + if (isset(self::$symlink_cache[$path])) |
|
1054 | + { |
|
1055 | + return; |
|
1056 | + } |
|
1057 | + // nothing to do |
|
943 | 1058 | |
944 | - if ($target[0] != '/') $target = Vfs::parse_url($target,PHP_URL_PATH); |
|
1059 | + if ($target[0] != '/') |
|
1060 | + { |
|
1061 | + $target = Vfs::parse_url($target,PHP_URL_PATH); |
|
1062 | + } |
|
945 | 1063 | |
946 | 1064 | self::$symlink_cache[$path] = $target; |
947 | 1065 | |
@@ -950,7 +1068,10 @@ discard block |
||
950 | 1068 | { |
951 | 1069 | return strlen($a) - strlen($b); |
952 | 1070 | }); |
953 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache)); |
|
1071 | + if (self::LOG_LEVEL > 1) |
|
1072 | + { |
|
1073 | + error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache)); |
|
1074 | + } |
|
954 | 1075 | } |
955 | 1076 | |
956 | 1077 | /** |
@@ -963,7 +1084,10 @@ discard block |
||
963 | 1084 | $path = self::get_path($_path); |
964 | 1085 | |
965 | 1086 | unset(self::$symlink_cache[$path]); |
966 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path) cache now ".array2string(self::$symlink_cache)); |
|
1087 | + if (self::LOG_LEVEL > 1) |
|
1088 | + { |
|
1089 | + error_log(__METHOD__."($path) cache now ".array2string(self::$symlink_cache)); |
|
1090 | + } |
|
967 | 1091 | } |
968 | 1092 | |
969 | 1093 | /** |
@@ -984,11 +1108,18 @@ discard block |
||
984 | 1108 | |
985 | 1109 | foreach(self::$symlink_cache as $p => $t) |
986 | 1110 | { |
987 | - if (($strlen_p = strlen($p)) > $strlen_path) continue; // $path can NOT start with $p |
|
1111 | + if (($strlen_p = strlen($p)) > $strlen_path) |
|
1112 | + { |
|
1113 | + continue; |
|
1114 | + } |
|
1115 | + // $path can NOT start with $p |
|
988 | 1116 | |
989 | 1117 | if ($path == $p) |
990 | 1118 | { |
991 | - if ($do_symlink) $target = $t; |
|
1119 | + if ($do_symlink) |
|
1120 | + { |
|
1121 | + $target = $t; |
|
1122 | + } |
|
992 | 1123 | break; |
993 | 1124 | } |
994 | 1125 | elseif (substr($path,0,$strlen_p+1) == $p.'/') |
@@ -997,7 +1128,10 @@ discard block |
||
997 | 1128 | break; |
998 | 1129 | } |
999 | 1130 | } |
1000 | - if (self::LOG_LEVEL > 1 && isset($target)) error_log(__METHOD__."($path) = $target"); |
|
1131 | + if (self::LOG_LEVEL > 1 && isset($target)) |
|
1132 | + { |
|
1133 | + error_log(__METHOD__."($path) = $target"); |
|
1134 | + } |
|
1001 | 1135 | return isset($target) ? $target : $path; |
1002 | 1136 | } |
1003 | 1137 | |
@@ -1038,7 +1172,10 @@ discard block |
||
1038 | 1172 | self::HIDE_UNREADABLES && !$this->opened_dir_writable && |
1039 | 1173 | !Vfs::check_access(Vfs::concat($this->opened_dir_url,$file),Vfs::READABLE))); |
1040 | 1174 | } |
1041 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $this->opened_dir ) = '$file'"); |
|
1175 | + if (self::LOG_LEVEL > 1) |
|
1176 | + { |
|
1177 | + error_log(__METHOD__."( $this->opened_dir ) = '$file'"); |
|
1178 | + } |
|
1042 | 1179 | return $file; |
1043 | 1180 | } |
1044 | 1181 | |
@@ -1141,7 +1278,10 @@ discard block |
||
1141 | 1278 | ) as $class) |
1142 | 1279 | { |
1143 | 1280 | //error_log(__METHOD__."('$scheme') class_exists('$class')=".array2string(class_exists($class))); |
1144 | - if (class_exists($class)) return $class; |
|
1281 | + if (class_exists($class)) |
|
1282 | + { |
|
1283 | + return $class; |
|
1284 | + } |
|
1145 | 1285 | } |
1146 | 1286 | } |
1147 | 1287 | |
@@ -1202,11 +1342,17 @@ discard block |
||
1202 | 1342 | */ |
1203 | 1343 | static function mount($url=null,$path=null,$check_url=null,$persitent_mount=true,$clear_fstab=false) |
1204 | 1344 | { |
1205 | - if (is_null($check_url)) $check_url = strpos($url,'$') === false; |
|
1345 | + if (is_null($check_url)) |
|
1346 | + { |
|
1347 | + $check_url = strpos($url,'$') === false; |
|
1348 | + } |
|
1206 | 1349 | |
1207 | - if (!isset($GLOBALS['egw_info']['server']['vfs_fstab'])) // happens eg. in setup |
|
1350 | + if (!isset($GLOBALS['egw_info']['server']['vfs_fstab'])) |
|
1351 | + { |
|
1352 | + // happens eg. in setup |
|
1208 | 1353 | { |
1209 | 1354 | $api_config = Api\Config::read('phpgwapi'); |
1355 | + } |
|
1210 | 1356 | if (isset($api_config['vfs_fstab']) && is_array($api_config['vfs_fstab'])) |
1211 | 1357 | { |
1212 | 1358 | self::$fstab = $api_config['vfs_fstab']; |
@@ -1222,12 +1368,18 @@ discard block |
||
1222 | 1368 | } |
1223 | 1369 | if (is_null($url) || is_null($path)) |
1224 | 1370 | { |
1225 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns '.array2string(self::$fstab)); |
|
1371 | + if (self::LOG_LEVEL > 1) |
|
1372 | + { |
|
1373 | + error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns '.array2string(self::$fstab)); |
|
1374 | + } |
|
1226 | 1375 | return self::$fstab; |
1227 | 1376 | } |
1228 | 1377 | if (!Vfs::$is_root) |
1229 | 1378 | { |
1230 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!'); |
|
1379 | + if (self::LOG_LEVEL > 0) |
|
1380 | + { |
|
1381 | + error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!'); |
|
1382 | + } |
|
1231 | 1383 | return false; // only root can mount |
1232 | 1384 | } |
1233 | 1385 | if ($clear_fstab) |
@@ -1236,14 +1388,20 @@ discard block |
||
1236 | 1388 | } |
1237 | 1389 | if (isset(self::$fstab[$path]) && self::$fstab[$path] === $url) |
1238 | 1390 | { |
1239 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') already mounted.'); |
|
1391 | + if (self::LOG_LEVEL > 0) |
|
1392 | + { |
|
1393 | + error_log(__METHOD__.'('.array2string($url).','.array2string($path).') already mounted.'); |
|
1394 | + } |
|
1240 | 1395 | return true; // already mounted |
1241 | 1396 | } |
1242 | 1397 | self::load_wrapper(Vfs::parse_url($url,PHP_URL_SCHEME)); |
1243 | 1398 | |
1244 | 1399 | if ($check_url && (!file_exists($url) || opendir($url) === false)) |
1245 | 1400 | { |
1246 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') url does NOT exist!'); |
|
1401 | + if (self::LOG_LEVEL > 0) |
|
1402 | + { |
|
1403 | + error_log(__METHOD__.'('.array2string($url).','.array2string($path).') url does NOT exist!'); |
|
1404 | + } |
|
1247 | 1405 | return false; // url does not exist |
1248 | 1406 | } |
1249 | 1407 | self::$fstab[$path] = $url; |
@@ -1258,12 +1416,18 @@ discard block |
||
1258 | 1416 | Api\Config::save_value('vfs_fstab',self::$fstab,'phpgwapi'); |
1259 | 1417 | $GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab; |
1260 | 1418 | // invalidate session cache |
1261 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
1419 | + if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
1420 | + { |
|
1421 | + // egw object in setup is limited |
|
1262 | 1422 | { |
1263 | 1423 | $GLOBALS['egw']->invalidate_session_cache(); |
1264 | 1424 | } |
1425 | + } |
|
1426 | + } |
|
1427 | + if (self::LOG_LEVEL > 1) |
|
1428 | + { |
|
1429 | + error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns true (successful new mount).'); |
|
1265 | 1430 | } |
1266 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns true (successful new mount).'); |
|
1267 | 1431 | return true; |
1268 | 1432 | } |
1269 | 1433 | |
@@ -1276,12 +1440,18 @@ discard block |
||
1276 | 1440 | { |
1277 | 1441 | if (!Vfs::$is_root) |
1278 | 1442 | { |
1279 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!'); |
|
1443 | + if (self::LOG_LEVEL > 0) |
|
1444 | + { |
|
1445 | + error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!'); |
|
1446 | + } |
|
1280 | 1447 | return false; // only root can mount |
1281 | 1448 | } |
1282 | 1449 | if (!isset(self::$fstab[$path]) && ($path = array_search($path,self::$fstab)) === false) |
1283 | 1450 | { |
1284 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).') NOT mounted!'); |
|
1451 | + if (self::LOG_LEVEL > 0) |
|
1452 | + { |
|
1453 | + error_log(__METHOD__.'('.array2string($path).') NOT mounted!'); |
|
1454 | + } |
|
1285 | 1455 | return false; // $path not mounted |
1286 | 1456 | } |
1287 | 1457 | unset(self::$fstab[$path]); |
@@ -1289,11 +1459,17 @@ discard block |
||
1289 | 1459 | Api\Config::save_value('vfs_fstab',self::$fstab,'phpgwapi'); |
1290 | 1460 | $GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab; |
1291 | 1461 | // invalidate session cache |
1292 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
1462 | + if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
1463 | + { |
|
1464 | + // egw object in setup is limited |
|
1293 | 1465 | { |
1294 | 1466 | $GLOBALS['egw']->invalidate_session_cache(); |
1295 | 1467 | } |
1296 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($path).') returns true (successful unmount).'); |
|
1468 | + } |
|
1469 | + if (self::LOG_LEVEL > 1) |
|
1470 | + { |
|
1471 | + error_log(__METHOD__.'('.array2string($path).') returns true (successful unmount).'); |
|
1472 | + } |
|
1297 | 1473 | return true; |
1298 | 1474 | } |
1299 | 1475 |
@@ -405,10 +405,10 @@ discard block |
||
405 | 405 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
406 | 406 | * |
407 | 407 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
408 | - * { |
|
408 | + * { |
|
409 | 409 | * $eof = !$eof; |
410 | 410 | * } |
411 | - * |
|
411 | + * |
|
412 | 412 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
413 | 413 | */ |
414 | 414 | function stream_eof ( ) |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1)); |
907 | 907 | |
908 | 908 | while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) && |
909 | - ($url = Vfs::dirname($url))) |
|
909 | + ($url = Vfs::dirname($url))) |
|
910 | 910 | { |
911 | 911 | if (($stat = $this->url_stat($url,0,true,false))) |
912 | 912 | { |
@@ -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 | - function resolve_url_symlinks($_path,$file_exists=true,$resolve_last_symlink=true,&$stat=null) |
|
160 | + function resolve_url_symlinks($_path, $file_exists = true, $resolve_last_symlink = true, &$stat = null) |
|
161 | 161 | { |
162 | 162 | $path = self::get_path($_path); |
163 | 163 | |
164 | - if (!($stat = $this->url_stat($path,$resolve_last_symlink?0:STREAM_URL_STAT_LINK)) && !$file_exists) |
|
164 | + if (!($stat = $this->url_stat($path, $resolve_last_symlink ? 0 : STREAM_URL_STAT_LINK)) && !$file_exists) |
|
165 | 165 | { |
166 | 166 | $url = null; |
167 | - $stat = self::check_symlink_components($path,0,$url); |
|
167 | + $stat = self::check_symlink_components($path, 0, $url); |
|
168 | 168 | if (self::LOG_LEVEL > 1) $log = " (check_symlink_components('$path',0,'$url') = $stat)"; |
169 | 169 | } |
170 | 170 | else |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | $url = $stat['url']; |
173 | 173 | } |
174 | 174 | // if the url resolves to a symlink to the vfs, resolve this vfs:// url direct |
175 | - if ($url && Vfs::parse_url($url,PHP_URL_SCHEME) == self::SCHEME) |
|
175 | + if ($url && Vfs::parse_url($url, PHP_URL_SCHEME) == self::SCHEME) |
|
176 | 176 | { |
177 | - $url = self::resolve_url(Vfs::parse_url($url,PHP_URL_PATH)); |
|
177 | + $url = self::resolve_url(Vfs::parse_url($url, PHP_URL_PATH)); |
|
178 | 178 | } |
179 | 179 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,file_exists=$file_exists,resolve_last_symlink=$resolve_last_symlink) = '$url'$log"); |
180 | 180 | return $url; |
@@ -197,7 +197,7 @@ discard block |
||
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(Vfs::parse_url($path),$defaults); |
|
227 | - if (!$parts['host']) $parts['host'] = 'default'; // otherwise we get an invalid url (scheme:///path/to/something)! |
|
226 | + $parts = array_merge(Vfs::parse_url($path), $defaults); |
|
227 | + if (!$parts['host']) $parts['host'] = 'default'; // otherwise we get an invalid url (scheme:///path/to/something)! |
|
228 | 228 | |
229 | 229 | if (!empty($parts['scheme']) && $parts['scheme'] != self::SCHEME) |
230 | 230 | { |
231 | 231 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$path' (path is already an url)"); |
232 | - return $path; // path is already a non-vfs url --> nothing to do |
|
232 | + return $path; // path is already a non-vfs url --> nothing to do |
|
233 | 233 | } |
234 | 234 | if (empty($parts['path'])) $parts['path'] = '/'; |
235 | 235 | |
236 | - foreach(array_reverse(self::$fstab) as $mounted => $url) |
|
236 | + foreach (array_reverse(self::$fstab) as $mounted => $url) |
|
237 | 237 | { |
238 | - if ($mounted == '/' || $mounted == $parts['path'] || $mounted.'/' == substr($parts['path'],0,strlen($mounted)+1)) |
|
238 | + if ($mounted == '/' || $mounted == $parts['path'] || $mounted.'/' == substr($parts['path'], 0, strlen($mounted) + 1)) |
|
239 | 239 | { |
240 | - $scheme = Vfs::parse_url($url,PHP_URL_SCHEME); |
|
241 | - if (is_null(self::$wrappers) || !in_array($scheme,self::$wrappers)) |
|
240 | + $scheme = Vfs::parse_url($url, PHP_URL_SCHEME); |
|
241 | + if (is_null(self::$wrappers) || !in_array($scheme, self::$wrappers)) |
|
242 | 242 | { |
243 | 243 | self::load_wrapper($scheme); |
244 | 244 | } |
245 | - if (($relative = substr($parts['path'],strlen($mounted)))) |
|
245 | + if (($relative = substr($parts['path'], strlen($mounted)))) |
|
246 | 246 | { |
247 | - $url = Vfs::concat($url,$relative); |
|
247 | + $url = Vfs::concat($url, $relative); |
|
248 | 248 | } |
249 | 249 | // if url contains url parameter, eg. from filesystem streamwrapper, we need to append relative path here too |
250 | 250 | $matches = null; |
251 | 251 | if ($fix_url_query && preg_match('|([?&]url=)([^&]+)|', $url, $matches)) |
252 | 252 | { |
253 | - $url = str_replace($matches[0], $matches[1].Vfs::concat($matches[2], substr($parts['path'],strlen($mounted))), $url); |
|
253 | + $url = str_replace($matches[0], $matches[1].Vfs::concat($matches[2], substr($parts['path'], strlen($mounted))), $url); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | if ($replace_user_pass_host) |
257 | 257 | { |
258 | - $url = str_replace(array('$user','$pass','$host','$home'),array($parts['user'],$parts['pass'],$parts['host'],$parts['home']),$url); |
|
258 | + $url = str_replace(array('$user', '$pass', '$host', '$home'), array($parts['user'], $parts['pass'], $parts['host'], $parts['home']), $url); |
|
259 | 259 | } |
260 | 260 | if ($parts['query']) $url .= '?'.$parts['query']; |
261 | 261 | if ($parts['fragment']) $url .= '#'.$parts['fragment']; |
@@ -268,7 +268,7 @@ discard block |
||
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 | } |
@@ -303,13 +303,13 @@ discard block |
||
303 | 303 | * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set |
304 | 304 | * @return boolean true if the ressource was opened successful, otherwise false |
305 | 305 | */ |
306 | - function stream_open ( $path, $mode, $options, &$opened_path ) |
|
306 | + function stream_open($path, $mode, $options, &$opened_path) |
|
307 | 307 | { |
308 | - unset($options,$opened_path); // not used but required by function signature |
|
308 | + unset($options, $opened_path); // not used but required by function signature |
|
309 | 309 | $this->opened_stream = null; |
310 | 310 | |
311 | 311 | $stat = null; |
312 | - if (!($url = $this->resolve_url_symlinks($path,$mode[0]=='r',true,$stat))) |
|
312 | + if (!($url = $this->resolve_url_symlinks($path, $mode[0] == 'r', true, $stat))) |
|
313 | 313 | { |
314 | 314 | return false; |
315 | 315 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * |
346 | 346 | * VFS calls either "vfs_read", "vfs_added" or "vfs_modified" hook |
347 | 347 | */ |
348 | - function stream_close ( ) |
|
348 | + function stream_close( ) |
|
349 | 349 | { |
350 | 350 | $ret = fclose($this->opened_stream); |
351 | 351 | // clear PHP's stat cache, it contains wrong size of just closed file, |
@@ -355,12 +355,11 @@ discard block |
||
355 | 355 | if (!class_exists('setup_process', false)) |
356 | 356 | { |
357 | 357 | Api\Hooks::process(array( |
358 | - 'location' => str_replace('b','',$this->opened_stream_mode) == 'r' ? 'vfs_read' : |
|
359 | - ($this->opened_stream_is_new ? 'vfs_added' : 'vfs_modified'), |
|
358 | + 'location' => str_replace('b', '', $this->opened_stream_mode) == 'r' ? 'vfs_read' : ($this->opened_stream_is_new ? 'vfs_added' : 'vfs_modified'), |
|
360 | 359 | 'path' => $this->opened_stream_path, |
361 | 360 | 'mode' => $this->opened_stream_mode, |
362 | 361 | 'url' => $this->opened_stream_url, |
363 | - ),'',true); |
|
362 | + ), '', true); |
|
364 | 363 | } |
365 | 364 | $this->opened_stream = $this->opened_stream_mode = $this->opened_stream_path = $this->opened_stream_url = $this->opened_stream_is_new = null; |
366 | 365 | |
@@ -378,9 +377,9 @@ discard block |
||
378 | 377 | * @param int $count |
379 | 378 | * @return string/false up to count bytes read or false on EOF |
380 | 379 | */ |
381 | - function stream_read ( $count ) |
|
380 | + function stream_read($count) |
|
382 | 381 | { |
383 | - return fread($this->opened_stream,$count); |
|
382 | + return fread($this->opened_stream, $count); |
|
384 | 383 | } |
385 | 384 | |
386 | 385 | /** |
@@ -394,9 +393,9 @@ discard block |
||
394 | 393 | * @param string $data |
395 | 394 | * @return integer |
396 | 395 | */ |
397 | - function stream_write ( $data ) |
|
396 | + function stream_write($data) |
|
398 | 397 | { |
399 | - return fwrite($this->opened_stream,$data); |
|
398 | + return fwrite($this->opened_stream, $data); |
|
400 | 399 | } |
401 | 400 | |
402 | 401 | /** |
@@ -411,7 +410,7 @@ discard block |
||
411 | 410 | * |
412 | 411 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
413 | 412 | */ |
414 | - function stream_eof ( ) |
|
413 | + function stream_eof( ) |
|
415 | 414 | { |
416 | 415 | return feof($this->opened_stream); |
417 | 416 | } |
@@ -421,7 +420,7 @@ discard block |
||
421 | 420 | * |
422 | 421 | * @return integer current read/write position of the stream |
423 | 422 | */ |
424 | - function stream_tell ( ) |
|
423 | + function stream_tell( ) |
|
425 | 424 | { |
426 | 425 | return ftell($this->opened_stream); |
427 | 426 | } |
@@ -438,9 +437,9 @@ discard block |
||
438 | 437 | * SEEK_END - 2 - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.) |
439 | 438 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
440 | 439 | */ |
441 | - function stream_seek ( $offset, $whence ) |
|
440 | + function stream_seek($offset, $whence) |
|
442 | 441 | { |
443 | - return !fseek($this->opened_stream,$offset,$whence); // fseek returns 0 on success and -1 on failure |
|
442 | + return !fseek($this->opened_stream, $offset, $whence); // fseek returns 0 on success and -1 on failure |
|
444 | 443 | } |
445 | 444 | |
446 | 445 | /** |
@@ -450,7 +449,7 @@ discard block |
||
450 | 449 | * |
451 | 450 | * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored. |
452 | 451 | */ |
453 | - function stream_flush ( ) |
|
452 | + function stream_flush( ) |
|
454 | 453 | { |
455 | 454 | return fflush($this->opened_stream); |
456 | 455 | } |
@@ -469,7 +468,7 @@ discard block |
||
469 | 468 | * |
470 | 469 | * @return array containing the same values as appropriate for the stream. |
471 | 470 | */ |
472 | - function stream_stat ( ) |
|
471 | + function stream_stat( ) |
|
473 | 472 | { |
474 | 473 | return fstat($this->opened_stream); |
475 | 474 | } |
@@ -498,10 +497,10 @@ discard block |
||
498 | 497 | } |
499 | 498 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path', $option, ".array2string($value).") url=$url"); |
500 | 499 | |
501 | - switch($option) |
|
500 | + switch ($option) |
|
502 | 501 | { |
503 | 502 | case STREAM_META_TOUCH: |
504 | - return touch($url, $value[0]); // atime is not supported |
|
503 | + return touch($url, $value[0]); // atime is not supported |
|
505 | 504 | |
506 | 505 | case STREAM_META_ACCESS: |
507 | 506 | return chmod($url, $value); |
@@ -532,9 +531,9 @@ discard block |
||
532 | 531 | * @param string $path |
533 | 532 | * @return boolean TRUE on success or FALSE on failure |
534 | 533 | */ |
535 | - function unlink ( $path ) |
|
534 | + function unlink($path) |
|
536 | 535 | { |
537 | - if (!($url = $this->resolve_url_symlinks($path,true,false))) // true,false file need to exist, but do not resolve last component |
|
536 | + if (!($url = $this->resolve_url_symlinks($path, true, false))) // true,false file need to exist, but do not resolve last component |
|
538 | 537 | { |
539 | 538 | return false; |
540 | 539 | } |
@@ -555,7 +554,7 @@ discard block |
||
555 | 554 | 'path' => $path[0] == '/' ? $path : Vfs::parse_url($path, PHP_URL_PATH), |
556 | 555 | 'url' => $url, |
557 | 556 | 'stat' => $stat, |
558 | - ),'',true); |
|
557 | + ), '', true); |
|
559 | 558 | } |
560 | 559 | return $ok; |
561 | 560 | } |
@@ -573,26 +572,26 @@ discard block |
||
573 | 572 | * @return boolean TRUE on success or FALSE on failure |
574 | 573 | * @throws Exception\ProtectedDirectory if trying to delete a protected directory, see Vfs::isProtected() |
575 | 574 | */ |
576 | - function rename ( $path_from, $path_to ) |
|
575 | + function rename($path_from, $path_to) |
|
577 | 576 | { |
578 | 577 | if (Vfs::isProtectedDir($path_from)) |
579 | 578 | { |
580 | 579 | throw new Exception\ProtectedDirectory("Renaming protected directory '$path_from' rejected!"); |
581 | 580 | } |
582 | - if (!($url_from = $this->resolve_url_symlinks($path_from,true,false)) || |
|
583 | - !($url_to = $this->resolve_url_symlinks($path_to,false))) |
|
581 | + if (!($url_from = $this->resolve_url_symlinks($path_from, true, false)) || |
|
582 | + !($url_to = $this->resolve_url_symlinks($path_to, false))) |
|
584 | 583 | { |
585 | 584 | return false; |
586 | 585 | } |
587 | 586 | // if file is moved from one filesystem / wrapper to an other --> copy it (rename fails cross wrappers) |
588 | - if (Vfs::parse_url($url_from,PHP_URL_SCHEME) == Vfs::parse_url($url_to,PHP_URL_SCHEME)) |
|
587 | + if (Vfs::parse_url($url_from, PHP_URL_SCHEME) == Vfs::parse_url($url_to, PHP_URL_SCHEME)) |
|
589 | 588 | { |
590 | 589 | self::symlinkCache_remove($path_from); |
591 | - $ret = rename($url_from,$url_to); |
|
590 | + $ret = rename($url_from, $url_to); |
|
592 | 591 | } |
593 | - elseif (($from = fopen($url_from,'r')) && ($to = fopen($url_to,'w'))) |
|
592 | + elseif (($from = fopen($url_from, 'r')) && ($to = fopen($url_to, 'w'))) |
|
594 | 593 | { |
595 | - $ret = stream_copy_to_stream($from,$to) !== false; |
|
594 | + $ret = stream_copy_to_stream($from, $to) !== false; |
|
596 | 595 | fclose($from); |
597 | 596 | fclose($to); |
598 | 597 | if ($ret) $this->unlink($path_from); |
@@ -614,7 +613,7 @@ discard block |
||
614 | 613 | 'to' => $path_to[0] == '/' ? $path_to : Vfs::parse_url($path_to, PHP_URL_PATH), |
615 | 614 | 'url_from' => $url_from, |
616 | 615 | 'url_to' => $url_to, |
617 | - ),'',true); |
|
616 | + ), '', true); |
|
618 | 617 | } |
619 | 618 | return $ret; |
620 | 619 | } |
@@ -630,14 +629,14 @@ discard block |
||
630 | 629 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE |
631 | 630 | * @return boolean TRUE on success or FALSE on failure |
632 | 631 | */ |
633 | - function mkdir ( $path, $mode, $options ) |
|
632 | + function mkdir($path, $mode, $options) |
|
634 | 633 | { |
635 | - if (!($url = $this->resolve_url_symlinks($path,false))) // false = directory does not need to exists |
|
634 | + if (!($url = $this->resolve_url_symlinks($path, false))) // false = directory does not need to exists |
|
636 | 635 | { |
637 | 636 | return false; |
638 | 637 | } |
639 | 638 | // check if recursive option is set and needed |
640 | - if (($options & STREAM_MKDIR_RECURSIVE) && |
|
639 | + if (($options&STREAM_MKDIR_RECURSIVE) && |
|
641 | 640 | ($parent_url = Vfs::dirname($url)) && |
642 | 641 | !($this->url_stat($parent_url, STREAM_URL_STAT_QUIET)) && |
643 | 642 | Vfs::parse_url($parent_url, PHP_URL_PATH) !== '/') |
@@ -647,7 +646,7 @@ discard block |
||
647 | 646 | // unset it now, as it was handled above |
648 | 647 | $options &= ~STREAM_MKDIR_RECURSIVE; |
649 | 648 | |
650 | - $ret = mkdir($url,$mode,$options); |
|
649 | + $ret = mkdir($url, $mode, $options); |
|
651 | 650 | |
652 | 651 | // call "vfs_mkdir" hook |
653 | 652 | if ($ret && !class_exists('setup_process', false)) |
@@ -656,7 +655,7 @@ discard block |
||
656 | 655 | 'location' => 'vfs_mkdir', |
657 | 656 | 'path' => $path[0] == '/' ? $path : Vfs::parse_url($path, PHP_URL_PATH), |
658 | 657 | 'url' => $url, |
659 | - ),'',true); |
|
658 | + ), '', true); |
|
660 | 659 | } |
661 | 660 | return $ret; |
662 | 661 | } |
@@ -672,13 +671,13 @@ discard block |
||
672 | 671 | * @return boolean TRUE on success or FALSE on failure. |
673 | 672 | * @throws Exception\ProtectedDirectory if trying to delete a protected directory, see Vfs::isProtected() |
674 | 673 | */ |
675 | - function rmdir ( $path, $options ) |
|
674 | + function rmdir($path, $options) |
|
676 | 675 | { |
677 | 676 | if (Vfs::isProtectedDir($path)) |
678 | 677 | { |
679 | 678 | throw new Exception\ProtectedDirectory("Deleting protected directory '$path' rejected!"); |
680 | 679 | } |
681 | - unset($options); // not uses but required by function signature |
|
680 | + unset($options); // not uses but required by function signature |
|
682 | 681 | if (!($url = $this->resolve_url_symlinks($path))) |
683 | 682 | { |
684 | 683 | return false; |
@@ -700,7 +699,7 @@ discard block |
||
700 | 699 | 'path' => $path[0] == '/' ? $path : Vfs::parse_url($path, PHP_URL_PATH), |
701 | 700 | 'url' => $url, |
702 | 701 | 'stat' => $stat, |
703 | - ),'',true); |
|
702 | + ), '', true); |
|
704 | 703 | } |
705 | 704 | return $ok; |
706 | 705 | } |
@@ -711,7 +710,7 @@ discard block |
||
711 | 710 | * @param string $path URL that was passed to opendir() and that this object is expected to explore. |
712 | 711 | * @return booelan |
713 | 712 | */ |
714 | - function dir_opendir ( $path, $options ) |
|
713 | + function dir_opendir($path, $options) |
|
715 | 714 | { |
716 | 715 | $this->opened_dir = $this->extra_dirs = null; |
717 | 716 | $this->dir_url_params = array(); |
@@ -728,15 +727,15 @@ discard block |
||
728 | 727 | if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!"); |
729 | 728 | return false; |
730 | 729 | } |
731 | - $this->opened_dir_writable = Vfs::check_access($this->opened_dir_url,Vfs::WRITABLE); |
|
730 | + $this->opened_dir_writable = Vfs::check_access($this->opened_dir_url, Vfs::WRITABLE); |
|
732 | 731 | // check our fstab if we need to add some of the mountpoints |
733 | - $basepath = Vfs::parse_url($path,PHP_URL_PATH); |
|
734 | - foreach(array_keys(self::$fstab) as $mounted) |
|
732 | + $basepath = Vfs::parse_url($path, PHP_URL_PATH); |
|
733 | + foreach (array_keys(self::$fstab) as $mounted) |
|
735 | 734 | { |
736 | 735 | if (((Vfs::dirname($mounted) == $basepath || Vfs::dirname($mounted).'/' == $basepath) && $mounted != '/') && |
737 | 736 | // only return children readable by the user, if dir is not writable |
738 | 737 | (!self::HIDE_UNREADABLES || $this->opened_dir_writable || |
739 | - Vfs::check_access($mounted,Vfs::READABLE))) |
|
738 | + Vfs::check_access($mounted, Vfs::READABLE))) |
|
740 | 739 | { |
741 | 740 | $this->extra_dirs[] = basename($mounted); |
742 | 741 | } |
@@ -775,24 +774,24 @@ discard block |
||
775 | 774 | * @param boolean $check_symlink_components =true check if path contains symlinks in path components other then the last one |
776 | 775 | * @return array |
777 | 776 | */ |
778 | - function url_stat ( $path, $flags, $try_create_home=false, $check_symlink_components=true, $check_symlink_depth=self::MAX_SYMLINK_DEPTH, $try_reconnect=true ) |
|
777 | + function url_stat($path, $flags, $try_create_home = false, $check_symlink_components = true, $check_symlink_depth = self::MAX_SYMLINK_DEPTH, $try_reconnect = true) |
|
779 | 778 | { |
780 | - if (!($url = self::resolve_url($path,!($flags & STREAM_URL_STAT_LINK), $check_symlink_components))) |
|
779 | + if (!($url = self::resolve_url($path, !($flags&STREAM_URL_STAT_LINK), $check_symlink_components))) |
|
781 | 780 | { |
782 | 781 | if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) can NOT resolve path!"); |
783 | 782 | return false; |
784 | 783 | } |
785 | 784 | |
786 | 785 | try { |
787 | - if ($flags & STREAM_URL_STAT_LINK) |
|
786 | + if ($flags&STREAM_URL_STAT_LINK) |
|
788 | 787 | { |
789 | - $stat = @lstat($url); // suppressed the stat failed warnings |
|
788 | + $stat = @lstat($url); // suppressed the stat failed warnings |
|
790 | 789 | } |
791 | 790 | else |
792 | 791 | { |
793 | - $stat = @stat($url); // suppressed the stat failed warnings |
|
792 | + $stat = @stat($url); // suppressed the stat failed warnings |
|
794 | 793 | |
795 | - if ($stat && ($stat['mode'] & self::MODE_LINK)) |
|
794 | + if ($stat && ($stat['mode']&self::MODE_LINK)) |
|
796 | 795 | { |
797 | 796 | if (!$check_symlink_depth) |
798 | 797 | { |
@@ -803,25 +802,25 @@ discard block |
||
803 | 802 | { |
804 | 803 | if ($lpath[0] != '/') // concat relative path |
805 | 804 | { |
806 | - $lpath = Vfs::concat(Vfs::parse_url($path,PHP_URL_PATH),'../'.$lpath); |
|
805 | + $lpath = Vfs::concat(Vfs::parse_url($path, PHP_URL_PATH), '../'.$lpath); |
|
807 | 806 | } |
808 | - $u_query = parse_url($url,PHP_URL_QUERY); |
|
807 | + $u_query = parse_url($url, PHP_URL_QUERY); |
|
809 | 808 | $url = Vfs::PREFIX.$lpath; |
810 | 809 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$flags) symlif (substr($path,-1) == '/' && $path != '/') $path = substr($path,0,-1); // remove trailing slash eg. added by WebDAVink found and resolved to $url"); |
811 | 810 | // try reading the stat of the link |
812 | - if (($stat = $this->url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth-1))) |
|
811 | + if (($stat = $this->url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth - 1))) |
|
813 | 812 | { |
814 | 813 | $stat_query = parse_url($stat['url'], PHP_URL_QUERY); |
815 | - if($u_query || $stat_query) |
|
814 | + if ($u_query || $stat_query) |
|
816 | 815 | { |
817 | 816 | $stat_url = parse_url($stat['url']); |
818 | - parse_str($stat_query,$stat_query); |
|
817 | + parse_str($stat_query, $stat_query); |
|
819 | 818 | parse_str($u_query, $u_query); |
820 | 819 | $stat_query = http_build_query(array_merge($stat_query, $u_query)); |
821 | 820 | $stat['url'] = $stat_url['scheme'].'://'.$stat_url['host'].$stat_url['path'].'?'.$stat_query; |
822 | 821 | } |
823 | - if(isset($stat['url'])) $url = $stat['url']; // if stat returns an url use that, as there might be more links ... |
|
824 | - self::symlinkCache_add($path,$url); |
|
822 | + if (isset($stat['url'])) $url = $stat['url']; // if stat returns an url use that, as there might be more links ... |
|
823 | + self::symlinkCache_add($path, $url); |
|
825 | 824 | } |
826 | 825 | } |
827 | 826 | } |
@@ -841,7 +840,7 @@ discard block |
||
841 | 840 | throw $e; |
842 | 841 | } |
843 | 842 | // check if a failed url_stat was for a home dir, in that case silently create it |
844 | - if (!$stat && $try_create_home && Vfs::dirname(Vfs::parse_url($path,PHP_URL_PATH)) == '/home' && |
|
843 | + if (!$stat && $try_create_home && Vfs::dirname(Vfs::parse_url($path, PHP_URL_PATH)) == '/home' && |
|
845 | 844 | ($id = $GLOBALS['egw']->accounts->name2id(basename($path))) && |
846 | 845 | $GLOBALS['egw']->accounts->id2name($id) == basename($path)) // make sure path has the right case! |
847 | 846 | { |
@@ -851,25 +850,25 @@ discard block |
||
851 | 850 | 'account_lid' => basename($path), |
852 | 851 | 'account_name' => basename($path), |
853 | 852 | ); |
854 | - call_user_func(array(__NAMESPACE__.'\\Hooks',$hook_data['location']),$hook_data); |
|
853 | + call_user_func(array(__NAMESPACE__.'\\Hooks', $hook_data['location']), $hook_data); |
|
855 | 854 | unset($hook_data); |
856 | - $stat = $this->url_stat($path,$flags,false); |
|
855 | + $stat = $this->url_stat($path, $flags, false); |
|
857 | 856 | } |
858 | 857 | $query = parse_url($url, PHP_URL_QUERY); |
859 | 858 | if (!$stat && $check_symlink_components) // check if there's a symlink somewhere inbetween the path |
860 | 859 | { |
861 | - $stat = self::check_symlink_components($path,$flags,$url); |
|
862 | - if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path,$stat['url']); |
|
860 | + $stat = self::check_symlink_components($path, $flags, $url); |
|
861 | + if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path, $stat['url']); |
|
863 | 862 | } |
864 | - elseif(is_array($stat) && !isset($stat['url'])) |
|
863 | + elseif (is_array($stat) && !isset($stat['url'])) |
|
865 | 864 | { |
866 | 865 | $stat['url'] = $url; |
867 | 866 | } |
868 | - if (($stat['mode'] & 0222) && self::url_is_readonly($stat['url'])) |
|
867 | + if (($stat['mode']&0222) && self::url_is_readonly($stat['url'])) |
|
869 | 868 | { |
870 | 869 | $stat['mode'] &= ~0222; |
871 | 870 | } |
872 | - if($stat['url'] && $query && strpos($stat['url'],'?'.$query)===false) |
|
871 | + if ($stat['url'] && $query && strpos($stat['url'], '?'.$query) === false) |
|
873 | 872 | { |
874 | 873 | $stat['url'] .= '?'.$query; |
875 | 874 | } |
@@ -896,7 +895,7 @@ discard block |
||
896 | 895 | * @param string &$url=null already resolved path |
897 | 896 | * @return array|boolean stat array or false if not found |
898 | 897 | */ |
899 | - private function check_symlink_components($path,$flags=0,&$url=null) |
|
898 | + private function check_symlink_components($path, $flags = 0, &$url = null) |
|
900 | 899 | { |
901 | 900 | if (is_null($url) && !($url = self::resolve_url($path))) |
902 | 901 | { |
@@ -908,7 +907,7 @@ discard block |
||
908 | 907 | while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) && |
909 | 908 | ($url = Vfs::dirname($url))) |
910 | 909 | { |
911 | - if (($stat = $this->url_stat($url,0,true,false))) |
|
910 | + if (($stat = $this->url_stat($url, 0, true, false))) |
|
912 | 911 | { |
913 | 912 | if (is_link($url) && ($lpath = Vfs::readlink($url))) |
914 | 913 | { |
@@ -916,20 +915,20 @@ discard block |
||
916 | 915 | |
917 | 916 | if ($lpath[0] != '/') |
918 | 917 | { |
919 | - $lpath = Vfs::concat(Vfs::parse_url($url,PHP_URL_PATH),'../'.$lpath); |
|
918 | + $lpath = Vfs::concat(Vfs::parse_url($url, PHP_URL_PATH), '../'.$lpath); |
|
920 | 919 | } |
921 | 920 | //self::symlinkCache_add($path,Vfs::PREFIX.$lpath); |
922 | - $url = Vfs::PREFIX.Vfs::concat($lpath,$rel_path); |
|
921 | + $url = Vfs::PREFIX.Vfs::concat($lpath, $rel_path); |
|
923 | 922 | if (self::LOG_LEVEL > 1) error_log("$log --> lpath='$lpath', url='$url'"); |
924 | - return $this->url_stat($url,$flags); |
|
923 | + return $this->url_stat($url, $flags); |
|
925 | 924 | } |
926 | - $url = Vfs::concat($url,$rel_path); |
|
925 | + $url = Vfs::concat($url, $rel_path); |
|
927 | 926 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning null"); |
928 | 927 | return null; |
929 | 928 | } |
930 | 929 | } |
931 | 930 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning false"); |
932 | - return false; // $path does not exist |
|
931 | + return false; // $path does not exist |
|
933 | 932 | } |
934 | 933 | |
935 | 934 | /** |
@@ -945,13 +944,13 @@ discard block |
||
945 | 944 | * @param string $_path vfs path |
946 | 945 | * @param string $target target path |
947 | 946 | */ |
948 | - static protected function symlinkCache_add($_path,$target) |
|
947 | + static protected function symlinkCache_add($_path, $target) |
|
949 | 948 | { |
950 | 949 | $path = self::get_path($_path); |
951 | 950 | |
952 | - if (isset(self::$symlink_cache[$path])) return; // nothing to do |
|
951 | + if (isset(self::$symlink_cache[$path])) return; // nothing to do |
|
953 | 952 | |
954 | - if ($target[0] != '/') $target = Vfs::parse_url($target,PHP_URL_PATH); |
|
953 | + if ($target[0] != '/') $target = Vfs::parse_url($target, PHP_URL_PATH); |
|
955 | 954 | |
956 | 955 | self::$symlink_cache[$path] = $target; |
957 | 956 | |
@@ -985,25 +984,25 @@ discard block |
||
985 | 984 | * @param boolean $do_symlink =true is a direct match allowed, default yes (must be false for a lstat or readlink!) |
986 | 985 | * @return string target or path, if path not found |
987 | 986 | */ |
988 | - static public function symlinkCache_resolve($_path,$do_symlink=true) |
|
987 | + static public function symlinkCache_resolve($_path, $do_symlink = true) |
|
989 | 988 | { |
990 | 989 | // remove vfs scheme, but no other schemes (eg. filesystem!) |
991 | 990 | $path = self::get_path($_path); |
992 | 991 | |
993 | 992 | $strlen_path = strlen($path); |
994 | 993 | |
995 | - foreach(self::$symlink_cache as $p => $t) |
|
994 | + foreach (self::$symlink_cache as $p => $t) |
|
996 | 995 | { |
997 | - if (($strlen_p = strlen($p)) > $strlen_path) continue; // $path can NOT start with $p |
|
996 | + if (($strlen_p = strlen($p)) > $strlen_path) continue; // $path can NOT start with $p |
|
998 | 997 | |
999 | 998 | if ($path == $p) |
1000 | 999 | { |
1001 | 1000 | if ($do_symlink) $target = $t; |
1002 | 1001 | break; |
1003 | 1002 | } |
1004 | - elseif (substr($path,0,$strlen_p+1) == $p.'/') |
|
1003 | + elseif (substr($path, 0, $strlen_p + 1) == $p.'/') |
|
1005 | 1004 | { |
1006 | - $target = $t . substr($path,$strlen_p); |
|
1005 | + $target = $t.substr($path, $strlen_p); |
|
1007 | 1006 | break; |
1008 | 1007 | } |
1009 | 1008 | } |
@@ -1031,7 +1030,7 @@ discard block |
||
1031 | 1030 | * |
1032 | 1031 | * @return string |
1033 | 1032 | */ |
1034 | - function dir_readdir ( ) |
|
1033 | + function dir_readdir( ) |
|
1035 | 1034 | { |
1036 | 1035 | if ($this->extra_dirs && count($this->extra_dirs) > $this->extra_dir_ptr) |
1037 | 1036 | { |
@@ -1043,10 +1042,10 @@ discard block |
||
1043 | 1042 | do { |
1044 | 1043 | $file = readdir($this->opened_dir); |
1045 | 1044 | } |
1046 | - while($file !== false && |
|
1047 | - (is_array($this->extra_dirs) && in_array($file,$this->extra_dirs) || // do NOT return extra_dirs twice |
|
1045 | + while ($file !== false && |
|
1046 | + (is_array($this->extra_dirs) && in_array($file, $this->extra_dirs) || // do NOT return extra_dirs twice |
|
1048 | 1047 | self::HIDE_UNREADABLES && !$this->opened_dir_writable && |
1049 | - !Vfs::check_access(Vfs::concat($this->opened_dir_url,$file),Vfs::READABLE))); |
|
1048 | + !Vfs::check_access(Vfs::concat($this->opened_dir_url, $file), Vfs::READABLE))); |
|
1050 | 1049 | } |
1051 | 1050 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $this->opened_dir ) = '$file'"); |
1052 | 1051 | return $file; |
@@ -1060,7 +1059,7 @@ discard block |
||
1060 | 1059 | * |
1061 | 1060 | * @return boolean |
1062 | 1061 | */ |
1063 | - function dir_rewinddir ( ) |
|
1062 | + function dir_rewinddir( ) |
|
1064 | 1063 | { |
1065 | 1064 | $this->extra_dir_ptr = 0; |
1066 | 1065 | |
@@ -1074,7 +1073,7 @@ discard block |
||
1074 | 1073 | * |
1075 | 1074 | * @return boolean |
1076 | 1075 | */ |
1077 | - function dir_closedir ( ) |
|
1076 | + function dir_closedir( ) |
|
1078 | 1077 | { |
1079 | 1078 | $ret = closedir($this->opened_dir); |
1080 | 1079 | |
@@ -1091,9 +1090,9 @@ discard block |
||
1091 | 1090 | */ |
1092 | 1091 | static function load_wrapper($scheme) |
1093 | 1092 | { |
1094 | - if (!in_array($scheme,self::get_wrappers())) |
|
1093 | + if (!in_array($scheme, self::get_wrappers())) |
|
1095 | 1094 | { |
1096 | - switch($scheme) |
|
1095 | + switch ($scheme) |
|
1097 | 1096 | { |
1098 | 1097 | case 'webdav': |
1099 | 1098 | case 'webdavs': |
@@ -1101,16 +1100,16 @@ discard block |
||
1101 | 1100 | self::$wrappers[] = $scheme; |
1102 | 1101 | break; |
1103 | 1102 | case '': |
1104 | - break; // default file, always loaded |
|
1103 | + break; // default file, always loaded |
|
1105 | 1104 | default: |
1106 | 1105 | // check if scheme is buildin in php or one of our own stream wrappers |
1107 | - if (in_array($scheme,stream_get_wrappers()) || class_exists(self::scheme2class($scheme))) |
|
1106 | + if (in_array($scheme, stream_get_wrappers()) || class_exists(self::scheme2class($scheme))) |
|
1108 | 1107 | { |
1109 | 1108 | self::$wrappers[] = $scheme; |
1110 | 1109 | } |
1111 | 1110 | else |
1112 | 1111 | { |
1113 | - trigger_error("Can't load stream-wrapper for scheme '$scheme'!",E_USER_WARNING); |
|
1112 | + trigger_error("Can't load stream-wrapper for scheme '$scheme'!", E_USER_WARNING); |
|
1114 | 1113 | return false; |
1115 | 1114 | } |
1116 | 1115 | } |
@@ -1144,10 +1143,10 @@ discard block |
||
1144 | 1143 | static function scheme2class($scheme) |
1145 | 1144 | { |
1146 | 1145 | list($app, $app_scheme) = explode('.', $scheme); |
1147 | - foreach(array( |
|
1148 | - empty($app_scheme) ? 'EGroupware\\Api\\Vfs\\'.ucfirst($scheme).'\\StreamWrapper' : // streamwrapper in Api\Vfs |
|
1146 | + foreach (array( |
|
1147 | + empty($app_scheme) ? 'EGroupware\\Api\\Vfs\\'.ucfirst($scheme).'\\StreamWrapper' : // streamwrapper in Api\Vfs |
|
1149 | 1148 | 'EGroupware\\'.ucfirst($app).'\\Vfs\\'.ucfirst($app_scheme).'\\StreamWrapper', // streamwrapper in $app\Vfs |
1150 | - str_replace('.','_',$scheme).'_stream_wrapper', // old (flat) name |
|
1149 | + str_replace('.', '_', $scheme).'_stream_wrapper', // old (flat) name |
|
1151 | 1150 | ) as $class) |
1152 | 1151 | { |
1153 | 1152 | //error_log(__METHOD__."('$scheme') class_exists('$class')=".array2string(class_exists($class))); |
@@ -1162,7 +1161,7 @@ discard block |
||
1162 | 1161 | * @param string $only_remove_scheme =self::SCHEME if given only that scheme get's removed |
1163 | 1162 | * @return string path without training slash |
1164 | 1163 | */ |
1165 | - static protected function get_path($path,$only_remove_scheme=self::SCHEME) |
|
1164 | + static protected function get_path($path, $only_remove_scheme = self::SCHEME) |
|
1166 | 1165 | { |
1167 | 1166 | if ($path[0] != '/' && (!$only_remove_scheme || Vfs::parse_url($path, PHP_URL_SCHEME) == $only_remove_scheme)) |
1168 | 1167 | { |
@@ -1173,7 +1172,7 @@ discard block |
||
1173 | 1172 | { |
1174 | 1173 | while (mb_substr($path, -1) == '/' && $path != '/' && ($path[0] == '/' || Vfs::parse_url($path, PHP_URL_PATH) != '/')) |
1175 | 1174 | { |
1176 | - $path = mb_substr($path,0,-1); |
|
1175 | + $path = mb_substr($path, 0, -1); |
|
1177 | 1176 | } |
1178 | 1177 | } |
1179 | 1178 | return $path; |
@@ -1188,7 +1187,7 @@ discard block |
||
1188 | 1187 | static function url_is_readonly($url) |
1189 | 1188 | { |
1190 | 1189 | static $cache = array(); |
1191 | - $ret =& $cache[$url]; |
|
1190 | + $ret = & $cache[$url]; |
|
1192 | 1191 | if (!isset($ret)) |
1193 | 1192 | { |
1194 | 1193 | $matches = null; |
@@ -1210,9 +1209,9 @@ discard block |
||
1210 | 1209 | * @param boolean $clear_fstab =false true clear current fstab, false (default) only add given mount |
1211 | 1210 | * @return array|boolean array with fstab, if called without parameter or true on successful mount |
1212 | 1211 | */ |
1213 | - static function mount($url=null,$path=null,$check_url=null,$persitent_mount=true,$clear_fstab=false) |
|
1212 | + static function mount($url = null, $path = null, $check_url = null, $persitent_mount = true, $clear_fstab = false) |
|
1214 | 1213 | { |
1215 | - if (is_null($check_url)) $check_url = strpos($url,'$') === false; |
|
1214 | + if (is_null($check_url)) $check_url = strpos($url, '$') === false; |
|
1216 | 1215 | |
1217 | 1216 | if (!isset($GLOBALS['egw_info']['server']['vfs_fstab'])) // happens eg. in setup |
1218 | 1217 | { |
@@ -1238,7 +1237,7 @@ discard block |
||
1238 | 1237 | if (!Vfs::$is_root) |
1239 | 1238 | { |
1240 | 1239 | if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!'); |
1241 | - return false; // only root can mount |
|
1240 | + return false; // only root can mount |
|
1242 | 1241 | } |
1243 | 1242 | if ($clear_fstab) |
1244 | 1243 | { |
@@ -1247,14 +1246,14 @@ discard block |
||
1247 | 1246 | if (isset(self::$fstab[$path]) && self::$fstab[$path] === $url) |
1248 | 1247 | { |
1249 | 1248 | if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') already mounted.'); |
1250 | - return true; // already mounted |
|
1249 | + return true; // already mounted |
|
1251 | 1250 | } |
1252 | - self::load_wrapper(Vfs::parse_url($url,PHP_URL_SCHEME)); |
|
1251 | + self::load_wrapper(Vfs::parse_url($url, PHP_URL_SCHEME)); |
|
1253 | 1252 | |
1254 | 1253 | if ($check_url && (!file_exists($url) || opendir($url) === false)) |
1255 | 1254 | { |
1256 | 1255 | if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') url does NOT exist!'); |
1257 | - return false; // url does not exist |
|
1256 | + return false; // url does not exist |
|
1258 | 1257 | } |
1259 | 1258 | self::$fstab[$path] = $url; |
1260 | 1259 | |
@@ -1265,10 +1264,10 @@ discard block |
||
1265 | 1264 | |
1266 | 1265 | if ($persitent_mount) |
1267 | 1266 | { |
1268 | - Api\Config::save_value('vfs_fstab',self::$fstab,'phpgwapi'); |
|
1267 | + Api\Config::save_value('vfs_fstab', self::$fstab, 'phpgwapi'); |
|
1269 | 1268 | $GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab; |
1270 | 1269 | // invalidate session cache |
1271 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
1270 | + if (method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
1272 | 1271 | { |
1273 | 1272 | $GLOBALS['egw']->invalidate_session_cache(); |
1274 | 1273 | } |
@@ -1287,19 +1286,19 @@ discard block |
||
1287 | 1286 | if (!Vfs::$is_root) |
1288 | 1287 | { |
1289 | 1288 | if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!'); |
1290 | - return false; // only root can mount |
|
1289 | + return false; // only root can mount |
|
1291 | 1290 | } |
1292 | - if (!isset(self::$fstab[$path]) && ($path = array_search($path,self::$fstab)) === false) |
|
1291 | + if (!isset(self::$fstab[$path]) && ($path = array_search($path, self::$fstab)) === false) |
|
1293 | 1292 | { |
1294 | 1293 | if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).') NOT mounted!'); |
1295 | - return false; // $path not mounted |
|
1294 | + return false; // $path not mounted |
|
1296 | 1295 | } |
1297 | 1296 | unset(self::$fstab[$path]); |
1298 | 1297 | |
1299 | - Api\Config::save_value('vfs_fstab',self::$fstab,'phpgwapi'); |
|
1298 | + Api\Config::save_value('vfs_fstab', self::$fstab, 'phpgwapi'); |
|
1300 | 1299 | $GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab; |
1301 | 1300 | // invalidate session cache |
1302 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
1301 | + if (method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
1303 | 1302 | { |
1304 | 1303 | $GLOBALS['egw']->invalidate_session_cache(); |
1305 | 1304 | } |
@@ -1313,7 +1312,7 @@ discard block |
||
1313 | 1312 | */ |
1314 | 1313 | static function init_static() |
1315 | 1314 | { |
1316 | - stream_register_wrapper(self::SCHEME,__CLASS__); |
|
1315 | + stream_register_wrapper(self::SCHEME, __CLASS__); |
|
1317 | 1316 | |
1318 | 1317 | if (($fstab = $GLOBALS['egw_info']['server']['vfs_fstab']) && is_array($fstab) && count($fstab)) |
1319 | 1318 | { |
@@ -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 | - function unlink ( $path ); |
|
146 | + 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 | - function rename ( $path_from, $path_to ); |
|
160 | + 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 | - function mkdir ( $path, $mode, $options ); |
|
173 | + 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 | - function rmdir ( $path, $options ); |
|
185 | + 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 | - function url_stat ( $path, $flags ); |
|
221 | + 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 | { |
@@ -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 |
@@ -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,117 +110,117 @@ 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) { |
|
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 | 224 | try { |
225 | 225 | if (!rename($source, $dest)) { |
226 | 226 | return "500 Internal server error"; |
@@ -229,51 +229,51 @@ discard block |
||
229 | 229 | catch (Exception\ProtectedDirectory $e) { |
230 | 230 | return "403 Forbidden: ".$e->getMessage(); |
231 | 231 | } |
232 | - } else { |
|
233 | - if (is_dir($source) && $options['depth'] == 'infinity') { |
|
234 | - $files = Vfs::find($source,array('depth' => true,'url' => true)); // depth=true: return dirs first, url=true: allow urls! |
|
235 | - } else { |
|
236 | - $files = array($source); |
|
237 | - } |
|
238 | - |
|
239 | - if (!is_array($files) || empty($files)) { |
|
240 | - return "500 Internal server error"; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - foreach ($files as $file) { |
|
245 | - if (is_dir($file)) { |
|
246 | - $file = $this->_slashify($file); |
|
247 | - } |
|
248 | - |
|
249 | - $destfile = str_replace($source, $dest, $file); |
|
250 | - |
|
251 | - if (is_dir($file)) { |
|
252 | - if (!is_dir($destfile)) { |
|
253 | - // TODO "mkdir -p" here? (only natively supported by PHP 5) |
|
254 | - if (!@mkdir($destfile)) { |
|
255 | - return "409 Conflict"; |
|
256 | - } |
|
257 | - } |
|
258 | - } else { |
|
259 | - if (!@copy($file, $destfile)) { |
|
260 | - return "409 Conflict"; |
|
261 | - } |
|
262 | - } |
|
263 | - } |
|
264 | - } |
|
265 | - // adding Location header as shown in example in rfc2518 section 8.9.5 |
|
232 | + } else { |
|
233 | + if (is_dir($source) && $options['depth'] == 'infinity') { |
|
234 | + $files = Vfs::find($source,array('depth' => true,'url' => true)); // depth=true: return dirs first, url=true: allow urls! |
|
235 | + } else { |
|
236 | + $files = array($source); |
|
237 | + } |
|
238 | + |
|
239 | + if (!is_array($files) || empty($files)) { |
|
240 | + return "500 Internal server error"; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + foreach ($files as $file) { |
|
245 | + if (is_dir($file)) { |
|
246 | + $file = $this->_slashify($file); |
|
247 | + } |
|
248 | + |
|
249 | + $destfile = str_replace($source, $dest, $file); |
|
250 | + |
|
251 | + if (is_dir($file)) { |
|
252 | + if (!is_dir($destfile)) { |
|
253 | + // TODO "mkdir -p" here? (only natively supported by PHP 5) |
|
254 | + if (!@mkdir($destfile)) { |
|
255 | + return "409 Conflict"; |
|
256 | + } |
|
257 | + } |
|
258 | + } else { |
|
259 | + if (!@copy($file, $destfile)) { |
|
260 | + return "409 Conflict"; |
|
261 | + } |
|
262 | + } |
|
263 | + } |
|
264 | + } |
|
265 | + // adding Location header as shown in example in rfc2518 section 8.9.5 |
|
266 | 266 | header('Location: '.$this->base_uri.$options['dest']); |
267 | 267 | |
268 | - return ($new && !$existing_col) ? "201 Created" : "204 No Content"; |
|
269 | - } |
|
268 | + return ($new && !$existing_col) ? "201 Created" : "204 No Content"; |
|
269 | + } |
|
270 | 270 | |
271 | - /** |
|
272 | - * Get properties for a single file/resource |
|
273 | - * |
|
274 | - * @param string $_path resource path |
|
275 | - * @return array resource properties |
|
276 | - */ |
|
271 | + /** |
|
272 | + * Get properties for a single file/resource |
|
273 | + * |
|
274 | + * @param string $_path resource path |
|
275 | + * @return array resource properties |
|
276 | + */ |
|
277 | 277 | function fileinfo($_path) |
278 | 278 | { |
279 | 279 | // internally we require some url-encoding, as vfs_stream_wrapper uses URL's internally |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | $info['props'][] = self::mkprop ('creationdate', filectime($fspath)); |
302 | 302 | $info['props'][] = self::mkprop ('getlastmodified', filemtime($fspath)); |
303 | 303 | |
304 | - // Microsoft extensions: last access time and 'hidden' status |
|
305 | - $info["props"][] = self::mkprop("lastaccessed", fileatime($fspath)); |
|
306 | - $info["props"][] = self::mkprop("ishidden", Vfs::is_hidden($fspath)); |
|
304 | + // Microsoft extensions: last access time and 'hidden' status |
|
305 | + $info["props"][] = self::mkprop("lastaccessed", fileatime($fspath)); |
|
306 | + $info["props"][] = self::mkprop("ishidden", Vfs::is_hidden($fspath)); |
|
307 | 307 | |
308 | 308 | // type and size (caller already made sure that path exists) |
309 | 309 | if (is_dir($fspath)) { |
@@ -441,38 +441,38 @@ discard block |
||
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
444 | - * Used eg. by get |
|
445 | - * |
|
446 | - * @todo replace all calls to _mimetype with Vfs::mime_content_type() |
|
447 | - * @param string $path |
|
448 | - * @return string |
|
449 | - */ |
|
444 | + * Used eg. by get |
|
445 | + * |
|
446 | + * @todo replace all calls to _mimetype with Vfs::mime_content_type() |
|
447 | + * @param string $path |
|
448 | + * @return string |
|
449 | + */ |
|
450 | 450 | function _mimetype($path) |
451 | 451 | { |
452 | 452 | return Vfs::mime_content_type($path); |
453 | 453 | } |
454 | 454 | |
455 | - /** |
|
456 | - * Check if path is readable by current user |
|
457 | - * |
|
458 | - * @param string $fspath |
|
459 | - * @return boolean |
|
460 | - */ |
|
461 | - function _is_readable($fspath) |
|
462 | - { |
|
463 | - return Vfs::is_readable($fspath); |
|
464 | - } |
|
465 | - |
|
466 | - /** |
|
467 | - * Check if path is writable by current user |
|
468 | - * |
|
469 | - * @param string $fspath |
|
470 | - * @return boolean |
|
471 | - */ |
|
472 | - function _is_writable($fspath) |
|
473 | - { |
|
474 | - return Vfs::is_writable($fspath); |
|
475 | - } |
|
455 | + /** |
|
456 | + * Check if path is readable by current user |
|
457 | + * |
|
458 | + * @param string $fspath |
|
459 | + * @return boolean |
|
460 | + */ |
|
461 | + function _is_readable($fspath) |
|
462 | + { |
|
463 | + return Vfs::is_readable($fspath); |
|
464 | + } |
|
465 | + |
|
466 | + /** |
|
467 | + * Check if path is writable by current user |
|
468 | + * |
|
469 | + * @param string $fspath |
|
470 | + * @return boolean |
|
471 | + */ |
|
472 | + function _is_writable($fspath) |
|
473 | + { |
|
474 | + return Vfs::is_writable($fspath); |
|
475 | + } |
|
476 | 476 | |
477 | 477 | /** |
478 | 478 | * PROPPATCH method handler |
@@ -615,13 +615,13 @@ discard block |
||
615 | 615 | * @param string directory path |
616 | 616 | * @return void function has to handle HTTP response itself |
617 | 617 | */ |
618 | - function GetDir($fspath, &$options) |
|
619 | - { |
|
618 | + function GetDir($fspath, &$options) |
|
619 | + { |
|
620 | 620 | // add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv) |
621 | 621 | header('Content-type: text/html; charset='.Api\Translation::charset()); |
622 | 622 | |
623 | 623 | parent::GetDir($fspath, $options); |
624 | - } |
|
624 | + } |
|
625 | 625 | |
626 | 626 | private $force_download = false; |
627 | 627 |
@@ -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,76 +205,104 @@ 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) { |
|
253 | + if ($del) |
|
254 | + { |
|
224 | 255 | try { |
225 | - if (!rename($source, $dest)) { |
|
256 | + if (!rename($source, $dest)) |
|
257 | + { |
|
226 | 258 | return "500 Internal server error"; |
227 | 259 | } |
228 | 260 | } |
229 | 261 | catch (Exception\ProtectedDirectory $e) { |
230 | 262 | return "403 Forbidden: ".$e->getMessage(); |
231 | 263 | } |
232 | - } else { |
|
233 | - if (is_dir($source) && $options['depth'] == 'infinity') { |
|
264 | + } |
|
265 | + else |
|
266 | + { |
|
267 | + if (is_dir($source) && $options['depth'] == 'infinity') |
|
268 | + { |
|
234 | 269 | $files = Vfs::find($source,array('depth' => true,'url' => true)); // depth=true: return dirs first, url=true: allow urls! |
235 | - } else { |
|
270 | + } |
|
271 | + else |
|
272 | + { |
|
236 | 273 | $files = array($source); |
237 | 274 | } |
238 | 275 | |
239 | - if (!is_array($files) || empty($files)) { |
|
276 | + if (!is_array($files) || empty($files)) |
|
277 | + { |
|
240 | 278 | return "500 Internal server error"; |
241 | 279 | } |
242 | 280 | |
243 | 281 | |
244 | - foreach ($files as $file) { |
|
245 | - if (is_dir($file)) { |
|
282 | + foreach ($files as $file) |
|
283 | + { |
|
284 | + if (is_dir($file)) |
|
285 | + { |
|
246 | 286 | $file = $this->_slashify($file); |
247 | 287 | } |
248 | 288 | |
249 | 289 | $destfile = str_replace($source, $dest, $file); |
250 | 290 | |
251 | - if (is_dir($file)) { |
|
252 | - if (!is_dir($destfile)) { |
|
291 | + if (is_dir($file)) |
|
292 | + { |
|
293 | + if (!is_dir($destfile)) |
|
294 | + { |
|
253 | 295 | // TODO "mkdir -p" here? (only natively supported by PHP 5) |
254 | - if (!@mkdir($destfile)) { |
|
296 | + if (!@mkdir($destfile)) |
|
297 | + { |
|
255 | 298 | return "409 Conflict"; |
256 | 299 | } |
257 | 300 | } |
258 | - } else { |
|
259 | - if (!@copy($file, $destfile)) { |
|
301 | + } |
|
302 | + else |
|
303 | + { |
|
304 | + if (!@copy($file, $destfile)) |
|
305 | + { |
|
260 | 306 | return "409 Conflict"; |
261 | 307 | } |
262 | 308 | } |
@@ -306,17 +352,23 @@ discard block |
||
306 | 352 | $info["props"][] = self::mkprop("ishidden", Vfs::is_hidden($fspath)); |
307 | 353 | |
308 | 354 | // type and size (caller already made sure that path exists) |
309 | - if (is_dir($fspath)) { |
|
355 | + if (is_dir($fspath)) |
|
356 | + { |
|
310 | 357 | // directory (WebDAV collection) |
311 | 358 | $info['props'][] = self::mkprop ('resourcetype', array( |
312 | 359 | self::mkprop('collection', ''))); |
313 | 360 | $info['props'][] = self::mkprop ('getcontenttype', 'httpd/unix-directory'); |
314 | - } else { |
|
361 | + } |
|
362 | + else |
|
363 | + { |
|
315 | 364 | // plain file (WebDAV resource) |
316 | 365 | $info['props'][] = self::mkprop ('resourcetype', ''); |
317 | - if (Vfs::is_readable($path)) { |
|
366 | + if (Vfs::is_readable($path)) |
|
367 | + { |
|
318 | 368 | $info['props'][] = self::mkprop ('getcontenttype', Vfs::mime_content_type($path)); |
319 | - } else { |
|
369 | + } |
|
370 | + else |
|
371 | + { |
|
320 | 372 | error_log(__METHOD__."($path) $fspath is not readable!"); |
321 | 373 | $info['props'][] = self::mkprop ('getcontenttype', 'application/x-non-readable'); |
322 | 374 | } |
@@ -388,7 +440,10 @@ discard block |
||
388 | 440 | continue; |
389 | 441 | } |
390 | 442 | $_path = $info['path']; |
391 | - if (!$n && $info['path'] != '/' && substr($info['path'],-1) == '/') $_path = substr($info['path'],0,-1); |
|
443 | + if (!$n && $info['path'] != '/' && substr($info['path'],-1) == '/') |
|
444 | + { |
|
445 | + $_path = substr($info['path'],0,-1); |
|
446 | + } |
|
392 | 447 | |
393 | 448 | // need to encode path again, as $info['path'] is NOT encoded, but Vfs::(stat|propfind) require it |
394 | 449 | // otherwise pathes containing url special chars like ? or # will not stat |
@@ -427,16 +482,22 @@ discard block |
||
427 | 482 | $fileprops =& $files['files'][$path2n[$path]]['props']; |
428 | 483 | foreach($props as $prop) |
429 | 484 | { |
430 | - if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'][0] == '#') // eGW's customfields |
|
485 | + if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'][0] == '#') |
|
486 | + { |
|
487 | + // eGW's customfields |
|
431 | 488 | { |
432 | 489 | $prop['ns'] .= 'customfields/'; |
490 | + } |
|
433 | 491 | $prop['name'] = substr($prop['name'],1); |
434 | 492 | } |
435 | 493 | $fileprops[] = $prop; |
436 | 494 | } |
437 | 495 | } |
438 | 496 | } |
439 | - if ($this->debug) error_log(__METHOD__."() props=".array2string($files['files'])); |
|
497 | + if ($this->debug) |
|
498 | + { |
|
499 | + error_log(__METHOD__."() props=".array2string($files['files'])); |
|
500 | + } |
|
440 | 501 | return true; |
441 | 502 | } |
442 | 503 | |
@@ -488,7 +549,8 @@ discard block |
||
488 | 549 | { |
489 | 550 | $path = Api\Translation::convert($options['path'],'utf-8'); |
490 | 551 | |
491 | - foreach ($options['props'] as $key => $prop) { |
|
552 | + foreach ($options['props'] as $key => $prop) |
|
553 | + { |
|
492 | 554 | $attributes = array(); |
493 | 555 | switch($prop['ns']) |
494 | 556 | { |
@@ -505,7 +567,10 @@ discard block |
||
505 | 567 | //$attributes['created'] = strtotime($prop['val']); |
506 | 568 | //break; |
507 | 569 | default: |
508 | - if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
570 | + if (!Vfs::proppatch($path,array($prop))) |
|
571 | + { |
|
572 | + $options['props'][$key]['status'] = '403 Forbidden'; |
|
573 | + } |
|
509 | 574 | break; |
510 | 575 | } |
511 | 576 | break; |
@@ -534,7 +599,10 @@ discard block |
||
534 | 599 | case 'Win32LastAccessTime': |
535 | 600 | case 'Win32FileAttributes': // not sure what that is, it was always "00000000" |
536 | 601 | default: |
537 | - if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
602 | + if (!Vfs::proppatch($path,array($prop))) |
|
603 | + { |
|
604 | + $options['props'][$key]['status'] = '403 Forbidden'; |
|
605 | + } |
|
538 | 606 | break; |
539 | 607 | } |
540 | 608 | break; |
@@ -544,15 +612,24 @@ discard block |
||
544 | 612 | $prop['name'] = '#'.$prop['name']; |
545 | 613 | // fall through |
546 | 614 | default: |
547 | - if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
615 | + if (!Vfs::proppatch($path,array($prop))) |
|
616 | + { |
|
617 | + $options['props'][$key]['status'] = '403 Forbidden'; |
|
618 | + } |
|
548 | 619 | break; |
549 | 620 | } |
550 | - if ($this->debug) $props[] = '('.$prop['ns'].')'.$prop['name'].'='.$prop['val']; |
|
621 | + if ($this->debug) |
|
622 | + { |
|
623 | + $props[] = '('.$prop['ns'].')'.$prop['name'].'='.$prop['val']; |
|
624 | + } |
|
551 | 625 | } |
552 | 626 | if ($this->debug) |
553 | 627 | { |
554 | 628 | error_log(__METHOD__.": path=$options[path], props=".implode(', ',$props)); |
555 | - if ($attributes) error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n",' ',print_r($attributes,true))); |
|
629 | + if ($attributes) |
|
630 | + { |
|
631 | + error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n",' ',print_r($attributes,true))); |
|
632 | + } |
|
556 | 633 | } |
557 | 634 | |
558 | 635 | return ''; // this is as the filesystem example handler does it, no true or false ... |
@@ -566,7 +643,10 @@ discard block |
||
566 | 643 | */ |
567 | 644 | function LOCK(&$options) |
568 | 645 | { |
569 | - if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')'); |
|
646 | + if ($this->debug) |
|
647 | + { |
|
648 | + error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')'); |
|
649 | + } |
|
570 | 650 | // TODO recursive locks on directories not supported yet |
571 | 651 | if (is_dir($this->base . $options['path']) && !empty($options['depth'])) |
572 | 652 | { |
@@ -592,7 +672,10 @@ discard block |
||
592 | 672 | */ |
593 | 673 | function UNLOCK(&$options) |
594 | 674 | { |
595 | - if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')'); |
|
675 | + if ($this->debug) |
|
676 | + { |
|
677 | + error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')'); |
|
678 | + } |
|
596 | 679 | return Vfs::unlock($options['path'],$options['token']) ? '204 No Content' : '409 Conflict'; |
597 | 680 | } |
598 | 681 |
@@ -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)) { |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | } |
232 | 232 | } else { |
233 | 233 | if (is_dir($source) && $options['depth'] == 'infinity') { |
234 | - $files = Vfs::find($source,array('depth' => true,'url' => true)); // depth=true: return dirs first, url=true: allow urls! |
|
234 | + $files = Vfs::find($source, array('depth' => true, 'url' => true)); // depth=true: return dirs first, url=true: allow urls! |
|
235 | 235 | } else { |
236 | 236 | $files = array($source); |
237 | 237 | } |
@@ -277,16 +277,16 @@ discard block |
||
277 | 277 | function fileinfo($_path) |
278 | 278 | { |
279 | 279 | // internally we require some url-encoding, as vfs_stream_wrapper uses URL's internally |
280 | - $path = str_replace(array('#','?'),array('%23','%3F'),$_path); |
|
280 | + $path = str_replace(array('#', '?'), array('%23', '%3F'), $_path); |
|
281 | 281 | |
282 | 282 | //error_log(__METHOD__."($path)"); |
283 | 283 | // map URI path to filesystem path |
284 | - $fspath = $this->base . $path; |
|
284 | + $fspath = $this->base.$path; |
|
285 | 285 | |
286 | 286 | // create result array |
287 | 287 | $info = array(); |
288 | 288 | // TODO remove slash append code when base class is able to do it itself |
289 | - $info['path'] = is_dir($fspath) ? $this->_slashify($path) : $path; |
|
289 | + $info['path'] = is_dir($fspath) ? $this->_slashify($path) : $path; |
|
290 | 290 | |
291 | 291 | // remove all urlencoding we need internally in EGw, HTTP_WebDAV_Server will add it's own! |
292 | 292 | // rawurldecode does NOT touch + |
@@ -295,32 +295,32 @@ discard block |
||
295 | 295 | $info['props'] = array(); |
296 | 296 | |
297 | 297 | // no special beautified displayname here ... |
298 | - $info['props'][] = self::mkprop ('displayname', Vfs::basename(self::_unslashify($info['path']))); |
|
298 | + $info['props'][] = self::mkprop('displayname', Vfs::basename(self::_unslashify($info['path']))); |
|
299 | 299 | |
300 | 300 | // creation and modification time |
301 | - $info['props'][] = self::mkprop ('creationdate', filectime($fspath)); |
|
302 | - $info['props'][] = self::mkprop ('getlastmodified', filemtime($fspath)); |
|
301 | + $info['props'][] = self::mkprop('creationdate', filectime($fspath)); |
|
302 | + $info['props'][] = self::mkprop('getlastmodified', filemtime($fspath)); |
|
303 | 303 | |
304 | 304 | // Microsoft extensions: last access time and 'hidden' status |
305 | - $info["props"][] = self::mkprop("lastaccessed", fileatime($fspath)); |
|
306 | - $info["props"][] = self::mkprop("ishidden", Vfs::is_hidden($fspath)); |
|
305 | + $info["props"][] = self::mkprop("lastaccessed", fileatime($fspath)); |
|
306 | + $info["props"][] = self::mkprop("ishidden", Vfs::is_hidden($fspath)); |
|
307 | 307 | |
308 | 308 | // type and size (caller already made sure that path exists) |
309 | 309 | if (is_dir($fspath)) { |
310 | 310 | // directory (WebDAV collection) |
311 | - $info['props'][] = self::mkprop ('resourcetype', array( |
|
311 | + $info['props'][] = self::mkprop('resourcetype', array( |
|
312 | 312 | self::mkprop('collection', ''))); |
313 | - $info['props'][] = self::mkprop ('getcontenttype', 'httpd/unix-directory'); |
|
313 | + $info['props'][] = self::mkprop('getcontenttype', 'httpd/unix-directory'); |
|
314 | 314 | } else { |
315 | 315 | // plain file (WebDAV resource) |
316 | - $info['props'][] = self::mkprop ('resourcetype', ''); |
|
316 | + $info['props'][] = self::mkprop('resourcetype', ''); |
|
317 | 317 | if (Vfs::is_readable($path)) { |
318 | - $info['props'][] = self::mkprop ('getcontenttype', Vfs::mime_content_type($path)); |
|
318 | + $info['props'][] = self::mkprop('getcontenttype', Vfs::mime_content_type($path)); |
|
319 | 319 | } else { |
320 | 320 | error_log(__METHOD__."($path) $fspath is not readable!"); |
321 | - $info['props'][] = self::mkprop ('getcontenttype', 'application/x-non-readable'); |
|
321 | + $info['props'][] = self::mkprop('getcontenttype', 'application/x-non-readable'); |
|
322 | 322 | } |
323 | - $info['props'][] = self::mkprop ('getcontentlength', filesize($fspath)); |
|
323 | + $info['props'][] = self::mkprop('getcontentlength', filesize($fspath)); |
|
324 | 324 | } |
325 | 325 | // generate etag from inode (sqlfs: fs_id), modification time and size |
326 | 326 | $stat = stat($fspath); |
@@ -374,21 +374,21 @@ discard block |
||
374 | 374 | */ |
375 | 375 | function PROPFIND(&$options, &$files) |
376 | 376 | { |
377 | - if (!parent::PROPFIND($options,$files)) |
|
377 | + if (!parent::PROPFIND($options, $files)) |
|
378 | 378 | { |
379 | 379 | return false; |
380 | 380 | } |
381 | 381 | $path2n = array(); |
382 | - foreach($files['files'] as $n => $info) |
|
382 | + foreach ($files['files'] as $n => $info) |
|
383 | 383 | { |
384 | 384 | // do NOT report /clientsync/.favorites/, as it fails |
385 | - if (strpos($info['path'],'/clientsync/.favorites/') === 0) |
|
385 | + if (strpos($info['path'], '/clientsync/.favorites/') === 0) |
|
386 | 386 | { |
387 | 387 | unset($files['files'][$n]); |
388 | 388 | continue; |
389 | 389 | } |
390 | 390 | $_path = $info['path']; |
391 | - if (!$n && $info['path'] != '/' && substr($info['path'],-1) == '/') $_path = substr($info['path'],0,-1); |
|
391 | + if (!$n && $info['path'] != '/' && substr($info['path'], -1) == '/') $_path = substr($info['path'], 0, -1); |
|
392 | 392 | |
393 | 393 | // need to encode path again, as $info['path'] is NOT encoded, but Vfs::(stat|propfind) require it |
394 | 394 | // otherwise pathes containing url special chars like ? or # will not stat |
@@ -398,21 +398,21 @@ discard block |
||
398 | 398 | // adding some properties used instead of regular DAV times |
399 | 399 | if (($stat = Vfs::stat($path))) |
400 | 400 | { |
401 | - $fileprops =& $files['files'][$path2n[$path]]['props']; |
|
402 | - foreach(self::$auto_props as $attr => $props) |
|
401 | + $fileprops = & $files['files'][$path2n[$path]]['props']; |
|
402 | + foreach (self::$auto_props as $attr => $props) |
|
403 | 403 | { |
404 | - switch($attr) |
|
404 | + switch ($attr) |
|
405 | 405 | { |
406 | 406 | case 'ctime': |
407 | 407 | case 'mtime': |
408 | 408 | case 'atime': |
409 | - $value = gmdate('D, d M Y H:i:s T',$stat[$attr]); |
|
409 | + $value = gmdate('D, d M Y H:i:s T', $stat[$attr]); |
|
410 | 410 | break; |
411 | 411 | |
412 | 412 | default: |
413 | 413 | continue 2; |
414 | 414 | } |
415 | - foreach($props as $prop) |
|
415 | + foreach ($props as $prop) |
|
416 | 416 | { |
417 | 417 | $prop['val'] = $value; |
418 | 418 | $fileprops[] = $prop; |
@@ -420,17 +420,17 @@ discard block |
||
420 | 420 | } |
421 | 421 | } |
422 | 422 | } |
423 | - if ($path2n && ($path2props = Vfs::propfind(array_keys($path2n),null))) |
|
423 | + if ($path2n && ($path2props = Vfs::propfind(array_keys($path2n), null))) |
|
424 | 424 | { |
425 | - foreach($path2props as $path => $props) |
|
425 | + foreach ($path2props as $path => $props) |
|
426 | 426 | { |
427 | - $fileprops =& $files['files'][$path2n[$path]]['props']; |
|
428 | - foreach($props as $prop) |
|
427 | + $fileprops = & $files['files'][$path2n[$path]]['props']; |
|
428 | + foreach ($props as $prop) |
|
429 | 429 | { |
430 | 430 | if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'][0] == '#') // eGW's customfields |
431 | 431 | { |
432 | 432 | $prop['ns'] .= 'customfields/'; |
433 | - $prop['name'] = substr($prop['name'],1); |
|
433 | + $prop['name'] = substr($prop['name'], 1); |
|
434 | 434 | } |
435 | 435 | $fileprops[] = $prop; |
436 | 436 | } |
@@ -486,36 +486,36 @@ discard block |
||
486 | 486 | */ |
487 | 487 | function PROPPATCH(&$options) |
488 | 488 | { |
489 | - $path = Api\Translation::convert($options['path'],'utf-8'); |
|
489 | + $path = Api\Translation::convert($options['path'], 'utf-8'); |
|
490 | 490 | |
491 | 491 | foreach ($options['props'] as $key => $prop) { |
492 | 492 | $attributes = array(); |
493 | - switch($prop['ns']) |
|
493 | + switch ($prop['ns']) |
|
494 | 494 | { |
495 | 495 | // allow Webdrive to set creation and modification time |
496 | 496 | case 'http://www.southrivertech.com/': |
497 | - switch($prop['name']) |
|
497 | + switch ($prop['name']) |
|
498 | 498 | { |
499 | 499 | case 'srt_modifiedtime': |
500 | 500 | case 'getlastmodified': |
501 | - Vfs::touch($path,strtotime($prop['val'])); |
|
501 | + Vfs::touch($path, strtotime($prop['val'])); |
|
502 | 502 | break; |
503 | 503 | //case 'srt_creationtime': |
504 | 504 | // no streamwrapper interface / php function to set the ctime currently |
505 | 505 | //$attributes['created'] = strtotime($prop['val']); |
506 | 506 | //break; |
507 | 507 | default: |
508 | - if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
508 | + if (!Vfs::proppatch($path, array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
509 | 509 | break; |
510 | 510 | } |
511 | 511 | break; |
512 | 512 | |
513 | 513 | case 'DAV:': |
514 | - switch($prop['name']) |
|
514 | + switch ($prop['name']) |
|
515 | 515 | { |
516 | 516 | // allow netdrive to change the modification time |
517 | 517 | case 'getlastmodified': |
518 | - Vfs::touch($path,strtotime($prop['val'])); |
|
518 | + Vfs::touch($path, strtotime($prop['val'])); |
|
519 | 519 | break; |
520 | 520 | // not sure why, the filesystem example of the WebDAV class does it ... |
521 | 521 | default: |
@@ -525,16 +525,16 @@ discard block |
||
525 | 525 | break; |
526 | 526 | |
527 | 527 | case 'urn:schemas-microsoft-com:': |
528 | - switch($prop['name']) |
|
528 | + switch ($prop['name']) |
|
529 | 529 | { |
530 | 530 | case 'Win32LastModifiedTime': |
531 | - Vfs::touch($path,strtotime($prop['val'])); |
|
531 | + Vfs::touch($path, strtotime($prop['val'])); |
|
532 | 532 | break; |
533 | 533 | case 'Win32CreationTime': // eg. "Wed, 14 Sep 2011 15:48:26 GMT" |
534 | 534 | case 'Win32LastAccessTime': |
535 | 535 | case 'Win32FileAttributes': // not sure what that is, it was always "00000000" |
536 | 536 | default: |
537 | - if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
537 | + if (!Vfs::proppatch($path, array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
538 | 538 | break; |
539 | 539 | } |
540 | 540 | break; |
@@ -544,18 +544,18 @@ discard block |
||
544 | 544 | $prop['name'] = '#'.$prop['name']; |
545 | 545 | // fall through |
546 | 546 | default: |
547 | - if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
547 | + if (!Vfs::proppatch($path, array($prop))) $options['props'][$key]['status'] = '403 Forbidden'; |
|
548 | 548 | break; |
549 | 549 | } |
550 | 550 | if ($this->debug) $props[] = '('.$prop['ns'].')'.$prop['name'].'='.$prop['val']; |
551 | 551 | } |
552 | 552 | if ($this->debug) |
553 | 553 | { |
554 | - error_log(__METHOD__.": path=$options[path], props=".implode(', ',$props)); |
|
555 | - if ($attributes) error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n",' ',print_r($attributes,true))); |
|
554 | + error_log(__METHOD__.": path=$options[path], props=".implode(', ', $props)); |
|
555 | + if ($attributes) error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n", ' ', print_r($attributes, true))); |
|
556 | 556 | } |
557 | 557 | |
558 | - return ''; // this is as the filesystem example handler does it, no true or false ... |
|
558 | + return ''; // this is as the filesystem example handler does it, no true or false ... |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -566,18 +566,18 @@ discard block |
||
566 | 566 | */ |
567 | 567 | function LOCK(&$options) |
568 | 568 | { |
569 | - if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')'); |
|
569 | + if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n", ' '), '', print_r($options, true)).')'); |
|
570 | 570 | // TODO recursive locks on directories not supported yet |
571 | - if (is_dir($this->base . $options['path']) && !empty($options['depth'])) |
|
571 | + if (is_dir($this->base.$options['path']) && !empty($options['depth'])) |
|
572 | 572 | { |
573 | 573 | return '409 Conflict'; |
574 | 574 | } |
575 | - $options['timeout'] = time()+300; // 5min. hardcoded |
|
575 | + $options['timeout'] = time() + 300; // 5min. hardcoded |
|
576 | 576 | |
577 | 577 | // dont know why, but HTTP_WebDAV_Server passes the owner in D:href tags, which get's passed unchanged to checkLock/PROPFIND |
578 | 578 | // that's wrong according to the standard and cadaver does not show it on discover --> strip_tags removes eventual tags |
579 | - if (($ret = Vfs::lock($options['path'],$options['locktoken'],$options['timeout'],strip_tags($options['owner']), |
|
580 | - $options['scope'],$options['type'],isset($options['update']))) && !isset($options['update'])) |
|
579 | + if (($ret = Vfs::lock($options['path'], $options['locktoken'], $options['timeout'], strip_tags($options['owner']), |
|
580 | + $options['scope'], $options['type'], isset($options['update']))) && !isset($options['update'])) |
|
581 | 581 | { |
582 | 582 | return $ret ? '200 OK' : '409 Conflict'; |
583 | 583 | } |
@@ -592,8 +592,8 @@ discard block |
||
592 | 592 | */ |
593 | 593 | function UNLOCK(&$options) |
594 | 594 | { |
595 | - if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')'); |
|
596 | - return Vfs::unlock($options['path'],$options['token']) ? '204 No Content' : '409 Conflict'; |
|
595 | + if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n", ' '), '', print_r($options, true)).')'); |
|
596 | + return Vfs::unlock($options['path'], $options['token']) ? '204 No Content' : '409 Conflict'; |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
@@ -632,9 +632,9 @@ discard block |
||
632 | 632 | */ |
633 | 633 | function __construct() |
634 | 634 | { |
635 | - if ($_SERVER['REQUEST_METHOD'] == 'GET' && (($this->force_download = strpos($_SERVER['REQUEST_URI'],'?download')) !== false)) |
|
635 | + if ($_SERVER['REQUEST_METHOD'] == 'GET' && (($this->force_download = strpos($_SERVER['REQUEST_URI'], '?download')) !== false)) |
|
636 | 636 | { |
637 | - $_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'],0,$this->force_download); |
|
637 | + $_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], 0, $this->force_download); |
|
638 | 638 | } |
639 | 639 | parent::__construct(); |
640 | 640 | } |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | */ |
650 | 650 | function GET(&$options) |
651 | 651 | { |
652 | - if (is_dir($this->base . $options["path"])) |
|
652 | + if (is_dir($this->base.$options["path"])) |
|
653 | 653 | { |
654 | 654 | return $this->autoindex($options); |
655 | 655 | } |
@@ -657,11 +657,11 @@ discard block |
||
657 | 657 | { |
658 | 658 | // mitigate risks of serving javascript or css from our domain |
659 | 659 | Api\Header\Content::safe($options['stream'], $options['path'], $options['mimetype'], $options['size'], false, |
660 | - $this->force_download, true); // true = do not send content-type and content-length header, but modify values |
|
660 | + $this->force_download, true); // true = do not send content-type and content-length header, but modify values |
|
661 | 661 | |
662 | 662 | if (!is_resource($options['stream'])) |
663 | 663 | { |
664 | - $options['data'] =& $options['stream']; |
|
664 | + $options['data'] = & $options['stream']; |
|
665 | 665 | unset($options['stream']); |
666 | 666 | } |
667 | 667 | } |
@@ -680,9 +680,9 @@ discard block |
||
680 | 680 | 'depth' => 1, |
681 | 681 | ); |
682 | 682 | $files = array(); |
683 | - if (($ret = $this->PROPFIND($propfind_options,$files)) !== true) |
|
683 | + if (($ret = $this->PROPFIND($propfind_options, $files)) !== true) |
|
684 | 684 | { |
685 | - return $ret; // no collection |
|
685 | + return $ret; // no collection |
|
686 | 686 | } |
687 | 687 | header('Content-type: text/html; charset='.Api\Translation::charset()); |
688 | 688 | echo "<html>\n<head>\n\t<title>".'EGroupware WebDAV server '.htmlspecialchars($options['path'])."</title>\n"; |
@@ -694,10 +694,10 @@ discard block |
||
694 | 694 | echo '<h1>WebDAV '; |
695 | 695 | list(,$base) = explode(parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH), $this->base_uri, 2); |
696 | 696 | $path = $base; |
697 | - foreach(explode('/',$this->_unslashify($options['path'])) as $n => $name) |
|
697 | + foreach (explode('/', $this->_unslashify($options['path'])) as $n => $name) |
|
698 | 698 | { |
699 | 699 | $path .= ($n != 1 ? '/' : '').$name; |
700 | - echo Api\Html::a_href(htmlspecialchars($name.'/'),$path); |
|
700 | + echo Api\Html::a_href(htmlspecialchars($name.'/'), $path); |
|
701 | 701 | } |
702 | 702 | echo "</h1>\n"; |
703 | 703 | |
@@ -714,18 +714,18 @@ discard block |
||
714 | 714 | ); |
715 | 715 | $n = 0; |
716 | 716 | $collection_props = null; |
717 | - foreach($files['files'] as $file) |
|
717 | + foreach ($files['files'] as $file) |
|
718 | 718 | { |
719 | 719 | if (!isset($collection_props)) |
720 | 720 | { |
721 | 721 | $collection_props = $this->props2array($file['props']); |
722 | 722 | echo '<h3>'.lang('Collection listing').': '.htmlspecialchars($collection_props['DAV:displayname'])."</h3>\n"; |
723 | - continue; // own entry --> displaying properies later |
|
723 | + continue; // own entry --> displaying properies later |
|
724 | 724 | } |
725 | - if(!$n++) |
|
725 | + if (!$n++) |
|
726 | 726 | { |
727 | 727 | echo "<table>\n\t<tr class='th'>\n\t\t<th>#</th>\n\t\t<th>".lang('Name')."</th>"; |
728 | - foreach($props2show as $label) |
|
728 | + foreach ($props2show as $label) |
|
729 | 729 | { |
730 | 730 | echo "\t\t<th>".lang($label)."</th>\n"; |
731 | 731 | } |
@@ -735,9 +735,9 @@ discard block |
||
735 | 735 | //echo $file['path']; _debug_array($props); |
736 | 736 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
737 | 737 | |
738 | - if (substr($file['path'],-1) == '/') |
|
738 | + if (substr($file['path'], -1) == '/') |
|
739 | 739 | { |
740 | - $name = basename(substr($file['path'],0,-1)).'/'; |
|
740 | + $name = basename(substr($file['path'], 0, -1)).'/'; |
|
741 | 741 | } |
742 | 742 | else |
743 | 743 | { |
@@ -745,14 +745,14 @@ discard block |
||
745 | 745 | } |
746 | 746 | |
747 | 747 | echo "\t<tr class='$class'>\n\t\t<td>$n</td>\n\t\t<td>". |
748 | - Api\Html::a_href(htmlspecialchars($name),$base.strtr($file['path'], array( |
|
748 | + Api\Html::a_href(htmlspecialchars($name), $base.strtr($file['path'], array( |
|
749 | 749 | '%' => '%25', |
750 | 750 | '#' => '%23', |
751 | 751 | '?' => '%3F', |
752 | 752 | )))."</td>\n"; |
753 | - foreach($props2show as $prop => $label) |
|
753 | + foreach ($props2show as $prop => $label) |
|
754 | 754 | { |
755 | - echo "\t\t<td>".($prop=='DAV:getlastmodified'&&!empty($props[$prop])?date('Y-m-d H:i:s',$props[$prop]):$props[$prop])."</td>\n"; |
|
755 | + echo "\t\t<td>".($prop == 'DAV:getlastmodified' && !empty($props[$prop]) ? date('Y-m-d H:i:s', $props[$prop]) : $props[$prop])."</td>\n"; |
|
756 | 756 | } |
757 | 757 | echo "\t</tr>\n"; |
758 | 758 | } |
@@ -766,12 +766,12 @@ discard block |
||
766 | 766 | } |
767 | 767 | echo '<h3>'.lang('Properties')."</h3>\n"; |
768 | 768 | echo "<table>\n\t<tr class='th'><th>".lang('Namespace')."</th><th>".lang('Name')."</th><th>".lang('Value')."</th></tr>\n"; |
769 | - foreach($collection_props as $name => $value) |
|
769 | + foreach ($collection_props as $name => $value) |
|
770 | 770 | { |
771 | 771 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
772 | - $parts = explode(':',$name); |
|
772 | + $parts = explode(':', $name); |
|
773 | 773 | $name = array_pop($parts); |
774 | - $ns = implode(':',$parts); |
|
774 | + $ns = implode(':', $parts); |
|
775 | 775 | echo "\t<tr class='$class'>\n\t\t<td>".htmlspecialchars($ns)."</td><td style='white-space: nowrap'>".htmlspecialchars($name)."</td>\n"; |
776 | 776 | echo "\t\t<td>".$value."</td>\n\t</tr>\n"; |
777 | 777 | } |
@@ -814,11 +814,11 @@ discard block |
||
814 | 814 | 'wrap' => 0, |
815 | 815 | )); |
816 | 816 | } |
817 | - if (($href=preg_match('/\<(D:)?href\>[^<]+\<\/(D:)?href\>/i',$value))) |
|
817 | + if (($href = preg_match('/\<(D:)?href\>[^<]+\<\/(D:)?href\>/i', $value))) |
|
818 | 818 | { |
819 | - $value = preg_replace('/\<(D:)?href\>('.preg_quote($this->base_uri.'/','/').')?([^<]+)\<\/(D:)?href\>/i','<\\1href><a href="\\2\\3">\\3</a></\\4href>',$value); |
|
819 | + $value = preg_replace('/\<(D:)?href\>('.preg_quote($this->base_uri.'/', '/').')?([^<]+)\<\/(D:)?href\>/i', '<\\1href><a href="\\2\\3">\\3</a></\\4href>', $value); |
|
820 | 820 | } |
821 | - $ret = $value[0] == '<' || strpos($value, "\n") !== false ? |
|
821 | + $ret = $value[0] == '<' || strpos($value, "\n") !== false ? |
|
822 | 822 | '<pre>'.htmlspecialchars($value).'</pre>' : htmlspecialchars($value); |
823 | 823 | |
824 | 824 | if ($href) |
@@ -838,10 +838,10 @@ discard block |
||
838 | 838 | protected function props2array(array $props) |
839 | 839 | { |
840 | 840 | $arr = array(); |
841 | - foreach($props as $prop) |
|
841 | + foreach ($props as $prop) |
|
842 | 842 | { |
843 | 843 | $ns_hash = array('DAV:' => 'D'); |
844 | - switch($prop['ns']) |
|
844 | + switch ($prop['ns']) |
|
845 | 845 | { |
846 | 846 | case 'DAV:'; |
847 | 847 | $ns = 'DAV'; |
@@ -851,10 +851,10 @@ discard block |
||
851 | 851 | } |
852 | 852 | if (is_array($prop['val'])) |
853 | 853 | { |
854 | - $prop['val'] = $this->_hierarchical_prop_encode($prop['val'], $prop['ns'], $ns_defs='', $ns_hash); |
|
854 | + $prop['val'] = $this->_hierarchical_prop_encode($prop['val'], $prop['ns'], $ns_defs = '', $ns_hash); |
|
855 | 855 | // hack to show real namespaces instead of not (visibly) defined shortcuts |
856 | 856 | unset($ns_hash['DAV:']); |
857 | - $value = strtr($v=$this->prop_value($prop['val']),array_flip($ns_hash)); |
|
857 | + $value = strtr($v = $this->prop_value($prop['val']), array_flip($ns_hash)); |
|
858 | 858 | } |
859 | 859 | else |
860 | 860 | { |