@@ -447,10 +447,10 @@ discard block |
||
| 447 | 447 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
| 448 | 448 | * |
| 449 | 449 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
| 450 | - * { |
|
| 450 | + * { |
|
| 451 | 451 | * $eof = !$eof; |
| 452 | 452 | * } |
| 453 | - * |
|
| 453 | + * |
|
| 454 | 454 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
| 455 | 455 | */ |
| 456 | 456 | function stream_eof ( ) |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | * See fseek() for more information about these parameters. |
| 486 | 486 | * |
| 487 | 487 | * @param integer $offset |
| 488 | - * @param integer $whence SEEK_SET - 0 - Set position equal to offset bytes |
|
| 488 | + * @param integer $whence SEEK_SET - 0 - Set position equal to offset bytes |
|
| 489 | 489 | * SEEK_CUR - 1 - Set position to current location plus offset. |
| 490 | 490 | * 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.) |
| 491 | 491 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
@@ -681,8 +681,8 @@ discard block |
||
| 681 | 681 | $maxdepth=10; |
| 682 | 682 | $depth2propagate = (int)$depth + 1; |
| 683 | 683 | if ($depth2propagate > $maxdepth) return is_dir($pathname); |
| 684 | - is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate); |
|
| 685 | - return is_dir($pathname) || @mkdir($pathname, $mode); |
|
| 684 | + is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate); |
|
| 685 | + return is_dir($pathname) || @mkdir($pathname, $mode); |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | /** |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | var $debug = 0; |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * Serve a webdav request |
|
| 56 | - * |
|
| 57 | - * Reimplemented to not check our vfs base path with realpath and connect to mysql DB |
|
| 58 | - * |
|
| 59 | - * @access public |
|
| 60 | - * @param $prefix =null prefix filesystem path with given path, eg. "/webdav" for owncloud 4.5 remote.php |
|
| 61 | - */ |
|
| 55 | + * Serve a webdav request |
|
| 56 | + * |
|
| 57 | + * Reimplemented to not check our vfs base path with realpath and connect to mysql DB |
|
| 58 | + * |
|
| 59 | + * @access public |
|
| 60 | + * @param $prefix =null prefix filesystem path with given path, eg. "/webdav" for owncloud 4.5 remote.php |
|
| 61 | + */ |
|
| 62 | 62 | function ServeRequest($prefix=null) |
| 63 | 63 | { |
| 64 | 64 | // special treatment for litmus compliance test |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | - * DELETE method handler |
|
| 77 | - * |
|
| 78 | - * @param array general parameter passing array |
|
| 79 | - * @return bool true on success |
|
| 80 | - */ |
|
| 76 | + * DELETE method handler |
|
| 77 | + * |
|
| 78 | + * @param array general parameter passing array |
|
| 79 | + * @return bool true on success |
|
| 80 | + */ |
|
| 81 | 81 | function DELETE($options) |
| 82 | 82 | { |
| 83 | 83 | $path = $this->base . $options['path']; |
@@ -110,165 +110,165 @@ discard block |
||
| 110 | 110 | return '204 No Content'; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * MKCOL method handler |
|
| 115 | - * |
|
| 116 | - * Reimplemented to NOT use dirname/basename, which has problems with utf-8 chars |
|
| 117 | - * |
|
| 118 | - * @param array general parameter passing array |
|
| 119 | - * @return bool true on success |
|
| 120 | - */ |
|
| 121 | - function MKCOL($options) |
|
| 122 | - { |
|
| 123 | - $path = $this->_unslashify($this->base .$options["path"]); |
|
| 124 | - $parent = Vfs::dirname($path); |
|
| 125 | - |
|
| 126 | - if (!file_exists($parent)) { |
|
| 127 | - return "409 Conflict"; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - if (!is_dir($parent)) { |
|
| 131 | - return "403 Forbidden"; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - if ( file_exists($path) ) { |
|
| 135 | - return "405 Method not allowed"; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
| 139 | - return "415 Unsupported media type"; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $stat = mkdir($path, 0777); |
|
| 143 | - if (!$stat) { |
|
| 144 | - return "403 Forbidden"; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - return ("201 Created"); |
|
| 148 | - } |
|
| 113 | + /** |
|
| 114 | + * MKCOL method handler |
|
| 115 | + * |
|
| 116 | + * Reimplemented to NOT use dirname/basename, which has problems with utf-8 chars |
|
| 117 | + * |
|
| 118 | + * @param array general parameter passing array |
|
| 119 | + * @return bool true on success |
|
| 120 | + */ |
|
| 121 | + function MKCOL($options) |
|
| 122 | + { |
|
| 123 | + $path = $this->_unslashify($this->base .$options["path"]); |
|
| 124 | + $parent = Vfs::dirname($path); |
|
| 125 | + |
|
| 126 | + if (!file_exists($parent)) { |
|
| 127 | + return "409 Conflict"; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + if (!is_dir($parent)) { |
|
| 131 | + return "403 Forbidden"; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + if ( file_exists($path) ) { |
|
| 135 | + return "405 Method not allowed"; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
| 139 | + return "415 Unsupported media type"; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $stat = mkdir($path, 0777); |
|
| 143 | + if (!$stat) { |
|
| 144 | + return "403 Forbidden"; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + return ("201 Created"); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | - * COPY method handler |
|
| 152 | - * |
|
| 153 | - * @param array general parameter passing array |
|
| 154 | - * @return bool true on success |
|
| 155 | - */ |
|
| 156 | - function COPY($options, $del=false) |
|
| 157 | - { |
|
| 158 | - // TODO Property updates still broken (Litmus should detect this?) |
|
| 159 | - |
|
| 160 | - if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
| 161 | - return "415 Unsupported media type"; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - // no copying to different WebDAV Servers yet |
|
| 165 | - if (isset($options["dest_url"])) { |
|
| 166 | - return "502 bad gateway"; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - $source = $this->base .$options["path"]; |
|
| 170 | - if (!file_exists($source)) return "404 Not found"; |
|
| 171 | - |
|
| 172 | - if (is_dir($source)) { // resource is a collection |
|
| 173 | - switch ($options["depth"]) { |
|
| 174 | - case "infinity": // valid |
|
| 175 | - break; |
|
| 176 | - case "0": // valid for COPY only |
|
| 177 | - if ($del) { // MOVE? |
|
| 178 | - return "400 Bad request"; |
|
| 179 | - } |
|
| 180 | - break; |
|
| 181 | - case "1": // invalid for both COPY and MOVE |
|
| 182 | - default: |
|
| 183 | - return "400 Bad request"; |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - $dest = $this->base . $options["dest"]; |
|
| 188 | - $destdir = dirname($dest); |
|
| 189 | - |
|
| 190 | - if (!file_exists($destdir) || !is_dir($destdir)) { |
|
| 191 | - return "409 Conflict"; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - $new = !file_exists($dest); |
|
| 195 | - $existing_col = false; |
|
| 196 | - |
|
| 197 | - if (!$new) { |
|
| 198 | - if ($del && is_dir($dest)) { |
|
| 199 | - if (!$options["overwrite"]) { |
|
| 200 | - return "412 precondition failed"; |
|
| 201 | - } |
|
| 202 | - $dest .= basename($source); |
|
| 203 | - if (file_exists($dest)) { |
|
| 204 | - $options["dest"] .= basename($source); |
|
| 205 | - } else { |
|
| 206 | - $new = true; |
|
| 207 | - $existing_col = true; |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - if (!$new) { |
|
| 213 | - if ($options["overwrite"]) { |
|
| 214 | - $stat = $this->DELETE(array("path" => $options["dest"])); |
|
| 215 | - if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) { |
|
| 216 | - return $stat; |
|
| 217 | - } |
|
| 218 | - } else { |
|
| 219 | - return "412 precondition failed"; |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - if ($del) { |
|
| 224 | - if (!rename($source, $dest)) { |
|
| 225 | - return "500 Internal server error"; |
|
| 226 | - } |
|
| 227 | - } else { |
|
| 228 | - if (is_dir($source) && $options['depth'] == 'infinity') { |
|
| 229 | - $files = Vfs::find($source,array('depth' => true,'url' => true)); // depth=true: return dirs first, url=true: allow urls! |
|
| 230 | - } else { |
|
| 231 | - $files = array($source); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - if (!is_array($files) || empty($files)) { |
|
| 235 | - return "500 Internal server error"; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - foreach ($files as $file) { |
|
| 240 | - if (is_dir($file)) { |
|
| 241 | - $file = $this->_slashify($file); |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - $destfile = str_replace($source, $dest, $file); |
|
| 245 | - |
|
| 246 | - if (is_dir($file)) { |
|
| 247 | - if (!is_dir($destfile)) { |
|
| 248 | - // TODO "mkdir -p" here? (only natively supported by PHP 5) |
|
| 249 | - if (!@mkdir($destfile)) { |
|
| 250 | - return "409 Conflict"; |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - } else { |
|
| 254 | - if (!@copy($file, $destfile)) { |
|
| 255 | - return "409 Conflict"; |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - // adding Location header as shown in example in rfc2518 section 8.9.5 |
|
| 151 | + * COPY method handler |
|
| 152 | + * |
|
| 153 | + * @param array general parameter passing array |
|
| 154 | + * @return bool true on success |
|
| 155 | + */ |
|
| 156 | + function COPY($options, $del=false) |
|
| 157 | + { |
|
| 158 | + // TODO Property updates still broken (Litmus should detect this?) |
|
| 159 | + |
|
| 160 | + if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
| 161 | + return "415 Unsupported media type"; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + // no copying to different WebDAV Servers yet |
|
| 165 | + if (isset($options["dest_url"])) { |
|
| 166 | + return "502 bad gateway"; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + $source = $this->base .$options["path"]; |
|
| 170 | + if (!file_exists($source)) return "404 Not found"; |
|
| 171 | + |
|
| 172 | + if (is_dir($source)) { // resource is a collection |
|
| 173 | + switch ($options["depth"]) { |
|
| 174 | + case "infinity": // valid |
|
| 175 | + break; |
|
| 176 | + case "0": // valid for COPY only |
|
| 177 | + if ($del) { // MOVE? |
|
| 178 | + return "400 Bad request"; |
|
| 179 | + } |
|
| 180 | + break; |
|
| 181 | + case "1": // invalid for both COPY and MOVE |
|
| 182 | + default: |
|
| 183 | + return "400 Bad request"; |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + $dest = $this->base . $options["dest"]; |
|
| 188 | + $destdir = dirname($dest); |
|
| 189 | + |
|
| 190 | + if (!file_exists($destdir) || !is_dir($destdir)) { |
|
| 191 | + return "409 Conflict"; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + $new = !file_exists($dest); |
|
| 195 | + $existing_col = false; |
|
| 196 | + |
|
| 197 | + if (!$new) { |
|
| 198 | + if ($del && is_dir($dest)) { |
|
| 199 | + if (!$options["overwrite"]) { |
|
| 200 | + return "412 precondition failed"; |
|
| 201 | + } |
|
| 202 | + $dest .= basename($source); |
|
| 203 | + if (file_exists($dest)) { |
|
| 204 | + $options["dest"] .= basename($source); |
|
| 205 | + } else { |
|
| 206 | + $new = true; |
|
| 207 | + $existing_col = true; |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + if (!$new) { |
|
| 213 | + if ($options["overwrite"]) { |
|
| 214 | + $stat = $this->DELETE(array("path" => $options["dest"])); |
|
| 215 | + if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) { |
|
| 216 | + return $stat; |
|
| 217 | + } |
|
| 218 | + } else { |
|
| 219 | + return "412 precondition failed"; |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + if ($del) { |
|
| 224 | + if (!rename($source, $dest)) { |
|
| 225 | + return "500 Internal server error"; |
|
| 226 | + } |
|
| 227 | + } else { |
|
| 228 | + if (is_dir($source) && $options['depth'] == 'infinity') { |
|
| 229 | + $files = Vfs::find($source,array('depth' => true,'url' => true)); // depth=true: return dirs first, url=true: allow urls! |
|
| 230 | + } else { |
|
| 231 | + $files = array($source); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + if (!is_array($files) || empty($files)) { |
|
| 235 | + return "500 Internal server error"; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + foreach ($files as $file) { |
|
| 240 | + if (is_dir($file)) { |
|
| 241 | + $file = $this->_slashify($file); |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + $destfile = str_replace($source, $dest, $file); |
|
| 245 | + |
|
| 246 | + if (is_dir($file)) { |
|
| 247 | + if (!is_dir($destfile)) { |
|
| 248 | + // TODO "mkdir -p" here? (only natively supported by PHP 5) |
|
| 249 | + if (!@mkdir($destfile)) { |
|
| 250 | + return "409 Conflict"; |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + } else { |
|
| 254 | + if (!@copy($file, $destfile)) { |
|
| 255 | + return "409 Conflict"; |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + // adding Location header as shown in example in rfc2518 section 8.9.5 |
|
| 261 | 261 | header('Location: '.$this->base_uri.$options['dest']); |
| 262 | 262 | |
| 263 | - return ($new && !$existing_col) ? "201 Created" : "204 No Content"; |
|
| 264 | - } |
|
| 263 | + return ($new && !$existing_col) ? "201 Created" : "204 No Content"; |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - /** |
|
| 267 | - * Get properties for a single file/resource |
|
| 268 | - * |
|
| 269 | - * @param string $_path resource path |
|
| 270 | - * @return array resource properties |
|
| 271 | - */ |
|
| 266 | + /** |
|
| 267 | + * Get properties for a single file/resource |
|
| 268 | + * |
|
| 269 | + * @param string $_path resource path |
|
| 270 | + * @return array resource properties |
|
| 271 | + */ |
|
| 272 | 272 | function fileinfo($_path) |
| 273 | 273 | { |
| 274 | 274 | // internally we require some url-encoding, as vfs_stream_wrapper uses URL's internally |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | $info['props'][] = self::mkprop ('creationdate', filectime($fspath)); |
| 297 | 297 | $info['props'][] = self::mkprop ('getlastmodified', filemtime($fspath)); |
| 298 | 298 | |
| 299 | - // Microsoft extensions: last access time and 'hidden' status |
|
| 300 | - $info["props"][] = self::mkprop("lastaccessed", fileatime($fspath)); |
|
| 301 | - $info["props"][] = self::mkprop("ishidden", Vfs::is_hidden($fspath)); |
|
| 299 | + // Microsoft extensions: last access time and 'hidden' status |
|
| 300 | + $info["props"][] = self::mkprop("lastaccessed", fileatime($fspath)); |
|
| 301 | + $info["props"][] = self::mkprop("ishidden", Vfs::is_hidden($fspath)); |
|
| 302 | 302 | |
| 303 | 303 | // type and size (caller already made sure that path exists) |
| 304 | 304 | if (is_dir($fspath)) { |
@@ -436,38 +436,38 @@ discard block |
||
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | /** |
| 439 | - * Used eg. by get |
|
| 440 | - * |
|
| 441 | - * @todo replace all calls to _mimetype with Vfs::mime_content_type() |
|
| 442 | - * @param string $path |
|
| 443 | - * @return string |
|
| 444 | - */ |
|
| 439 | + * Used eg. by get |
|
| 440 | + * |
|
| 441 | + * @todo replace all calls to _mimetype with Vfs::mime_content_type() |
|
| 442 | + * @param string $path |
|
| 443 | + * @return string |
|
| 444 | + */ |
|
| 445 | 445 | function _mimetype($path) |
| 446 | 446 | { |
| 447 | 447 | return Vfs::mime_content_type($path); |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - /** |
|
| 451 | - * Check if path is readable by current user |
|
| 452 | - * |
|
| 453 | - * @param string $fspath |
|
| 454 | - * @return boolean |
|
| 455 | - */ |
|
| 456 | - function _is_readable($fspath) |
|
| 457 | - { |
|
| 458 | - return Vfs::is_readable($fspath); |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - /** |
|
| 462 | - * Check if path is writable by current user |
|
| 463 | - * |
|
| 464 | - * @param string $fspath |
|
| 465 | - * @return boolean |
|
| 466 | - */ |
|
| 467 | - function _is_writable($fspath) |
|
| 468 | - { |
|
| 469 | - return Vfs::is_writable($fspath); |
|
| 470 | - } |
|
| 450 | + /** |
|
| 451 | + * Check if path is readable by current user |
|
| 452 | + * |
|
| 453 | + * @param string $fspath |
|
| 454 | + * @return boolean |
|
| 455 | + */ |
|
| 456 | + function _is_readable($fspath) |
|
| 457 | + { |
|
| 458 | + return Vfs::is_readable($fspath); |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + /** |
|
| 462 | + * Check if path is writable by current user |
|
| 463 | + * |
|
| 464 | + * @param string $fspath |
|
| 465 | + * @return boolean |
|
| 466 | + */ |
|
| 467 | + function _is_writable($fspath) |
|
| 468 | + { |
|
| 469 | + return Vfs::is_writable($fspath); |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | 472 | /** |
| 473 | 473 | * PROPPATCH method handler |
@@ -610,13 +610,13 @@ discard block |
||
| 610 | 610 | * @param string directory path |
| 611 | 611 | * @return void function has to handle HTTP response itself |
| 612 | 612 | */ |
| 613 | - function GetDir($fspath, &$options) |
|
| 614 | - { |
|
| 613 | + function GetDir($fspath, &$options) |
|
| 614 | + { |
|
| 615 | 615 | // add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv) |
| 616 | 616 | header('Content-type: text/html; charset='.Api\Translation::charset()); |
| 617 | 617 | |
| 618 | 618 | parent::GetDir($fspath, $options); |
| 619 | - } |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | 621 | private $force_download = false; |
| 622 | 622 | |
@@ -411,10 +411,10 @@ discard block |
||
| 411 | 411 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
| 412 | 412 | * |
| 413 | 413 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
| 414 | - * { |
|
| 414 | + * { |
|
| 415 | 415 | * $eof = !$eof; |
| 416 | 416 | * } |
| 417 | - * |
|
| 417 | + * |
|
| 418 | 418 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
| 419 | 419 | */ |
| 420 | 420 | function stream_eof ( ) |
@@ -1053,7 +1053,7 @@ discard block |
||
| 1053 | 1053 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1)); |
| 1054 | 1054 | |
| 1055 | 1055 | while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) && |
| 1056 | - ($url = Vfs::dirname($url))) |
|
| 1056 | + ($url = Vfs::dirname($url))) |
|
| 1057 | 1057 | { |
| 1058 | 1058 | if (($stat = self::url_stat($url,0,false,false))) |
| 1059 | 1059 | { |
@@ -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; |
@@ -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 ( ); |
@@ -6730,14 +6730,14 @@ |
||
| 6730 | 6730 | { |
| 6731 | 6731 | if ($this->folderExists($_folder,true)) |
| 6732 | 6732 | { |
| 6733 | - if($this->isSentFolder($_folder)) |
|
| 6733 | + if($this->isSentFolder($_folder)) |
|
| 6734 | 6734 | { |
| 6735 | - $flags = '\\Seen'; |
|
| 6736 | - } elseif($this->isDraftFolder($_folder)) { |
|
| 6737 | - $flags = '\\Draft'; |
|
| 6738 | - } else { |
|
| 6739 | - $flags = ''; |
|
| 6740 | - } |
|
| 6735 | + $flags = '\\Seen'; |
|
| 6736 | + } elseif($this->isDraftFolder($_folder)) { |
|
| 6737 | + $flags = '\\Draft'; |
|
| 6738 | + } else { |
|
| 6739 | + $flags = ''; |
|
| 6740 | + } |
|
| 6741 | 6741 | $savefailed = false; |
| 6742 | 6742 | try |
| 6743 | 6743 | { |
@@ -43,209 +43,209 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class _parse_lockinfo |
| 45 | 45 | { |
| 46 | - /** |
|
| 47 | - * success state flag |
|
| 48 | - * |
|
| 49 | - * @var bool |
|
| 50 | - * @access public |
|
| 51 | - */ |
|
| 52 | - var $success = false; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * lock type, currently only "write" |
|
| 56 | - * |
|
| 57 | - * @var string |
|
| 58 | - * @access public |
|
| 59 | - */ |
|
| 60 | - var $locktype = ""; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * lock scope, "shared" or "exclusive" |
|
| 64 | - * |
|
| 65 | - * @var string |
|
| 66 | - * @access public |
|
| 67 | - */ |
|
| 68 | - var $lockscope = ""; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * lock owner information |
|
| 72 | - * |
|
| 73 | - * @var string |
|
| 74 | - * @access public |
|
| 75 | - */ |
|
| 76 | - var $owner = ""; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * flag that is set during lock owner read |
|
| 80 | - * |
|
| 81 | - * @var bool |
|
| 82 | - * @access private |
|
| 83 | - */ |
|
| 84 | - var $collect_owner = false; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * constructor |
|
| 88 | - * |
|
| 89 | - * @param string path of stream to read |
|
| 90 | - * @access public |
|
| 91 | - */ |
|
| 92 | - function __construct($path) |
|
| 93 | - { |
|
| 94 | - // we assume success unless problems occur |
|
| 95 | - $this->success = true; |
|
| 96 | - |
|
| 97 | - // remember if any input was parsed |
|
| 98 | - $had_input = false; |
|
| 99 | - |
|
| 100 | - // open stream |
|
| 101 | - $f_in = fopen($path, "r"); |
|
| 102 | - if (!$f_in) { |
|
| 103 | - $this->success = false; |
|
| 104 | - return; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - // create namespace aware parser |
|
| 108 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 109 | - |
|
| 110 | - // set tag and data handlers |
|
| 111 | - xml_set_element_handler($xml_parser, |
|
| 112 | - array(&$this, "_startElement"), |
|
| 113 | - array(&$this, "_endElement")); |
|
| 114 | - xml_set_character_data_handler($xml_parser, |
|
| 115 | - array(&$this, "_data")); |
|
| 116 | - |
|
| 117 | - // we want a case sensitive parser |
|
| 118 | - xml_parser_set_option($xml_parser, |
|
| 119 | - XML_OPTION_CASE_FOLDING, false); |
|
| 120 | - |
|
| 121 | - // parse input |
|
| 122 | - while ($this->success && !feof($f_in)) { |
|
| 123 | - $line = fgets($f_in); |
|
| 124 | - if (is_string($line)) { |
|
| 125 | - $had_input = true; |
|
| 126 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - // finish parsing |
|
| 131 | - if ($had_input) { |
|
| 132 | - $this->success &= xml_parse($xml_parser, "", true); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - // check if required tags where found |
|
| 136 | - $this->success &= !empty($this->locktype); |
|
| 137 | - $this->success &= !empty($this->lockscope); |
|
| 138 | - |
|
| 139 | - // free parser resource |
|
| 140 | - xml_parser_free($xml_parser); |
|
| 141 | - |
|
| 142 | - // close input stream |
|
| 143 | - fclose($f_in); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * tag start handler |
|
| 149 | - * |
|
| 150 | - * @param resource parser |
|
| 151 | - * @param string tag name |
|
| 152 | - * @param array tag attributes |
|
| 153 | - * @return void |
|
| 154 | - * @access private |
|
| 155 | - */ |
|
| 156 | - function _startElement($parser, $name, $attrs) |
|
| 157 | - { |
|
| 158 | - // namespace handling |
|
| 159 | - if (strstr($name, " ")) { |
|
| 160 | - list($ns, $tag) = explode(" ", $name); |
|
| 161 | - } else { |
|
| 162 | - $ns = ""; |
|
| 163 | - $tag = $name; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - if ($this->collect_owner) { |
|
| 168 | - // everything within the <owner> tag needs to be collected |
|
| 169 | - $ns_short = ""; |
|
| 170 | - $ns_attr = ""; |
|
| 171 | - if ($ns) { |
|
| 172 | - if ($ns == "DAV:") { |
|
| 173 | - $ns_short = "D:"; |
|
| 174 | - } else { |
|
| 175 | - $ns_attr = " xmlns='$ns'"; |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
| 179 | - } else if ($ns == "DAV:") { |
|
| 180 | - // parse only the essential tags |
|
| 181 | - switch ($tag) { |
|
| 182 | - case "write": |
|
| 183 | - $this->locktype = $tag; |
|
| 184 | - break; |
|
| 185 | - case "exclusive": |
|
| 186 | - case "shared": |
|
| 187 | - $this->lockscope = $tag; |
|
| 188 | - break; |
|
| 189 | - case "owner": |
|
| 190 | - $this->collect_owner = true; |
|
| 191 | - break; |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * data handler |
|
| 198 | - * |
|
| 199 | - * @param resource parser |
|
| 200 | - * @param string data |
|
| 201 | - * @return void |
|
| 202 | - * @access private |
|
| 203 | - */ |
|
| 204 | - function _data($parser, $data) |
|
| 205 | - { |
|
| 206 | - // only the <owner> tag has data content |
|
| 207 | - if ($this->collect_owner) { |
|
| 208 | - $this->owner .= $data; |
|
| 209 | - } |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * tag end handler |
|
| 214 | - * |
|
| 215 | - * @param resource parser |
|
| 216 | - * @param string tag name |
|
| 217 | - * @return void |
|
| 218 | - * @access private |
|
| 219 | - */ |
|
| 220 | - function _endElement($parser, $name) |
|
| 221 | - { |
|
| 222 | - // namespace handling |
|
| 223 | - if (strstr($name, " ")) { |
|
| 224 | - list($ns, $tag) = explode(" ", $name); |
|
| 225 | - } else { |
|
| 226 | - $ns = ""; |
|
| 227 | - $tag = $name; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - // <owner> finished? |
|
| 231 | - if (($ns == "DAV:") && ($tag == "owner")) { |
|
| 232 | - $this->collect_owner = false; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - // within <owner> we have to collect everything |
|
| 236 | - if ($this->collect_owner) { |
|
| 237 | - $ns_short = ""; |
|
| 238 | - $ns_attr = ""; |
|
| 239 | - if ($ns) { |
|
| 240 | - if ($ns == "DAV:") { |
|
| 241 | - $ns_short = "D:"; |
|
| 242 | - } else { |
|
| 243 | - $ns_attr = " xmlns='$ns'"; |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
| 247 | - } |
|
| 248 | - } |
|
| 46 | + /** |
|
| 47 | + * success state flag |
|
| 48 | + * |
|
| 49 | + * @var bool |
|
| 50 | + * @access public |
|
| 51 | + */ |
|
| 52 | + var $success = false; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * lock type, currently only "write" |
|
| 56 | + * |
|
| 57 | + * @var string |
|
| 58 | + * @access public |
|
| 59 | + */ |
|
| 60 | + var $locktype = ""; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * lock scope, "shared" or "exclusive" |
|
| 64 | + * |
|
| 65 | + * @var string |
|
| 66 | + * @access public |
|
| 67 | + */ |
|
| 68 | + var $lockscope = ""; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * lock owner information |
|
| 72 | + * |
|
| 73 | + * @var string |
|
| 74 | + * @access public |
|
| 75 | + */ |
|
| 76 | + var $owner = ""; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * flag that is set during lock owner read |
|
| 80 | + * |
|
| 81 | + * @var bool |
|
| 82 | + * @access private |
|
| 83 | + */ |
|
| 84 | + var $collect_owner = false; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * constructor |
|
| 88 | + * |
|
| 89 | + * @param string path of stream to read |
|
| 90 | + * @access public |
|
| 91 | + */ |
|
| 92 | + function __construct($path) |
|
| 93 | + { |
|
| 94 | + // we assume success unless problems occur |
|
| 95 | + $this->success = true; |
|
| 96 | + |
|
| 97 | + // remember if any input was parsed |
|
| 98 | + $had_input = false; |
|
| 99 | + |
|
| 100 | + // open stream |
|
| 101 | + $f_in = fopen($path, "r"); |
|
| 102 | + if (!$f_in) { |
|
| 103 | + $this->success = false; |
|
| 104 | + return; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + // create namespace aware parser |
|
| 108 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 109 | + |
|
| 110 | + // set tag and data handlers |
|
| 111 | + xml_set_element_handler($xml_parser, |
|
| 112 | + array(&$this, "_startElement"), |
|
| 113 | + array(&$this, "_endElement")); |
|
| 114 | + xml_set_character_data_handler($xml_parser, |
|
| 115 | + array(&$this, "_data")); |
|
| 116 | + |
|
| 117 | + // we want a case sensitive parser |
|
| 118 | + xml_parser_set_option($xml_parser, |
|
| 119 | + XML_OPTION_CASE_FOLDING, false); |
|
| 120 | + |
|
| 121 | + // parse input |
|
| 122 | + while ($this->success && !feof($f_in)) { |
|
| 123 | + $line = fgets($f_in); |
|
| 124 | + if (is_string($line)) { |
|
| 125 | + $had_input = true; |
|
| 126 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + // finish parsing |
|
| 131 | + if ($had_input) { |
|
| 132 | + $this->success &= xml_parse($xml_parser, "", true); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + // check if required tags where found |
|
| 136 | + $this->success &= !empty($this->locktype); |
|
| 137 | + $this->success &= !empty($this->lockscope); |
|
| 138 | + |
|
| 139 | + // free parser resource |
|
| 140 | + xml_parser_free($xml_parser); |
|
| 141 | + |
|
| 142 | + // close input stream |
|
| 143 | + fclose($f_in); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * tag start handler |
|
| 149 | + * |
|
| 150 | + * @param resource parser |
|
| 151 | + * @param string tag name |
|
| 152 | + * @param array tag attributes |
|
| 153 | + * @return void |
|
| 154 | + * @access private |
|
| 155 | + */ |
|
| 156 | + function _startElement($parser, $name, $attrs) |
|
| 157 | + { |
|
| 158 | + // namespace handling |
|
| 159 | + if (strstr($name, " ")) { |
|
| 160 | + list($ns, $tag) = explode(" ", $name); |
|
| 161 | + } else { |
|
| 162 | + $ns = ""; |
|
| 163 | + $tag = $name; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + if ($this->collect_owner) { |
|
| 168 | + // everything within the <owner> tag needs to be collected |
|
| 169 | + $ns_short = ""; |
|
| 170 | + $ns_attr = ""; |
|
| 171 | + if ($ns) { |
|
| 172 | + if ($ns == "DAV:") { |
|
| 173 | + $ns_short = "D:"; |
|
| 174 | + } else { |
|
| 175 | + $ns_attr = " xmlns='$ns'"; |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
| 179 | + } else if ($ns == "DAV:") { |
|
| 180 | + // parse only the essential tags |
|
| 181 | + switch ($tag) { |
|
| 182 | + case "write": |
|
| 183 | + $this->locktype = $tag; |
|
| 184 | + break; |
|
| 185 | + case "exclusive": |
|
| 186 | + case "shared": |
|
| 187 | + $this->lockscope = $tag; |
|
| 188 | + break; |
|
| 189 | + case "owner": |
|
| 190 | + $this->collect_owner = true; |
|
| 191 | + break; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * data handler |
|
| 198 | + * |
|
| 199 | + * @param resource parser |
|
| 200 | + * @param string data |
|
| 201 | + * @return void |
|
| 202 | + * @access private |
|
| 203 | + */ |
|
| 204 | + function _data($parser, $data) |
|
| 205 | + { |
|
| 206 | + // only the <owner> tag has data content |
|
| 207 | + if ($this->collect_owner) { |
|
| 208 | + $this->owner .= $data; |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * tag end handler |
|
| 214 | + * |
|
| 215 | + * @param resource parser |
|
| 216 | + * @param string tag name |
|
| 217 | + * @return void |
|
| 218 | + * @access private |
|
| 219 | + */ |
|
| 220 | + function _endElement($parser, $name) |
|
| 221 | + { |
|
| 222 | + // namespace handling |
|
| 223 | + if (strstr($name, " ")) { |
|
| 224 | + list($ns, $tag) = explode(" ", $name); |
|
| 225 | + } else { |
|
| 226 | + $ns = ""; |
|
| 227 | + $tag = $name; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + // <owner> finished? |
|
| 231 | + if (($ns == "DAV:") && ($tag == "owner")) { |
|
| 232 | + $this->collect_owner = false; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + // within <owner> we have to collect everything |
|
| 236 | + if ($this->collect_owner) { |
|
| 237 | + $ns_short = ""; |
|
| 238 | + $ns_attr = ""; |
|
| 239 | + if ($ns) { |
|
| 240 | + if ($ns == "DAV:") { |
|
| 241 | + $ns_short = "D:"; |
|
| 242 | + } else { |
|
| 243 | + $ns_attr = " xmlns='$ns'"; |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | ?> |
@@ -43,198 +43,198 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class _parse_proppatch |
| 45 | 45 | { |
| 46 | - /** |
|
| 47 | - * |
|
| 48 | - * |
|
| 49 | - * @var |
|
| 50 | - * @access |
|
| 51 | - */ |
|
| 52 | - var $success; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * |
|
| 56 | - * |
|
| 57 | - * @var |
|
| 58 | - * @access |
|
| 59 | - */ |
|
| 60 | - var $props; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * |
|
| 64 | - * |
|
| 65 | - * @var |
|
| 66 | - * @access |
|
| 67 | - */ |
|
| 68 | - var $depth; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * |
|
| 72 | - * |
|
| 73 | - * @var |
|
| 74 | - * @access |
|
| 75 | - */ |
|
| 76 | - var $mode; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * |
|
| 80 | - * |
|
| 81 | - * @var |
|
| 82 | - * @access |
|
| 83 | - */ |
|
| 84 | - var $current; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * On return whole request, if $store_request == true was specified in constructor |
|
| 88 | - * |
|
| 89 | - * @var string |
|
| 90 | - */ |
|
| 91 | - var $request; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * constructor |
|
| 95 | - * |
|
| 96 | - * @param string path of input stream |
|
| 97 | - * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
| 98 | - * @access public |
|
| 99 | - */ |
|
| 100 | - function __construct($path, $store_request=false) |
|
| 101 | - { |
|
| 102 | - $this->success = true; |
|
| 103 | - |
|
| 104 | - $this->depth = 0; |
|
| 105 | - $this->props = array(); |
|
| 106 | - $had_input = false; |
|
| 107 | - |
|
| 108 | - $f_in = fopen($path, "r"); |
|
| 109 | - if (!$f_in) { |
|
| 110 | - $this->success = false; |
|
| 111 | - return; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 115 | - |
|
| 116 | - xml_set_element_handler($xml_parser, |
|
| 117 | - array(&$this, "_startElement"), |
|
| 118 | - array(&$this, "_endElement")); |
|
| 119 | - |
|
| 120 | - xml_set_character_data_handler($xml_parser, |
|
| 121 | - array(&$this, "_data")); |
|
| 122 | - |
|
| 123 | - xml_parser_set_option($xml_parser, |
|
| 124 | - XML_OPTION_CASE_FOLDING, false); |
|
| 125 | - |
|
| 126 | - while($this->success && !feof($f_in)) { |
|
| 127 | - $line = fgets($f_in); |
|
| 128 | - if ($store_request) $this->request .= $line; |
|
| 129 | - if (is_string($line)) { |
|
| 130 | - $had_input = true; |
|
| 131 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - if($had_input) { |
|
| 136 | - $this->success &= xml_parse($xml_parser, "", true); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - xml_parser_free($xml_parser); |
|
| 140 | - |
|
| 141 | - fclose($f_in); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * tag start handler |
|
| 146 | - * |
|
| 147 | - * @param resource parser |
|
| 148 | - * @param string tag name |
|
| 149 | - * @param array tag attributes |
|
| 150 | - * @return void |
|
| 151 | - * @access private |
|
| 152 | - */ |
|
| 153 | - function _startElement($parser, $name, $attrs) |
|
| 154 | - { |
|
| 155 | - if (strstr($name, " ")) { |
|
| 156 | - list($ns, $tag) = explode(" ", $name); |
|
| 157 | - if ($ns == "") |
|
| 158 | - $this->success = false; |
|
| 159 | - } else { |
|
| 160 | - $ns = ""; |
|
| 161 | - $tag = $name; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - if ($this->depth == 1) { |
|
| 165 | - $this->mode = $tag; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - if ($this->depth == 3) { |
|
| 169 | - $prop = array("name" => $tag); |
|
| 170 | - $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
|
| 171 | - if ($this->mode == "set") { |
|
| 172 | - $this->current["val"] = ""; // default set val |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - if ($this->depth >= 4) { |
|
| 177 | - $this->current["val"] .= "<$tag"; |
|
| 178 | - if (isset($attr)) { |
|
| 179 | - foreach ($attr as $key => $val) { |
|
| 180 | - $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - $this->current["val"] .= ">"; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - $this->depth++; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * tag end handler |
|
| 193 | - * |
|
| 194 | - * @param resource parser |
|
| 195 | - * @param string tag name |
|
| 196 | - * @return void |
|
| 197 | - * @access private |
|
| 198 | - */ |
|
| 199 | - function _endElement($parser, $name) |
|
| 200 | - { |
|
| 201 | - if (strstr($name, " ")) { |
|
| 202 | - list($ns, $tag) = explode(" ", $name); |
|
| 203 | - if ($ns == "") |
|
| 204 | - $this->success = false; |
|
| 205 | - } else { |
|
| 206 | - $ns = ""; |
|
| 207 | - $tag = $name; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - $this->depth--; |
|
| 211 | - |
|
| 212 | - if ($this->depth >= 4) { |
|
| 213 | - $this->current["val"] .= "</$tag>"; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - if ($this->depth == 3) { |
|
| 217 | - if (isset($this->current)) { |
|
| 218 | - $this->props[] = $this->current; |
|
| 219 | - unset($this->current); |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * input data handler |
|
| 226 | - * |
|
| 227 | - * @param resource parser |
|
| 228 | - * @param string data |
|
| 229 | - * @return void |
|
| 230 | - * @access private |
|
| 231 | - */ |
|
| 232 | - function _data($parser, $data) |
|
| 233 | - { |
|
| 234 | - if (isset($this->current)) { |
|
| 235 | - $this->current["val"] .= $data; |
|
| 236 | - } |
|
| 237 | - } |
|
| 46 | + /** |
|
| 47 | + * |
|
| 48 | + * |
|
| 49 | + * @var |
|
| 50 | + * @access |
|
| 51 | + */ |
|
| 52 | + var $success; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * |
|
| 56 | + * |
|
| 57 | + * @var |
|
| 58 | + * @access |
|
| 59 | + */ |
|
| 60 | + var $props; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * |
|
| 64 | + * |
|
| 65 | + * @var |
|
| 66 | + * @access |
|
| 67 | + */ |
|
| 68 | + var $depth; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * |
|
| 72 | + * |
|
| 73 | + * @var |
|
| 74 | + * @access |
|
| 75 | + */ |
|
| 76 | + var $mode; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * |
|
| 80 | + * |
|
| 81 | + * @var |
|
| 82 | + * @access |
|
| 83 | + */ |
|
| 84 | + var $current; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * On return whole request, if $store_request == true was specified in constructor |
|
| 88 | + * |
|
| 89 | + * @var string |
|
| 90 | + */ |
|
| 91 | + var $request; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * constructor |
|
| 95 | + * |
|
| 96 | + * @param string path of input stream |
|
| 97 | + * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
| 98 | + * @access public |
|
| 99 | + */ |
|
| 100 | + function __construct($path, $store_request=false) |
|
| 101 | + { |
|
| 102 | + $this->success = true; |
|
| 103 | + |
|
| 104 | + $this->depth = 0; |
|
| 105 | + $this->props = array(); |
|
| 106 | + $had_input = false; |
|
| 107 | + |
|
| 108 | + $f_in = fopen($path, "r"); |
|
| 109 | + if (!$f_in) { |
|
| 110 | + $this->success = false; |
|
| 111 | + return; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 115 | + |
|
| 116 | + xml_set_element_handler($xml_parser, |
|
| 117 | + array(&$this, "_startElement"), |
|
| 118 | + array(&$this, "_endElement")); |
|
| 119 | + |
|
| 120 | + xml_set_character_data_handler($xml_parser, |
|
| 121 | + array(&$this, "_data")); |
|
| 122 | + |
|
| 123 | + xml_parser_set_option($xml_parser, |
|
| 124 | + XML_OPTION_CASE_FOLDING, false); |
|
| 125 | + |
|
| 126 | + while($this->success && !feof($f_in)) { |
|
| 127 | + $line = fgets($f_in); |
|
| 128 | + if ($store_request) $this->request .= $line; |
|
| 129 | + if (is_string($line)) { |
|
| 130 | + $had_input = true; |
|
| 131 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + if($had_input) { |
|
| 136 | + $this->success &= xml_parse($xml_parser, "", true); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + xml_parser_free($xml_parser); |
|
| 140 | + |
|
| 141 | + fclose($f_in); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * tag start handler |
|
| 146 | + * |
|
| 147 | + * @param resource parser |
|
| 148 | + * @param string tag name |
|
| 149 | + * @param array tag attributes |
|
| 150 | + * @return void |
|
| 151 | + * @access private |
|
| 152 | + */ |
|
| 153 | + function _startElement($parser, $name, $attrs) |
|
| 154 | + { |
|
| 155 | + if (strstr($name, " ")) { |
|
| 156 | + list($ns, $tag) = explode(" ", $name); |
|
| 157 | + if ($ns == "") |
|
| 158 | + $this->success = false; |
|
| 159 | + } else { |
|
| 160 | + $ns = ""; |
|
| 161 | + $tag = $name; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + if ($this->depth == 1) { |
|
| 165 | + $this->mode = $tag; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + if ($this->depth == 3) { |
|
| 169 | + $prop = array("name" => $tag); |
|
| 170 | + $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
|
| 171 | + if ($this->mode == "set") { |
|
| 172 | + $this->current["val"] = ""; // default set val |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + if ($this->depth >= 4) { |
|
| 177 | + $this->current["val"] .= "<$tag"; |
|
| 178 | + if (isset($attr)) { |
|
| 179 | + foreach ($attr as $key => $val) { |
|
| 180 | + $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + $this->current["val"] .= ">"; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + $this->depth++; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * tag end handler |
|
| 193 | + * |
|
| 194 | + * @param resource parser |
|
| 195 | + * @param string tag name |
|
| 196 | + * @return void |
|
| 197 | + * @access private |
|
| 198 | + */ |
|
| 199 | + function _endElement($parser, $name) |
|
| 200 | + { |
|
| 201 | + if (strstr($name, " ")) { |
|
| 202 | + list($ns, $tag) = explode(" ", $name); |
|
| 203 | + if ($ns == "") |
|
| 204 | + $this->success = false; |
|
| 205 | + } else { |
|
| 206 | + $ns = ""; |
|
| 207 | + $tag = $name; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + $this->depth--; |
|
| 211 | + |
|
| 212 | + if ($this->depth >= 4) { |
|
| 213 | + $this->current["val"] .= "</$tag>"; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + if ($this->depth == 3) { |
|
| 217 | + if (isset($this->current)) { |
|
| 218 | + $this->props[] = $this->current; |
|
| 219 | + unset($this->current); |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * input data handler |
|
| 226 | + * |
|
| 227 | + * @param resource parser |
|
| 228 | + * @param string data |
|
| 229 | + * @return void |
|
| 230 | + * @access private |
|
| 231 | + */ |
|
| 232 | + function _data($parser, $data) |
|
| 233 | + { |
|
| 234 | + if (isset($this->current)) { |
|
| 235 | + $this->current["val"] .= $data; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /* |
@@ -42,244 +42,244 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | class _parse_propfind |
| 44 | 44 | { |
| 45 | - /** |
|
| 46 | - * success state flag |
|
| 47 | - * |
|
| 48 | - * @var bool |
|
| 49 | - * @access public |
|
| 50 | - */ |
|
| 51 | - var $success = false; |
|
| 45 | + /** |
|
| 46 | + * success state flag |
|
| 47 | + * |
|
| 48 | + * @var bool |
|
| 49 | + * @access public |
|
| 50 | + */ |
|
| 51 | + var $success = false; |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * found properties are collected here |
|
| 55 | - * |
|
| 56 | - * @var array |
|
| 57 | - * @access public |
|
| 58 | - */ |
|
| 59 | - var $props = false; |
|
| 53 | + /** |
|
| 54 | + * found properties are collected here |
|
| 55 | + * |
|
| 56 | + * @var array |
|
| 57 | + * @access public |
|
| 58 | + */ |
|
| 59 | + var $props = false; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * found (CalDAV) filters are collected here |
|
| 63 | - * |
|
| 64 | - * @var array |
|
| 65 | - * @access public |
|
| 66 | - */ |
|
| 67 | - var $filters = false; |
|
| 61 | + /** |
|
| 62 | + * found (CalDAV) filters are collected here |
|
| 63 | + * |
|
| 64 | + * @var array |
|
| 65 | + * @access public |
|
| 66 | + */ |
|
| 67 | + var $filters = false; |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * found other tags, eg. CalDAV calendar-multiget href's |
|
| 71 | - * |
|
| 72 | - * @var array |
|
| 73 | - * @access public |
|
| 74 | - */ |
|
| 75 | - var $other = false; |
|
| 69 | + /** |
|
| 70 | + * found other tags, eg. CalDAV calendar-multiget href's |
|
| 71 | + * |
|
| 72 | + * @var array |
|
| 73 | + * @access public |
|
| 74 | + */ |
|
| 75 | + var $other = false; |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * what we are currently parsing: props or filters |
|
| 79 | - * |
|
| 80 | - * @var array |
|
| 81 | - * @access private |
|
| 82 | - */ |
|
| 83 | - var $use = 'props'; |
|
| 77 | + /** |
|
| 78 | + * what we are currently parsing: props or filters |
|
| 79 | + * |
|
| 80 | + * @var array |
|
| 81 | + * @access private |
|
| 82 | + */ |
|
| 83 | + var $use = 'props'; |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Root tag, usually 'propfind' for PROPFIND, but can be eg. 'calendar-query' or 'calendar-multiget' for CalDAV REPORT |
|
| 87 | - * |
|
| 88 | - * @var array with keys 'name' and 'ns' |
|
| 89 | - */ |
|
| 90 | - var $root; |
|
| 85 | + /** |
|
| 86 | + * Root tag, usually 'propfind' for PROPFIND, but can be eg. 'calendar-query' or 'calendar-multiget' for CalDAV REPORT |
|
| 87 | + * |
|
| 88 | + * @var array with keys 'name' and 'ns' |
|
| 89 | + */ |
|
| 90 | + var $root; |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * internal tag nesting depth counter |
|
| 94 | - * |
|
| 95 | - * @var int |
|
| 96 | - * @access private |
|
| 97 | - */ |
|
| 98 | - var $depth = 0; |
|
| 92 | + /** |
|
| 93 | + * internal tag nesting depth counter |
|
| 94 | + * |
|
| 95 | + * @var int |
|
| 96 | + * @access private |
|
| 97 | + */ |
|
| 98 | + var $depth = 0; |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * On return whole request, if $store_request == true was specified in constructor |
|
| 102 | - * |
|
| 103 | - * @var string |
|
| 104 | - */ |
|
| 105 | - var $request; |
|
| 100 | + /** |
|
| 101 | + * On return whole request, if $store_request == true was specified in constructor |
|
| 102 | + * |
|
| 103 | + * @var string |
|
| 104 | + */ |
|
| 105 | + var $request; |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * constructor |
|
| 109 | - * |
|
| 110 | - * @access public |
|
| 111 | - * @param string $path |
|
| 112 | - * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
| 113 | - */ |
|
| 114 | - function __construct($path, $store_request=false) |
|
| 115 | - { |
|
| 116 | - // success state flag |
|
| 117 | - $this->success = true; |
|
| 107 | + /** |
|
| 108 | + * constructor |
|
| 109 | + * |
|
| 110 | + * @access public |
|
| 111 | + * @param string $path |
|
| 112 | + * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
| 113 | + */ |
|
| 114 | + function __construct($path, $store_request=false) |
|
| 115 | + { |
|
| 116 | + // success state flag |
|
| 117 | + $this->success = true; |
|
| 118 | 118 | |
| 119 | - // property storage array |
|
| 120 | - $this->props = array(); |
|
| 119 | + // property storage array |
|
| 120 | + $this->props = array(); |
|
| 121 | 121 | |
| 122 | - // internal tag depth counter |
|
| 123 | - $this->depth = 0; |
|
| 122 | + // internal tag depth counter |
|
| 123 | + $this->depth = 0; |
|
| 124 | 124 | |
| 125 | - // remember if any input was parsed |
|
| 126 | - $had_input = false; |
|
| 125 | + // remember if any input was parsed |
|
| 126 | + $had_input = false; |
|
| 127 | 127 | |
| 128 | - // open input stream |
|
| 129 | - $f_in = fopen($path, "r"); |
|
| 130 | - if (!$f_in) { |
|
| 131 | - $this->success = false; |
|
| 132 | - return; |
|
| 133 | - } |
|
| 128 | + // open input stream |
|
| 129 | + $f_in = fopen($path, "r"); |
|
| 130 | + if (!$f_in) { |
|
| 131 | + $this->success = false; |
|
| 132 | + return; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - // create XML parser |
|
| 136 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 135 | + // create XML parser |
|
| 136 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 137 | 137 | |
| 138 | - // set tag and data handlers |
|
| 139 | - xml_set_element_handler($xml_parser, |
|
| 140 | - array(&$this, "_startElement"), |
|
| 141 | - array(&$this, "_endElement")); |
|
| 138 | + // set tag and data handlers |
|
| 139 | + xml_set_element_handler($xml_parser, |
|
| 140 | + array(&$this, "_startElement"), |
|
| 141 | + array(&$this, "_endElement")); |
|
| 142 | 142 | |
| 143 | 143 | xml_set_character_data_handler($xml_parser, |
| 144 | - array(&$this,'_charData') |
|
| 145 | - ); |
|
| 144 | + array(&$this,'_charData') |
|
| 145 | + ); |
|
| 146 | 146 | |
| 147 | - // we want a case sensitive parser |
|
| 148 | - xml_parser_set_option($xml_parser, |
|
| 149 | - XML_OPTION_CASE_FOLDING, false); |
|
| 147 | + // we want a case sensitive parser |
|
| 148 | + xml_parser_set_option($xml_parser, |
|
| 149 | + XML_OPTION_CASE_FOLDING, false); |
|
| 150 | 150 | |
| 151 | - // parse input |
|
| 152 | - while ($this->success && !feof($f_in)) { |
|
| 153 | - $line = fgets($f_in); |
|
| 154 | - if ($store_request) $this->request .= $line; |
|
| 155 | - if (is_string($line)) { |
|
| 156 | - $had_input = true; |
|
| 157 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
| 158 | - } |
|
| 159 | - } |
|
| 151 | + // parse input |
|
| 152 | + while ($this->success && !feof($f_in)) { |
|
| 153 | + $line = fgets($f_in); |
|
| 154 | + if ($store_request) $this->request .= $line; |
|
| 155 | + if (is_string($line)) { |
|
| 156 | + $had_input = true; |
|
| 157 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - // finish parsing |
|
| 162 | - if ($had_input) { |
|
| 163 | - $this->success &= xml_parse($xml_parser, "", true); |
|
| 164 | - } |
|
| 161 | + // finish parsing |
|
| 162 | + if ($had_input) { |
|
| 163 | + $this->success &= xml_parse($xml_parser, "", true); |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - // free parser |
|
| 167 | - xml_parser_free($xml_parser); |
|
| 166 | + // free parser |
|
| 167 | + xml_parser_free($xml_parser); |
|
| 168 | 168 | |
| 169 | - // close input stream |
|
| 170 | - fclose($f_in); |
|
| 169 | + // close input stream |
|
| 170 | + fclose($f_in); |
|
| 171 | 171 | |
| 172 | - // if no input was parsed it was a request |
|
| 173 | - if(!count($this->props)) $this->props = "all"; // default |
|
| 174 | - } |
|
| 172 | + // if no input was parsed it was a request |
|
| 173 | + if(!count($this->props)) $this->props = "all"; // default |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * start tag handler |
|
| 179 | - * |
|
| 180 | - * @access private |
|
| 181 | - * @param resource parser |
|
| 182 | - * @param string tag name |
|
| 183 | - * @param array tag attributes |
|
| 184 | - */ |
|
| 185 | - function _startElement($parser, $name, $attrs) |
|
| 186 | - { |
|
| 187 | - // name space handling |
|
| 188 | - if (strstr($name, " ")) { |
|
| 189 | - list($ns, $tag) = explode(" ", $name); |
|
| 190 | - if ($ns == "") |
|
| 191 | - $this->success = false; |
|
| 192 | - } else { |
|
| 193 | - $ns = ""; |
|
| 194 | - $tag = $name; |
|
| 195 | - } |
|
| 177 | + /** |
|
| 178 | + * start tag handler |
|
| 179 | + * |
|
| 180 | + * @access private |
|
| 181 | + * @param resource parser |
|
| 182 | + * @param string tag name |
|
| 183 | + * @param array tag attributes |
|
| 184 | + */ |
|
| 185 | + function _startElement($parser, $name, $attrs) |
|
| 186 | + { |
|
| 187 | + // name space handling |
|
| 188 | + if (strstr($name, " ")) { |
|
| 189 | + list($ns, $tag) = explode(" ", $name); |
|
| 190 | + if ($ns == "") |
|
| 191 | + $this->success = false; |
|
| 192 | + } else { |
|
| 193 | + $ns = ""; |
|
| 194 | + $tag = $name; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - // record root tag |
|
| 198 | - if ($this->depth == 0) { |
|
| 199 | - $this->root = array('name' => $tag, 'xmlns' => $ns, 'attrs' => $attrs); |
|
| 200 | - } |
|
| 201 | - // special tags at level 1: <allprop> and <propname> |
|
| 202 | - if ($this->depth == 1) { |
|
| 203 | - $this->use = 'props'; |
|
| 204 | - switch ($tag) |
|
| 205 | - { |
|
| 206 | - case "allprop": |
|
| 207 | - $this->props = "all"; |
|
| 197 | + // record root tag |
|
| 198 | + if ($this->depth == 0) { |
|
| 199 | + $this->root = array('name' => $tag, 'xmlns' => $ns, 'attrs' => $attrs); |
|
| 200 | + } |
|
| 201 | + // special tags at level 1: <allprop> and <propname> |
|
| 202 | + if ($this->depth == 1) { |
|
| 203 | + $this->use = 'props'; |
|
| 204 | + switch ($tag) |
|
| 205 | + { |
|
| 206 | + case "allprop": |
|
| 207 | + $this->props = "all"; |
|
| 208 | 208 | break; |
| 209 | - case "propname": |
|
| 210 | - $this->props = "names"; |
|
| 211 | - break; |
|
| 212 | - case 'prop': |
|
| 213 | - break; |
|
| 214 | - case 'filter': |
|
| 215 | - $this->use = 'filters'; |
|
| 216 | - $this->filters['attrs'] = $attrs; // need attrs eg. <filters test="(anyof|alloff)"> |
|
| 217 | - break; |
|
| 218 | - default: |
|
| 219 | - $this->use = 'other'; |
|
| 220 | - break; |
|
| 221 | - } |
|
| 222 | - } |
|
| 209 | + case "propname": |
|
| 210 | + $this->props = "names"; |
|
| 211 | + break; |
|
| 212 | + case 'prop': |
|
| 213 | + break; |
|
| 214 | + case 'filter': |
|
| 215 | + $this->use = 'filters'; |
|
| 216 | + $this->filters['attrs'] = $attrs; // need attrs eg. <filters test="(anyof|alloff)"> |
|
| 217 | + break; |
|
| 218 | + default: |
|
| 219 | + $this->use = 'other'; |
|
| 220 | + break; |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | 223 | //echo "$this->depth: use=$this->use $ns:$tag attrs=".array2string($attrs)."\n"; |
| 224 | 224 | |
| 225 | - // requested properties are found at level 2 |
|
| 226 | - // CalDAV filters can be at deeper levels too and we need the attrs, same for other tags (eg. multiget href's) |
|
| 227 | - if ($this->depth == 2 || $this->use == 'filters' && $this->depth >= 2 || $this->use == 'other' || |
|
| 228 | - $this->use == 'props' && $this->depth >= 2) { |
|
| 229 | - $prop = array("name" => $tag); |
|
| 230 | - if ($ns) |
|
| 231 | - $prop["xmlns"] = $ns; |
|
| 232 | - if ($this->use != 'props' || $this->depth > 2) { |
|
| 233 | - $prop['attrs'] = $attrs; |
|
| 234 | - $prop['depth'] = $this->depth; |
|
| 235 | - } |
|
| 236 | - // collect sub-elements of props in the original props children attribute |
|
| 237 | - // eg. required for CalDAV <calendar-data><expand start="..." end="..."/></calendar-data> |
|
| 238 | - if ($this->use == 'props' && $this->depth > 2) |
|
| 239 | - { |
|
| 240 | - $this->last_prop['children'][$tag] = $prop; |
|
| 241 | - } |
|
| 242 | - else |
|
| 243 | - { |
|
| 244 | - // this can happen if we have allprop and prop in one propfind: |
|
| 245 | - // <allprop /><prop><blah /></prop>, eg. blah is not automatic returned by allprop |
|
| 246 | - if (!is_array($this->{$this->use}) && $this->{$this->use}) $this->{$this->use} = array($this->{$this->use}); |
|
| 247 | - $this->{$this->use}[] =& $prop; |
|
| 248 | - $this->last_prop =& $prop; |
|
| 249 | - unset($prop); |
|
| 250 | - } |
|
| 251 | - } |
|
| 225 | + // requested properties are found at level 2 |
|
| 226 | + // CalDAV filters can be at deeper levels too and we need the attrs, same for other tags (eg. multiget href's) |
|
| 227 | + if ($this->depth == 2 || $this->use == 'filters' && $this->depth >= 2 || $this->use == 'other' || |
|
| 228 | + $this->use == 'props' && $this->depth >= 2) { |
|
| 229 | + $prop = array("name" => $tag); |
|
| 230 | + if ($ns) |
|
| 231 | + $prop["xmlns"] = $ns; |
|
| 232 | + if ($this->use != 'props' || $this->depth > 2) { |
|
| 233 | + $prop['attrs'] = $attrs; |
|
| 234 | + $prop['depth'] = $this->depth; |
|
| 235 | + } |
|
| 236 | + // collect sub-elements of props in the original props children attribute |
|
| 237 | + // eg. required for CalDAV <calendar-data><expand start="..." end="..."/></calendar-data> |
|
| 238 | + if ($this->use == 'props' && $this->depth > 2) |
|
| 239 | + { |
|
| 240 | + $this->last_prop['children'][$tag] = $prop; |
|
| 241 | + } |
|
| 242 | + else |
|
| 243 | + { |
|
| 244 | + // this can happen if we have allprop and prop in one propfind: |
|
| 245 | + // <allprop /><prop><blah /></prop>, eg. blah is not automatic returned by allprop |
|
| 246 | + if (!is_array($this->{$this->use}) && $this->{$this->use}) $this->{$this->use} = array($this->{$this->use}); |
|
| 247 | + $this->{$this->use}[] =& $prop; |
|
| 248 | + $this->last_prop =& $prop; |
|
| 249 | + unset($prop); |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - // increment depth count |
|
| 254 | - $this->depth++; |
|
| 255 | - } |
|
| 253 | + // increment depth count |
|
| 254 | + $this->depth++; |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | 257 | |
| 258 | - /** |
|
| 259 | - * end tag handler |
|
| 260 | - * |
|
| 261 | - * @access private |
|
| 262 | - * @param resource parser |
|
| 263 | - * @param string tag name |
|
| 264 | - */ |
|
| 265 | - function _endElement($parser, $name) |
|
| 266 | - { |
|
| 267 | - // here we only need to decrement the depth count |
|
| 268 | - $this->depth--; |
|
| 269 | - } |
|
| 258 | + /** |
|
| 259 | + * end tag handler |
|
| 260 | + * |
|
| 261 | + * @access private |
|
| 262 | + * @param resource parser |
|
| 263 | + * @param string tag name |
|
| 264 | + */ |
|
| 265 | + function _endElement($parser, $name) |
|
| 266 | + { |
|
| 267 | + // here we only need to decrement the depth count |
|
| 268 | + $this->depth--; |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | 271 | |
| 272 | - /** |
|
| 273 | - * char data handler for non prop tags, eg. href's in CalDAV multiget, or filter contents |
|
| 274 | - * |
|
| 275 | - * @access private |
|
| 276 | - * @param resource parser |
|
| 277 | - * @param string character data |
|
| 278 | - */ |
|
| 279 | - function _charData($parser, $data) |
|
| 280 | - { |
|
| 281 | - if ($this->use != 'props' && ($n = count($this->{$this->use})) && ($data = trim($data))) { |
|
| 282 | - $this->{$this->use}[$n-1]['data'] = $data; |
|
| 283 | - } |
|
| 284 | - } |
|
| 272 | + /** |
|
| 273 | + * char data handler for non prop tags, eg. href's in CalDAV multiget, or filter contents |
|
| 274 | + * |
|
| 275 | + * @access private |
|
| 276 | + * @param resource parser |
|
| 277 | + * @param string character data |
|
| 278 | + */ |
|
| 279 | + function _charData($parser, $data) |
|
| 280 | + { |
|
| 281 | + if ($this->use != 'props' && ($n = count($this->{$this->use})) && ($data = trim($data))) { |
|
| 282 | + $this->{$this->use}[$n-1]['data'] = $data; |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | 285 | } |