Commit f465d83130d9f27d835c0524c228f2ca651d06af
1 parent
0b4fa04d
BBS-458
"Update WebDAV PEAR class" Fixed. Moved webdav class into the ktwebdav directory to avoid conflicts with the Baobab modified webdav class. Upgraded the ktwebdav to version 1.0.0RC4(beta). Committed by: Megan Watson Reviewed by: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7613 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
5 changed files
with
691 additions
and
599 deletions
ktwebdav/ktwebdav.php
| ... | ... | @@ -6,39 +6,40 @@ |
| 6 | 6 | * KnowledgeTree Open Source Edition |
| 7 | 7 | * Document Management Made Simple |
| 8 | 8 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 9 | - * | |
| 9 | + * | |
| 10 | 10 | * This program is free software; you can redistribute it and/or modify it under |
| 11 | 11 | * the terms of the GNU General Public License version 3 as published by the |
| 12 | 12 | * Free Software Foundation. |
| 13 | - * | |
| 13 | + * | |
| 14 | 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 17 | 17 | * details. |
| 18 | - * | |
| 18 | + * | |
| 19 | 19 | * You should have received a copy of the GNU General Public License |
| 20 | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | - * | |
| 21 | + * | |
| 22 | 22 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 23 | 23 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 24 | - * | |
| 24 | + * | |
| 25 | 25 | * The interactive user interfaces in modified source and object code versions |
| 26 | 26 | * of this program must display Appropriate Legal Notices, as required under |
| 27 | 27 | * Section 5 of the GNU General Public License version 3. |
| 28 | - * | |
| 28 | + * | |
| 29 | 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 30 | 30 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 31 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 31 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | 32 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 33 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | - * copyright notice. | |
| 33 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | + * copyright notice. | |
| 35 | 35 | * Contributor( s): ______________________________________ |
| 36 | 36 | * |
| 37 | 37 | */ |
| 38 | 38 | |
| 39 | + $webdav_pear_path = 'thirdparty/pear'; | |
| 39 | 40 | $kt_pear_path = '../thirdparty/pear'; |
| 40 | 41 | $include_path = ini_get('include_path'); |
| 41 | - ini_set('include_path', $kt_pear_path . PATH_SEPARATOR . $include_path); | |
| 42 | + ini_set('include_path', $webdav_pear_path . PATH_SEPARATOR . $kt_pear_path . PATH_SEPARATOR . $include_path); | |
| 42 | 43 | |
| 43 | 44 | require_once "lib/KTWebDAVServer.inc.php"; |
| 44 | 45 | $ktwebdav = new KTWebDAVServer(); | ... | ... |
thirdparty/pear/HTTP/WebDAV/Server.php renamed to ktwebdav/thirdparty/pear/HTTP/WebDAV/Server.php
| ... | ... | @@ -17,22 +17,20 @@ |
| 17 | 17 | // | Christian Stocker <chregu@bitflux.ch> | |
| 18 | 18 | // +----------------------------------------------------------------------+ |
| 19 | 19 | // |
| 20 | -// $Id$ | |
| 20 | +// $Id: Server.php,v 1.56 2006/10/10 11:53:16 hholzgra Exp $ | |
| 21 | 21 | // |
| 22 | 22 | require_once "HTTP/WebDAV/Tools/_parse_propfind.php"; |
| 23 | 23 | require_once "HTTP/WebDAV/Tools/_parse_proppatch.php"; |
| 24 | 24 | require_once "HTTP/WebDAV/Tools/_parse_lockinfo.php"; |
| 25 | 25 | |
| 26 | - | |
| 27 | - | |
| 28 | 26 | /** |
| 29 | 27 | * Virtual base class for implementing WebDAV servers |
| 30 | 28 | * |
| 31 | 29 | * WebDAV server base class, needs to be extended to do useful work |
| 32 | 30 | * |
| 33 | 31 | * @package HTTP_WebDAV_Server |
| 34 | - * @author Hartmut Holzgraefe <hholzgra@php.net> | |
| 35 | - * @version 0.99.1dev | |
| 32 | + * @author Hartmut Holzgraefe <hholzgra@php.net> | |
| 33 | + * @version @package_version@ | |
| 36 | 34 | */ |
| 37 | 35 | class HTTP_WebDAV_Server |
| 38 | 36 | { |
| ... | ... | @@ -44,8 +42,8 @@ class HTTP_WebDAV_Server |
| 44 | 42 | * @var string |
| 45 | 43 | */ |
| 46 | 44 | var $uri; |
| 47 | - | |
| 48 | - | |
| 45 | + | |
| 46 | + | |
| 49 | 47 | /** |
| 50 | 48 | * base URI for this request |
| 51 | 49 | * |
| ... | ... | @@ -96,6 +94,16 @@ class HTTP_WebDAV_Server |
| 96 | 94 | */ |
| 97 | 95 | var $_prop_encoding = "utf-8"; |
| 98 | 96 | |
| 97 | + /** | |
| 98 | + * Copy of $_SERVER superglobal array | |
| 99 | + * | |
| 100 | + * Derived classes may extend the constructor to | |
| 101 | + * modify its contents | |
| 102 | + * | |
| 103 | + * @var array | |
| 104 | + */ | |
| 105 | + var $_SERVER; | |
| 106 | + | |
| 99 | 107 | // }}} |
| 100 | 108 | |
| 101 | 109 | // {{{ Constructor |
| ... | ... | @@ -109,6 +117,10 @@ class HTTP_WebDAV_Server |
| 109 | 117 | { |
| 110 | 118 | // PHP messages destroy XML output -> switch them off |
| 111 | 119 | ini_set("display_errors", 0); |
| 120 | + | |
| 121 | + // copy $_SERVER variables to local _SERVER array | |
| 122 | + // so that derived classes can simply modify these | |
| 123 | + $this->_SERVER = $_SERVER; | |
| 112 | 124 | } |
| 113 | 125 | |
| 114 | 126 | // }}} |
| ... | ... | @@ -124,22 +136,53 @@ class HTTP_WebDAV_Server |
| 124 | 136 | */ |
| 125 | 137 | function ServeRequest() |
| 126 | 138 | { |
| 139 | + // prevent warning in litmus check 'delete_fragment' | |
| 140 | + if (strstr($this->_SERVER["REQUEST_URI"], '#')) { | |
| 141 | + $this->http_status("400 Bad Request"); | |
| 142 | + return; | |
| 143 | + } | |
| 144 | + | |
| 127 | 145 | // default uri is the complete request uri |
| 128 | - $uri = (@$_SERVER["HTTPS"] === "on" ? "https:" : "http:"); | |
| 129 | - $uri.= "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]"; | |
| 146 | + $uri = (@$this->_SERVER["HTTPS"] === "on" ? "https:" : "http:"); | |
| 147 | + $uri.= "//$this->_SERVER[HTTP_HOST]$this->_SERVER[SCRIPT_NAME]"; | |
| 130 | 148 | |
| 149 | + $path_info = empty($this->_SERVER["PATH_INFO"]) ? "/" : $this->_SERVER["PATH_INFO"]; | |
| 150 | + | |
| 131 | 151 | $this->base_uri = $uri; |
| 132 | - $this->uri = $uri . $_SERVER["PATH_INFO"]; | |
| 152 | + $this->uri = $uri . $path_info; | |
| 133 | 153 | |
| 154 | + // set path | |
| 155 | + $this->path = $this->_urldecode($path_info); | |
| 156 | + if (!strlen($this->path)) { | |
| 157 | + if ($this->_SERVER["REQUEST_METHOD"] == "GET") { | |
| 158 | + // redirect clients that try to GET a collection | |
| 159 | + // WebDAV clients should never try this while | |
| 160 | + // regular HTTP clients might ... | |
| 161 | + header("Location: ".$this->base_uri."/"); | |
| 162 | + return; | |
| 163 | + } else { | |
| 164 | + // if a WebDAV client didn't give a path we just assume '/' | |
| 165 | + $this->path = "/"; | |
| 166 | + } | |
| 167 | + } | |
| 168 | + | |
| 169 | + if (ini_get("magic_quotes_gpc")) { | |
| 170 | + $this->path = stripslashes($this->path); | |
| 171 | + } | |
| 172 | + | |
| 173 | + | |
| 134 | 174 | // identify ourselves |
| 135 | 175 | if (empty($this->dav_powered_by)) { |
| 136 | 176 | header("X-Dav-Powered-By: PHP class: ".get_class($this)); |
| 137 | 177 | } else { |
| 138 | - header("X-Dav-Powered-By: ".$this->dav_powered_by ); | |
| 178 | + header("X-Dav-Powered-By: ".$this->dav_powered_by); | |
| 139 | 179 | } |
| 140 | 180 | |
| 141 | 181 | // check authentication |
| 142 | - if (!$this->_check_auth()) { | |
| 182 | + // for the motivation for not checking OPTIONS requests on / see | |
| 183 | + // http://pear.php.net/bugs/bug.php?id=5363 | |
| 184 | + if ( ( !(($this->_SERVER['REQUEST_METHOD'] == 'OPTIONS') && ($this->path == "/"))) | |
| 185 | + && (!$this->_check_auth())) { | |
| 143 | 186 | // RFC2518 says we must use Digest instead of Basic |
| 144 | 187 | // but Microsoft Clients do not support Digest |
| 145 | 188 | // and we don't support NTLM and Kerberos |
| ... | ... | @@ -154,33 +197,12 @@ class HTTP_WebDAV_Server |
| 154 | 197 | } |
| 155 | 198 | |
| 156 | 199 | // check |
| 157 | - if(! $this->_check_if_header_conditions()) { | |
| 158 | - $this->http_status("412 Precondition failed"); | |
| 200 | + if (! $this->_check_if_header_conditions()) { | |
| 159 | 201 | return; |
| 160 | 202 | } |
| 161 | 203 | |
| 162 | - // set path | |
| 163 | - $this->path = $this->_urldecode($_SERVER["PATH_INFO"]); | |
| 164 | - if (!strlen($this->path)) { | |
| 165 | - if ($_SERVER["REQUEST_METHOD"] == "GET") { | |
| 166 | - // redirect clients that try to GET a collection | |
| 167 | - // WebDAV clients should never try this while | |
| 168 | - // regular HTTP clients might ... | |
| 169 | - header("Location: ".$this->base_uri."/"); | |
| 170 | - exit; | |
| 171 | - } else { | |
| 172 | - // if a WebDAV client didn't give a path we just assume '/' | |
| 173 | - $this->path = "/"; | |
| 174 | - } | |
| 175 | - } | |
| 176 | - | |
| 177 | - if(ini_get("magic_quotes_gpc")) { | |
| 178 | - $this->path = stripslashes($this->path); | |
| 179 | - } | |
| 180 | - | |
| 181 | - | |
| 182 | 204 | // detect requested method names |
| 183 | - $method = strtolower($_SERVER["REQUEST_METHOD"]); | |
| 205 | + $method = strtolower($this->_SERVER["REQUEST_METHOD"]); | |
| 184 | 206 | $wrapper = "http_".$method; |
| 185 | 207 | |
| 186 | 208 | // activate HEAD emulation by GET if no HEAD method found |
| ... | ... | @@ -191,7 +213,7 @@ class HTTP_WebDAV_Server |
| 191 | 213 | if (method_exists($this, $wrapper) && ($method == "options" || method_exists($this, $method))) { |
| 192 | 214 | $this->$wrapper(); // call method by name |
| 193 | 215 | } else { // method not found/implemented |
| 194 | - if ($_SERVER["REQUEST_METHOD"] == "LOCK") { | |
| 216 | + if ($this->_SERVER["REQUEST_METHOD"] == "LOCK") { | |
| 195 | 217 | $this->http_status("412 Precondition failed"); |
| 196 | 218 | } else { |
| 197 | 219 | $this->http_status("405 Method not allowed"); |
| ... | ... | @@ -224,11 +246,11 @@ class HTTP_WebDAV_Server |
| 224 | 246 | */ |
| 225 | 247 | |
| 226 | 248 | /* abstract |
| 227 | - function GET(&$params) | |
| 228 | - { | |
| 229 | - // dummy entry for PHPDoc | |
| 230 | - } | |
| 231 | - */ | |
| 249 | + function GET(&$params) | |
| 250 | + { | |
| 251 | + // dummy entry for PHPDoc | |
| 252 | + } | |
| 253 | + */ | |
| 232 | 254 | |
| 233 | 255 | // }}} |
| 234 | 256 | |
| ... | ... | @@ -244,10 +266,10 @@ class HTTP_WebDAV_Server |
| 244 | 266 | */ |
| 245 | 267 | |
| 246 | 268 | /* abstract |
| 247 | - function PUT() | |
| 248 | - { | |
| 249 | - // dummy entry for PHPDoc | |
| 250 | - } | |
| 269 | + function PUT() | |
| 270 | + { | |
| 271 | + // dummy entry for PHPDoc | |
| 272 | + } | |
| 251 | 273 | */ |
| 252 | 274 | |
| 253 | 275 | // }}} |
| ... | ... | @@ -265,11 +287,11 @@ class HTTP_WebDAV_Server |
| 265 | 287 | */ |
| 266 | 288 | |
| 267 | 289 | /* abstract |
| 268 | - function COPY() | |
| 269 | - { | |
| 270 | - // dummy entry for PHPDoc | |
| 271 | - } | |
| 272 | - */ | |
| 290 | + function COPY() | |
| 291 | + { | |
| 292 | + // dummy entry for PHPDoc | |
| 293 | + } | |
| 294 | + */ | |
| 273 | 295 | |
| 274 | 296 | // }}} |
| 275 | 297 | |
| ... | ... | @@ -286,11 +308,11 @@ class HTTP_WebDAV_Server |
| 286 | 308 | */ |
| 287 | 309 | |
| 288 | 310 | /* abstract |
| 289 | - function MOVE() | |
| 290 | - { | |
| 291 | - // dummy entry for PHPDoc | |
| 292 | - } | |
| 293 | - */ | |
| 311 | + function MOVE() | |
| 312 | + { | |
| 313 | + // dummy entry for PHPDoc | |
| 314 | + } | |
| 315 | + */ | |
| 294 | 316 | |
| 295 | 317 | // }}} |
| 296 | 318 | |
| ... | ... | @@ -307,11 +329,11 @@ class HTTP_WebDAV_Server |
| 307 | 329 | */ |
| 308 | 330 | |
| 309 | 331 | /* abstract |
| 310 | - function DELETE() | |
| 311 | - { | |
| 312 | - // dummy entry for PHPDoc | |
| 313 | - } | |
| 314 | - */ | |
| 332 | + function DELETE() | |
| 333 | + { | |
| 334 | + // dummy entry for PHPDoc | |
| 335 | + } | |
| 336 | + */ | |
| 315 | 337 | // }}} |
| 316 | 338 | |
| 317 | 339 | // {{{ PROPFIND() |
| ... | ... | @@ -327,11 +349,11 @@ class HTTP_WebDAV_Server |
| 327 | 349 | */ |
| 328 | 350 | |
| 329 | 351 | /* abstract |
| 330 | - function PROPFIND() | |
| 331 | - { | |
| 332 | - // dummy entry for PHPDoc | |
| 333 | - } | |
| 334 | - */ | |
| 352 | + function PROPFIND() | |
| 353 | + { | |
| 354 | + // dummy entry for PHPDoc | |
| 355 | + } | |
| 356 | + */ | |
| 335 | 357 | |
| 336 | 358 | // }}} |
| 337 | 359 | |
| ... | ... | @@ -348,11 +370,11 @@ class HTTP_WebDAV_Server |
| 348 | 370 | */ |
| 349 | 371 | |
| 350 | 372 | /* abstract |
| 351 | - function PROPPATCH() | |
| 352 | - { | |
| 353 | - // dummy entry for PHPDoc | |
| 354 | - } | |
| 355 | - */ | |
| 373 | + function PROPPATCH() | |
| 374 | + { | |
| 375 | + // dummy entry for PHPDoc | |
| 376 | + } | |
| 377 | + */ | |
| 356 | 378 | // }}} |
| 357 | 379 | |
| 358 | 380 | // {{{ LOCK() |
| ... | ... | @@ -368,11 +390,11 @@ class HTTP_WebDAV_Server |
| 368 | 390 | */ |
| 369 | 391 | |
| 370 | 392 | /* abstract |
| 371 | - function LOCK() | |
| 372 | - { | |
| 373 | - // dummy entry for PHPDoc | |
| 374 | - } | |
| 375 | - */ | |
| 393 | + function LOCK() | |
| 394 | + { | |
| 395 | + // dummy entry for PHPDoc | |
| 396 | + } | |
| 397 | + */ | |
| 376 | 398 | // }}} |
| 377 | 399 | |
| 378 | 400 | // {{{ UNLOCK() |
| ... | ... | @@ -388,11 +410,11 @@ class HTTP_WebDAV_Server |
| 388 | 410 | */ |
| 389 | 411 | |
| 390 | 412 | /* abstract |
| 391 | - function UNLOCK() | |
| 392 | - { | |
| 393 | - // dummy entry for PHPDoc | |
| 394 | - } | |
| 395 | - */ | |
| 413 | + function UNLOCK() | |
| 414 | + { | |
| 415 | + // dummy entry for PHPDoc | |
| 416 | + } | |
| 417 | + */ | |
| 396 | 418 | // }}} |
| 397 | 419 | |
| 398 | 420 | // }}} |
| ... | ... | @@ -414,10 +436,10 @@ class HTTP_WebDAV_Server |
| 414 | 436 | */ |
| 415 | 437 | |
| 416 | 438 | /* abstract |
| 417 | - function checkAuth($type, $username, $password) | |
| 418 | - { | |
| 419 | - // dummy entry for PHPDoc | |
| 420 | - } | |
| 439 | + function checkAuth($type, $username, $password) | |
| 440 | + { | |
| 441 | + // dummy entry for PHPDoc | |
| 442 | + } | |
| 421 | 443 | */ |
| 422 | 444 | |
| 423 | 445 | // }}} |
| ... | ... | @@ -437,11 +459,11 @@ class HTTP_WebDAV_Server |
| 437 | 459 | */ |
| 438 | 460 | |
| 439 | 461 | /* abstract |
| 440 | - function checklock($resource) | |
| 441 | - { | |
| 442 | - // dummy entry for PHPDoc | |
| 443 | - } | |
| 444 | - */ | |
| 462 | + function checklock($resource) | |
| 463 | + { | |
| 464 | + // dummy entry for PHPDoc | |
| 465 | + } | |
| 466 | + */ | |
| 445 | 467 | |
| 446 | 468 | // }}} |
| 447 | 469 | |
| ... | ... | @@ -478,7 +500,7 @@ class HTTP_WebDAV_Server |
| 478 | 500 | |
| 479 | 501 | // tell clients what we found |
| 480 | 502 | $this->http_status("200 OK"); |
| 481 | - header("DAV: " .join("," , $dav)); | |
| 503 | + header("DAV: " .join(", ", $dav)); | |
| 482 | 504 | header("Allow: ".join(", ", $allow)); |
| 483 | 505 | |
| 484 | 506 | header("Content-length: 0"); |
| ... | ... | @@ -498,11 +520,13 @@ class HTTP_WebDAV_Server |
| 498 | 520 | function http_PROPFIND() |
| 499 | 521 | { |
| 500 | 522 | $options = Array(); |
| 523 | + $files = Array(); | |
| 524 | + | |
| 501 | 525 | $options["path"] = $this->path; |
| 502 | 526 | |
| 503 | 527 | // search depth from header (default is "infinity) |
| 504 | - if (isset($_SERVER['HTTP_DEPTH'])) { | |
| 505 | - $options["depth"] = $_SERVER["HTTP_DEPTH"]; | |
| 528 | + if (isset($this->_SERVER['HTTP_DEPTH'])) { | |
| 529 | + $options["depth"] = $this->_SERVER["HTTP_DEPTH"]; | |
| 506 | 530 | } else { |
| 507 | 531 | $options["depth"] = "infinity"; |
| 508 | 532 | } |
| ... | ... | @@ -514,11 +538,32 @@ class HTTP_WebDAV_Server |
| 514 | 538 | return; |
| 515 | 539 | } |
| 516 | 540 | $options['props'] = $propinfo->props; |
| 517 | - | |
| 541 | + | |
| 518 | 542 | // call user handler |
| 519 | 543 | if (!$this->PROPFIND($options, $files)) { |
| 520 | - $this->http_status("404 Not Found"); | |
| 521 | - return; | |
| 544 | + $files = array("files" => array()); | |
| 545 | + if (method_exists($this, "checkLock")) { | |
| 546 | + // is locked? | |
| 547 | + $lock = $this->checkLock($this->path); | |
| 548 | + | |
| 549 | + if (is_array($lock) && count($lock)) { | |
| 550 | + $created = isset($lock['created']) ? $lock['created'] : time(); | |
| 551 | + $modified = isset($lock['modified']) ? $lock['modified'] : time(); | |
| 552 | + $files['files'][] = array("path" => $this->_slashify($this->path), | |
| 553 | + "props" => array($this->mkprop("displayname", $this->path), | |
| 554 | + $this->mkprop("creationdate", $created), | |
| 555 | + $this->mkprop("getlastmodified", $modified), | |
| 556 | + $this->mkprop("resourcetype", ""), | |
| 557 | + $this->mkprop("getcontenttype", ""), | |
| 558 | + $this->mkprop("getcontentlength", 0)) | |
| 559 | + ); | |
| 560 | + } | |
| 561 | + } | |
| 562 | + | |
| 563 | + if (empty($files['files'])) { | |
| 564 | + $this->http_status("404 Not Found"); | |
| 565 | + return; | |
| 566 | + } | |
| 522 | 567 | } |
| 523 | 568 | |
| 524 | 569 | // collect namespaces here |
| ... | ... | @@ -528,7 +573,7 @@ class HTTP_WebDAV_Server |
| 528 | 573 | $ns_defs = "xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\""; |
| 529 | 574 | |
| 530 | 575 | // now we loop over all returned file entries |
| 531 | - foreach($files["files"] as $filekey => $file) { | |
| 576 | + foreach ($files["files"] as $filekey => $file) { | |
| 532 | 577 | |
| 533 | 578 | // nothing to do if no properties were returend for a file |
| 534 | 579 | if (!isset($file["props"]) || !is_array($file["props"])) { |
| ... | ... | @@ -536,7 +581,7 @@ class HTTP_WebDAV_Server |
| 536 | 581 | } |
| 537 | 582 | |
| 538 | 583 | // now loop over all returned properties |
| 539 | - foreach($file["props"] as $key => $prop) { | |
| 584 | + foreach ($file["props"] as $key => $prop) { | |
| 540 | 585 | // as a convenience feature we do not require that user handlers |
| 541 | 586 | // restrict returned properties to the requested ones |
| 542 | 587 | // here we strip all unrequested entries out of the response |
| ... | ... | @@ -556,9 +601,9 @@ class HTTP_WebDAV_Server |
| 556 | 601 | $found = false; |
| 557 | 602 | |
| 558 | 603 | // search property name in requested properties |
| 559 | - foreach((array)$options["props"] as $reqprop) { | |
| 604 | + foreach ((array)$options["props"] as $reqprop) { | |
| 560 | 605 | if ( $reqprop["name"] == $prop["name"] |
| 561 | - && $reqprop["xmlns"] == $prop["ns"]) { | |
| 606 | + && @$reqprop["xmlns"] == $prop["ns"]) { | |
| 562 | 607 | $found = true; |
| 563 | 608 | break; |
| 564 | 609 | } |
| ... | ... | @@ -587,26 +632,26 @@ class HTTP_WebDAV_Server |
| 587 | 632 | // we also need to add empty entries for properties that were requested |
| 588 | 633 | // but for which no values where returned by the user handler |
| 589 | 634 | if (is_array($options['props'])) { |
| 590 | - foreach($options["props"] as $reqprop) { | |
| 591 | - if($reqprop['name']=="") continue; // skip empty entries | |
| 635 | + foreach ($options["props"] as $reqprop) { | |
| 636 | + if ($reqprop['name']=="") continue; // skip empty entries | |
| 592 | 637 | |
| 593 | 638 | $found = false; |
| 594 | 639 | |
| 595 | 640 | // check if property exists in result |
| 596 | - foreach($file["props"] as $prop) { | |
| 641 | + foreach ($file["props"] as $prop) { | |
| 597 | 642 | if ( $reqprop["name"] == $prop["name"] |
| 598 | - && $reqprop["xmlns"] == $prop["ns"]) { | |
| 643 | + && @$reqprop["xmlns"] == $prop["ns"]) { | |
| 599 | 644 | $found = true; |
| 600 | 645 | break; |
| 601 | 646 | } |
| 602 | 647 | } |
| 603 | 648 | |
| 604 | 649 | if (!$found) { |
| 605 | - if($reqprop["xmlns"]==="DAV:" && $reqprop["name"]==="lockdiscovery") { | |
| 650 | + if ($reqprop["xmlns"]==="DAV:" && $reqprop["name"]==="lockdiscovery") { | |
| 606 | 651 | // lockdiscovery is handled by the base class |
| 607 | 652 | $files["files"][$filekey]["props"][] |
| 608 | 653 | = $this->mkprop("DAV:", |
| 609 | - "lockdiscovery" , | |
| 654 | + "lockdiscovery", | |
| 610 | 655 | $this->lockdiscovery($files["files"][$filekey]['path'])); |
| 611 | 656 | } else { |
| 612 | 657 | // add empty value for this property |
| ... | ... | @@ -633,15 +678,18 @@ class HTTP_WebDAV_Server |
| 633 | 678 | echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; |
| 634 | 679 | echo "<D:multistatus xmlns:D=\"DAV:\">\n"; |
| 635 | 680 | |
| 636 | - foreach($files["files"] as $file) { | |
| 681 | + foreach ($files["files"] as $file) { | |
| 637 | 682 | // ignore empty or incomplete entries |
| 638 | - if(!is_array($file) || empty($file) || !isset($file["path"])) continue; | |
| 683 | + if (!is_array($file) || empty($file) || !isset($file["path"])) continue; | |
| 639 | 684 | $path = $file['path']; |
| 640 | - if(!is_string($path) || $path==="") continue; | |
| 685 | + if (!is_string($path) || $path==="") continue; | |
| 641 | 686 | |
| 642 | 687 | echo " <D:response $ns_defs>\n"; |
| 643 | 688 | |
| 644 | - $href = $this->_slashify($this->_mergePathes($_SERVER['SCRIPT_NAME'], $path)); | |
| 689 | + /* TODO right now the user implementation has to make sure | |
| 690 | + collections end in a slash, this should be done in here | |
| 691 | + by checking the resource attribute */ | |
| 692 | + $href = $this->_mergePathes($this->_SERVER['SCRIPT_NAME'], $path); | |
| 645 | 693 | |
| 646 | 694 | echo " <D:href>$href</D:href>\n"; |
| 647 | 695 | |
| ... | ... | @@ -650,16 +698,16 @@ class HTTP_WebDAV_Server |
| 650 | 698 | echo " <D:propstat>\n"; |
| 651 | 699 | echo " <D:prop>\n"; |
| 652 | 700 | |
| 653 | - foreach($file["props"] as $key => $prop) { | |
| 701 | + foreach ($file["props"] as $key => $prop) { | |
| 654 | 702 | |
| 655 | 703 | if (!is_array($prop)) continue; |
| 656 | 704 | if (!isset($prop["name"])) continue; |
| 657 | 705 | |
| 658 | 706 | if (!isset($prop["val"]) || $prop["val"] === "" || $prop["val"] === false) { |
| 659 | 707 | // empty properties (cannot use empty() for check as "0" is a legal value here) |
| 660 | - if($prop["ns"]=="DAV:") { | |
| 708 | + if ($prop["ns"]=="DAV:") { | |
| 661 | 709 | echo " <D:$prop[name]/>\n"; |
| 662 | - } else if(!empty($prop["ns"])) { | |
| 710 | + } else if (!empty($prop["ns"])) { | |
| 663 | 711 | echo " <".$ns_hash[$prop["ns"]].":$prop[name]/>\n"; |
| 664 | 712 | } else { |
| 665 | 713 | echo " <$prop[name] xmlns=\"\"/>"; |
| ... | ... | @@ -669,7 +717,7 @@ class HTTP_WebDAV_Server |
| 669 | 717 | switch ($prop["name"]) { |
| 670 | 718 | case "creationdate": |
| 671 | 719 | echo " <D:creationdate ns0:dt=\"dateTime.tz\">" |
| 672 | - . gmdate("Y-m-d\\TH:i:s\\Z",$prop['val']) | |
| 720 | + . gmdate("Y-m-d\\TH:i:s\\Z", $prop['val']) | |
| 673 | 721 | . "</D:creationdate>\n"; |
| 674 | 722 | break; |
| 675 | 723 | case "getlastmodified": |
| ... | ... | @@ -718,7 +766,7 @@ class HTTP_WebDAV_Server |
| 718 | 766 | echo " <D:propstat>\n"; |
| 719 | 767 | echo " <D:prop>\n"; |
| 720 | 768 | |
| 721 | - foreach($file["noprops"] as $key => $prop) { | |
| 769 | + foreach ($file["noprops"] as $key => $prop) { | |
| 722 | 770 | if ($prop["ns"] == "DAV:") { |
| 723 | 771 | echo " <D:$prop[name]/>\n"; |
| 724 | 772 | } else if ($prop["ns"] == "") { |
| ... | ... | @@ -752,8 +800,9 @@ class HTTP_WebDAV_Server |
| 752 | 800 | */ |
| 753 | 801 | function http_PROPPATCH() |
| 754 | 802 | { |
| 755 | - if($this->_check_lock_status($this->path)) { | |
| 803 | + if ($this->_check_lock_status($this->path)) { | |
| 756 | 804 | $options = Array(); |
| 805 | + | |
| 757 | 806 | $options["path"] = $this->path; |
| 758 | 807 | |
| 759 | 808 | $propinfo = new _parse_proppatch("php://input"); |
| ... | ... | @@ -774,9 +823,9 @@ class HTTP_WebDAV_Server |
| 774 | 823 | |
| 775 | 824 | echo "<D:multistatus xmlns:D=\"DAV:\">\n"; |
| 776 | 825 | echo " <D:response>\n"; |
| 777 | - echo " <D:href>".$this->_urlencode($this->_mergePathes($_SERVER["SCRIPT_NAME"], $this->path))."</D:href>\n"; | |
| 826 | + echo " <D:href>".$this->_urlencode($this->_mergePathes($this->_SERVER["SCRIPT_NAME"], $this->path))."</D:href>\n"; | |
| 778 | 827 | |
| 779 | - foreach($options["props"] as $prop) { | |
| 828 | + foreach ($options["props"] as $prop) { | |
| 780 | 829 | echo " <D:propstat>\n"; |
| 781 | 830 | echo " <D:prop><$prop[name] xmlns=\"$prop[ns]\"/></D:prop>\n"; |
| 782 | 831 | echo " <D:status>HTTP/1.1 $prop[status]</D:status>\n"; |
| ... | ... | @@ -810,6 +859,7 @@ class HTTP_WebDAV_Server |
| 810 | 859 | function http_MKCOL() |
| 811 | 860 | { |
| 812 | 861 | $options = Array(); |
| 862 | + | |
| 813 | 863 | $options["path"] = $this->path; |
| 814 | 864 | |
| 815 | 865 | $stat = $this->MKCOL($options); |
| ... | ... | @@ -831,7 +881,7 @@ class HTTP_WebDAV_Server |
| 831 | 881 | function http_GET() |
| 832 | 882 | { |
| 833 | 883 | // TODO check for invalid stream |
| 834 | - $options = Array(); | |
| 884 | + $options = Array(); | |
| 835 | 885 | $options["path"] = $this->path; |
| 836 | 886 | |
| 837 | 887 | $this->_get_ranges($options); |
| ... | ... | @@ -861,7 +911,7 @@ class HTTP_WebDAV_Server |
| 861 | 911 | fseek($options['stream'], $range['start'], SEEK_SET); |
| 862 | 912 | if (feof($options['stream'])) { |
| 863 | 913 | $this->http_status("416 Requested range not satisfiable"); |
| 864 | - exit; | |
| 914 | + return; | |
| 865 | 915 | } |
| 866 | 916 | |
| 867 | 917 | if (isset($range['end'])) { |
| ... | ... | @@ -872,14 +922,14 @@ class HTTP_WebDAV_Server |
| 872 | 922 | . (isset($options['size']) ? $options['size'] : "*")); |
| 873 | 923 | while ($size && !feof($options['stream'])) { |
| 874 | 924 | $buffer = fread($options['stream'], 4096); |
| 875 | - $size -= strlen($buffer); | |
| 925 | + $size -= strlen($buffer); | |
| 876 | 926 | echo $buffer; |
| 877 | 927 | } |
| 878 | 928 | } else { |
| 879 | 929 | $this->http_status("206 partial"); |
| 880 | 930 | if (isset($options['size'])) { |
| 881 | 931 | header("Content-length: ".($options['size'] - $range['start'])); |
| 882 | - header("Content-range: $start-$end/" | |
| 932 | + header("Content-range: ".$range['start']."-".$range['end']."/" | |
| 883 | 933 | . (isset($options['size']) ? $options['size'] : "*")); |
| 884 | 934 | } |
| 885 | 935 | fpassthru($options['stream']); |
| ... | ... | @@ -894,21 +944,21 @@ class HTTP_WebDAV_Server |
| 894 | 944 | foreach ($options['ranges'] as $range) { |
| 895 | 945 | // TODO what if size unknown? 500? |
| 896 | 946 | if (isset($range['start'])) { |
| 897 | - $from = $range['start']; | |
| 898 | - $to = !empty($range['end']) ? $range['end'] : $options['size']-1; | |
| 947 | + $from = $range['start']; | |
| 948 | + $to = !empty($range['end']) ? $range['end'] : $options['size']-1; | |
| 899 | 949 | } else { |
| 900 | 950 | $from = $options['size'] - $range['last']-1; |
| 901 | - $to = $options['size'] -1; | |
| 951 | + $to = $options['size'] -1; | |
| 902 | 952 | } |
| 903 | 953 | $total = isset($options['size']) ? $options['size'] : "*"; |
| 904 | - $size = $to - $from + 1; | |
| 954 | + $size = $to - $from + 1; | |
| 905 | 955 | $this->_multipart_byterange_header($options['mimetype'], $from, $to, $total); |
| 906 | 956 | |
| 907 | 957 | |
| 908 | - fseek($options['stream'], $start, SEEK_SET); | |
| 958 | + fseek($options['stream'], $from, SEEK_SET); | |
| 909 | 959 | while ($size && !feof($options['stream'])) { |
| 910 | 960 | $buffer = fread($options['stream'], 4096); |
| 911 | - $size -= strlen($buffer); | |
| 961 | + $size -= strlen($buffer); | |
| 912 | 962 | echo $buffer; |
| 913 | 963 | } |
| 914 | 964 | } |
| ... | ... | @@ -922,7 +972,7 @@ class HTTP_WebDAV_Server |
| 922 | 972 | fpassthru($options['stream']); |
| 923 | 973 | return; // no more headers |
| 924 | 974 | } |
| 925 | - } elseif (isset($options['data'])) { | |
| 975 | + } elseif (isset($options['data'])) { | |
| 926 | 976 | if (is_array($options['data'])) { |
| 927 | 977 | // reply to partial request |
| 928 | 978 | } else { |
| ... | ... | @@ -936,10 +986,10 @@ class HTTP_WebDAV_Server |
| 936 | 986 | if (!headers_sent()) { |
| 937 | 987 | if (false === $status) { |
| 938 | 988 | $this->http_status("404 not found"); |
| 989 | + } else { | |
| 990 | + // TODO: check setting of headers in various code pathes above | |
| 991 | + $this->http_status("$status"); | |
| 939 | 992 | } |
| 940 | - | |
| 941 | - // TODO: check setting of headers in various code pathes above | |
| 942 | - $this->http_status("$status"); | |
| 943 | 993 | } |
| 944 | 994 | } |
| 945 | 995 | |
| ... | ... | @@ -953,10 +1003,10 @@ class HTTP_WebDAV_Server |
| 953 | 1003 | function _get_ranges(&$options) |
| 954 | 1004 | { |
| 955 | 1005 | // process Range: header if present |
| 956 | - if (isset($_SERVER['HTTP_RANGE'])) { | |
| 1006 | + if (isset($this->_SERVER['HTTP_RANGE'])) { | |
| 957 | 1007 | |
| 958 | 1008 | // we only support standard "bytes" range specifications for now |
| 959 | - if (ereg("bytes[[:space:]]*=[[:space:]]*(.+)", $_SERVER['HTTP_RANGE'], $matches)) { | |
| 1009 | + if (preg_match('/bytes\s*=\s*(.+)/', $this->_SERVER['HTTP_RANGE'], $matches)) { | |
| 960 | 1010 | $options["ranges"] = array(); |
| 961 | 1011 | |
| 962 | 1012 | // ranges are comma separated |
| ... | ... | @@ -964,8 +1014,8 @@ class HTTP_WebDAV_Server |
| 964 | 1014 | // ranges are either from-to pairs or just end positions |
| 965 | 1015 | list($start, $end) = explode("-", $range); |
| 966 | 1016 | $options["ranges"][] = ($start==="") |
| 967 | - ? array("last"=>$end) | |
| 968 | - : array("start"=>$start, "end"=>$end); | |
| 1017 | + ? array("last"=>$end) | |
| 1018 | + : array("start"=>$start, "end"=>$end); | |
| 969 | 1019 | } |
| 970 | 1020 | } |
| 971 | 1021 | } |
| ... | ... | @@ -1025,8 +1075,8 @@ class HTTP_WebDAV_Server |
| 1025 | 1075 | */ |
| 1026 | 1076 | function http_HEAD() |
| 1027 | 1077 | { |
| 1028 | - $status = false; | |
| 1029 | - $options = Array(); | |
| 1078 | + $status = false; | |
| 1079 | + $options = Array(); | |
| 1030 | 1080 | $options["path"] = $this->path; |
| 1031 | 1081 | |
| 1032 | 1082 | if (method_exists($this, "HEAD")) { |
| ... | ... | @@ -1034,11 +1084,27 @@ class HTTP_WebDAV_Server |
| 1034 | 1084 | } else if (method_exists($this, "GET")) { |
| 1035 | 1085 | ob_start(); |
| 1036 | 1086 | $status = $this->GET($options); |
| 1087 | + if (!isset($options['size'])) { | |
| 1088 | + $options['size'] = ob_get_length(); | |
| 1089 | + } | |
| 1037 | 1090 | ob_end_clean(); |
| 1038 | 1091 | } |
| 1039 | 1092 | |
| 1040 | - if($status===true) $status = "200 OK"; | |
| 1041 | - if($status===false) $status = "404 Not found"; | |
| 1093 | + if (!isset($options['mimetype'])) { | |
| 1094 | + $options['mimetype'] = "application/octet-stream"; | |
| 1095 | + } | |
| 1096 | + header("Content-type: $options[mimetype]"); | |
| 1097 | + | |
| 1098 | + if (isset($options['mtime'])) { | |
| 1099 | + header("Last-modified:".gmdate("D, d M Y H:i:s ", $options['mtime'])."GMT"); | |
| 1100 | + } | |
| 1101 | + | |
| 1102 | + if (isset($options['size'])) { | |
| 1103 | + header("Content-length: ".$options['size']); | |
| 1104 | + } | |
| 1105 | + | |
| 1106 | + if ($status === true) $status = "200 OK"; | |
| 1107 | + if ($status === false) $status = "404 Not found"; | |
| 1042 | 1108 | |
| 1043 | 1109 | $this->http_status($status); |
| 1044 | 1110 | } |
| ... | ... | @@ -1056,30 +1122,30 @@ class HTTP_WebDAV_Server |
| 1056 | 1122 | function http_PUT() |
| 1057 | 1123 | { |
| 1058 | 1124 | if ($this->_check_lock_status($this->path)) { |
| 1059 | - $options = Array(); | |
| 1060 | - $options["path"] = $this->path; | |
| 1061 | - $options["content_length"] = $_SERVER["CONTENT_LENGTH"]; | |
| 1125 | + $options = Array(); | |
| 1126 | + $options["path"] = $this->path; | |
| 1127 | + $options["content_length"] = $this->_SERVER["CONTENT_LENGTH"]; | |
| 1062 | 1128 | |
| 1063 | 1129 | // get the Content-type |
| 1064 | - if (isset($_SERVER["CONTENT_TYPE"])) { | |
| 1130 | + if (isset($this->_SERVER["CONTENT_TYPE"])) { | |
| 1065 | 1131 | // for now we do not support any sort of multipart requests |
| 1066 | - if (!strncmp($_SERVER["CONTENT_TYPE"], "multipart/", 10)) { | |
| 1132 | + if (!strncmp($this->_SERVER["CONTENT_TYPE"], "multipart/", 10)) { | |
| 1067 | 1133 | $this->http_status("501 not implemented"); |
| 1068 | 1134 | echo "The service does not support mulipart PUT requests"; |
| 1069 | 1135 | return; |
| 1070 | 1136 | } |
| 1071 | - $options["content_type"] = $_SERVER["CONTENT_TYPE"]; | |
| 1137 | + $options["content_type"] = $this->_SERVER["CONTENT_TYPE"]; | |
| 1072 | 1138 | } else { |
| 1073 | 1139 | // default content type if none given |
| 1074 | 1140 | $options["content_type"] = "application/octet-stream"; |
| 1075 | 1141 | } |
| 1076 | 1142 | |
| 1077 | 1143 | /* RFC 2616 2.6 says: "The recipient of the entity MUST NOT |
| 1078 | - ignore any Content-* (e.g. Content-Range) headers that it | |
| 1079 | - does not understand or implement and MUST return a 501 | |
| 1080 | - (Not Implemented) response in such cases." | |
| 1144 | + ignore any Content-* (e.g. Content-Range) headers that it | |
| 1145 | + does not understand or implement and MUST return a 501 | |
| 1146 | + (Not Implemented) response in such cases." | |
| 1081 | 1147 | */ |
| 1082 | - foreach ($_SERVER as $key => $val) { | |
| 1148 | + foreach ($this->_SERVER as $key => $val) { | |
| 1083 | 1149 | if (strncmp($key, "HTTP_CONTENT", 11)) continue; |
| 1084 | 1150 | switch ($key) { |
| 1085 | 1151 | case 'HTTP_CONTENT_ENCODING': // RFC 2616 14.11 |
| ... | ... | @@ -1091,20 +1157,20 @@ class HTTP_WebDAV_Server |
| 1091 | 1157 | case 'HTTP_CONTENT_LANGUAGE': // RFC 2616 14.12 |
| 1092 | 1158 | // we assume it is not critical if this one is ignored |
| 1093 | 1159 | // in the actual PUT implementation ... |
| 1094 | - $options["content_language"] = $value; | |
| 1160 | + $options["content_language"] = $val; | |
| 1095 | 1161 | break; |
| 1096 | 1162 | |
| 1097 | 1163 | case 'HTTP_CONTENT_LOCATION': // RFC 2616 14.14 |
| 1098 | 1164 | /* The meaning of the Content-Location header in PUT |
| 1099 | - or POST requests is undefined; servers are free | |
| 1100 | - to ignore it in those cases. */ | |
| 1165 | + or POST requests is undefined; servers are free | |
| 1166 | + to ignore it in those cases. */ | |
| 1101 | 1167 | break; |
| 1102 | 1168 | |
| 1103 | 1169 | case 'HTTP_CONTENT_RANGE': // RFC 2616 14.16 |
| 1104 | 1170 | // single byte range requests are supported |
| 1105 | 1171 | // the header format is also specified in RFC 2616 14.16 |
| 1106 | 1172 | // TODO we have to ensure that implementations support this or send 501 instead |
| 1107 | - if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $value, $matches)) { | |
| 1173 | + if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches)) { | |
| 1108 | 1174 | $this->http_status("400 bad request"); |
| 1109 | 1175 | echo "The service does only support single byte ranges"; |
| 1110 | 1176 | return; |
| ... | ... | @@ -1188,8 +1254,8 @@ class HTTP_WebDAV_Server |
| 1188 | 1254 | function http_DELETE() |
| 1189 | 1255 | { |
| 1190 | 1256 | // check RFC 2518 Section 9.2, last paragraph |
| 1191 | - if (isset($_SERVER["HTTP_DEPTH"])) { | |
| 1192 | - if ($_SERVER["HTTP_DEPTH"] != "infinity") { | |
| 1257 | + if (isset($this->_SERVER["HTTP_DEPTH"])) { | |
| 1258 | + if ($this->_SERVER["HTTP_DEPTH"] != "infinity") { | |
| 1193 | 1259 | $this->http_status("400 Bad Request"); |
| 1194 | 1260 | return; |
| 1195 | 1261 | } |
| ... | ... | @@ -1198,7 +1264,7 @@ class HTTP_WebDAV_Server |
| 1198 | 1264 | // check lock status |
| 1199 | 1265 | if ($this->_check_lock_status($this->path)) { |
| 1200 | 1266 | // ok, proceed |
| 1201 | - $options = Array(); | |
| 1267 | + $options = Array(); | |
| 1202 | 1268 | $options["path"] = $this->path; |
| 1203 | 1269 | |
| 1204 | 1270 | $stat = $this->DELETE($options); |
| ... | ... | @@ -1260,30 +1326,38 @@ class HTTP_WebDAV_Server |
| 1260 | 1326 | */ |
| 1261 | 1327 | function http_LOCK() |
| 1262 | 1328 | { |
| 1263 | - $options = Array(); | |
| 1329 | + $options = Array(); | |
| 1264 | 1330 | $options["path"] = $this->path; |
| 1265 | 1331 | |
| 1266 | - if (isset($_SERVER['HTTP_DEPTH'])) { | |
| 1267 | - $options["depth"] = $_SERVER["HTTP_DEPTH"]; | |
| 1332 | + if (isset($this->_SERVER['HTTP_DEPTH'])) { | |
| 1333 | + $options["depth"] = $this->_SERVER["HTTP_DEPTH"]; | |
| 1268 | 1334 | } else { |
| 1269 | 1335 | $options["depth"] = "infinity"; |
| 1270 | 1336 | } |
| 1271 | 1337 | |
| 1272 | - if (isset($_SERVER["HTTP_TIMEOUT"])) { | |
| 1273 | - $options["timeout"] = explode(",", $_SERVER["HTTP_TIMEOUT"]); | |
| 1338 | + if (isset($this->_SERVER["HTTP_TIMEOUT"])) { | |
| 1339 | + $options["timeout"] = explode(",", $this->_SERVER["HTTP_TIMEOUT"]); | |
| 1274 | 1340 | } |
| 1275 | 1341 | |
| 1276 | - if(empty($_SERVER['CONTENT_LENGTH']) && !empty($_SERVER['HTTP_IF'])) { | |
| 1342 | + if (empty($this->_SERVER['CONTENT_LENGTH']) && !empty($this->_SERVER['HTTP_IF'])) { | |
| 1277 | 1343 | // check if locking is possible |
| 1278 | - if(!$this->_check_lock_status($this->path)) { | |
| 1344 | + if (!$this->_check_lock_status($this->path)) { | |
| 1279 | 1345 | $this->http_status("423 Locked"); |
| 1280 | 1346 | return; |
| 1281 | 1347 | } |
| 1282 | 1348 | |
| 1283 | 1349 | // refresh lock |
| 1284 | - $options["update"] = substr($_SERVER['HTTP_IF'], 2, -2); | |
| 1350 | + $options["locktoken"] = substr($this->_SERVER['HTTP_IF'], 2, -2); | |
| 1351 | + $options["update"] = $options["locktoken"]; | |
| 1352 | + | |
| 1353 | + // setting defaults for required fields, LOCK() SHOULD overwrite these | |
| 1354 | + $options['owner'] = "unknown"; | |
| 1355 | + $options['scope'] = "exclusive"; | |
| 1356 | + $options['type'] = "write"; | |
| 1357 | + | |
| 1358 | + | |
| 1285 | 1359 | $stat = $this->LOCK($options); |
| 1286 | - } else { | |
| 1360 | + } else { | |
| 1287 | 1361 | // extract lock request information from request XML payload |
| 1288 | 1362 | $lockinfo = new _parse_lockinfo("php://input"); |
| 1289 | 1363 | if (!$lockinfo->success) { |
| ... | ... | @@ -1291,34 +1365,32 @@ class HTTP_WebDAV_Server |
| 1291 | 1365 | } |
| 1292 | 1366 | |
| 1293 | 1367 | // check if locking is possible |
| 1294 | - if(!$this->_check_lock_status($this->path, $lockinfo->lockscope === "shared")) { | |
| 1368 | + if (!$this->_check_lock_status($this->path, $lockinfo->lockscope === "shared")) { | |
| 1295 | 1369 | $this->http_status("423 Locked"); |
| 1296 | 1370 | return; |
| 1297 | 1371 | } |
| 1298 | 1372 | |
| 1299 | 1373 | // new lock |
| 1300 | - $options["scope"] = $lockinfo->lockscope; | |
| 1301 | - $options["type"] = $lockinfo->locktype; | |
| 1302 | - $options["owner"] = $lockinfo->owner; | |
| 1303 | - | |
| 1374 | + $options["scope"] = $lockinfo->lockscope; | |
| 1375 | + $options["type"] = $lockinfo->locktype; | |
| 1376 | + $options["owner"] = $lockinfo->owner; | |
| 1304 | 1377 | $options["locktoken"] = $this->_new_locktoken(); |
| 1305 | 1378 | |
| 1306 | 1379 | $stat = $this->LOCK($options); |
| 1307 | 1380 | } |
| 1308 | 1381 | |
| 1309 | - if(is_bool($stat)) { | |
| 1382 | + if (is_bool($stat)) { | |
| 1310 | 1383 | $http_stat = $stat ? "200 OK" : "423 Locked"; |
| 1311 | 1384 | } else { |
| 1312 | 1385 | $http_stat = $stat; |
| 1313 | 1386 | } |
| 1314 | - | |
| 1315 | 1387 | $this->http_status($http_stat); |
| 1316 | 1388 | |
| 1317 | 1389 | if ($http_stat{0} == 2) { // 2xx states are ok |
| 1318 | - if($options["timeout"]) { | |
| 1390 | + if ($options["timeout"]) { | |
| 1319 | 1391 | // more than a million is considered an absolute timestamp |
| 1320 | 1392 | // less is more likely a relative value |
| 1321 | - if($options["timeout"]>1000000) { | |
| 1393 | + if ($options["timeout"]>1000000) { | |
| 1322 | 1394 | $timeout = "Second-".($options['timeout']-time()); |
| 1323 | 1395 | } else { |
| 1324 | 1396 | $timeout = "Second-$options[timeout]"; |
| ... | ... | @@ -1358,17 +1430,17 @@ class HTTP_WebDAV_Server |
| 1358 | 1430 | */ |
| 1359 | 1431 | function http_UNLOCK() |
| 1360 | 1432 | { |
| 1361 | - $options = Array(); | |
| 1433 | + $options = Array(); | |
| 1362 | 1434 | $options["path"] = $this->path; |
| 1363 | 1435 | |
| 1364 | - if (isset($_SERVER['HTTP_DEPTH'])) { | |
| 1365 | - $options["depth"] = $_SERVER["HTTP_DEPTH"]; | |
| 1436 | + if (isset($this->_SERVER['HTTP_DEPTH'])) { | |
| 1437 | + $options["depth"] = $this->_SERVER["HTTP_DEPTH"]; | |
| 1366 | 1438 | } else { |
| 1367 | 1439 | $options["depth"] = "infinity"; |
| 1368 | 1440 | } |
| 1369 | 1441 | |
| 1370 | 1442 | // strip surrounding <> |
| 1371 | - $options["token"] = substr(trim($_SERVER["HTTP_LOCK_TOKEN"]), 1, -1); | |
| 1443 | + $options["token"] = substr(trim($this->_SERVER["HTTP_LOCK_TOKEN"]), 1, -1); | |
| 1372 | 1444 | |
| 1373 | 1445 | // call user method |
| 1374 | 1446 | $stat = $this->UNLOCK($options); |
| ... | ... | @@ -1384,39 +1456,39 @@ class HTTP_WebDAV_Server |
| 1384 | 1456 | |
| 1385 | 1457 | function _copymove($what) |
| 1386 | 1458 | { |
| 1387 | - $options = Array(); | |
| 1459 | + $options = Array(); | |
| 1388 | 1460 | $options["path"] = $this->path; |
| 1389 | 1461 | |
| 1390 | - if (isset($_SERVER["HTTP_DEPTH"])) { | |
| 1391 | - $options["depth"] = $_SERVER["HTTP_DEPTH"]; | |
| 1462 | + if (isset($this->_SERVER["HTTP_DEPTH"])) { | |
| 1463 | + $options["depth"] = $this->_SERVER["HTTP_DEPTH"]; | |
| 1392 | 1464 | } else { |
| 1393 | 1465 | $options["depth"] = "infinity"; |
| 1394 | 1466 | } |
| 1395 | 1467 | |
| 1396 | - extract(parse_url($_SERVER["HTTP_DESTINATION"])); | |
| 1397 | - $path = urldecode($path); | |
| 1468 | + extract(parse_url($this->_SERVER["HTTP_DESTINATION"])); | |
| 1469 | + $path = urldecode($path); | |
| 1398 | 1470 | $http_host = $host; |
| 1399 | 1471 | if (isset($port) && $port != 80) |
| 1400 | 1472 | $http_host.= ":$port"; |
| 1401 | 1473 | |
| 1402 | - $http_header_host = ereg_replace(":80$", "", $_SERVER["HTTP_HOST"]); | |
| 1474 | + $http_header_host = preg_replace("/:80$/", "", $this->_SERVER["HTTP_HOST"]); | |
| 1403 | 1475 | |
| 1404 | 1476 | if ($http_host == $http_header_host && |
| 1405 | - !strncmp($_SERVER["SCRIPT_NAME"], $path, | |
| 1406 | - strlen($_SERVER["SCRIPT_NAME"]))) { | |
| 1407 | - $options["dest"] = substr($path, strlen($_SERVER["SCRIPT_NAME"])); | |
| 1477 | + !strncmp($this->_SERVER["SCRIPT_NAME"], $path, | |
| 1478 | + strlen($this->_SERVER["SCRIPT_NAME"]))) { | |
| 1479 | + $options["dest"] = substr($path, strlen($this->_SERVER["SCRIPT_NAME"])); | |
| 1408 | 1480 | if (!$this->_check_lock_status($options["dest"])) { |
| 1409 | 1481 | $this->http_status("423 Locked"); |
| 1410 | 1482 | return; |
| 1411 | 1483 | } |
| 1412 | 1484 | |
| 1413 | 1485 | } else { |
| 1414 | - $options["dest_url"] = $_SERVER["HTTP_DESTINATION"]; | |
| 1486 | + $options["dest_url"] = $this->_SERVER["HTTP_DESTINATION"]; | |
| 1415 | 1487 | } |
| 1416 | 1488 | |
| 1417 | 1489 | // see RFC 2518 Sections 9.6, 8.8.4 and 8.9.3 |
| 1418 | - if (isset($_SERVER["HTTP_OVERWRITE"])) { | |
| 1419 | - $options["overwrite"] = $_SERVER["HTTP_OVERWRITE"] == "T"; | |
| 1490 | + if (isset($this->_SERVER["HTTP_OVERWRITE"])) { | |
| 1491 | + $options["overwrite"] = $this->_SERVER["HTTP_OVERWRITE"] == "T"; | |
| 1420 | 1492 | } else { |
| 1421 | 1493 | $options["overwrite"] = true; |
| 1422 | 1494 | } |
| ... | ... | @@ -1443,7 +1515,7 @@ class HTTP_WebDAV_Server |
| 1443 | 1515 | // all other METHODS need both a http_method() wrapper |
| 1444 | 1516 | // and a method() implementation |
| 1445 | 1517 | // the base class supplies wrappers only |
| 1446 | - foreach(get_class_methods($this) as $method) { | |
| 1518 | + foreach (get_class_methods($this) as $method) { | |
| 1447 | 1519 | if (!strncmp("http_", $method, 5)) { |
| 1448 | 1520 | $method = strtoupper(substr($method, 5)); |
| 1449 | 1521 | if (method_exists($this, $method)) { |
| ... | ... | @@ -1501,14 +1573,14 @@ class HTTP_WebDAV_Server |
| 1501 | 1573 | { |
| 1502 | 1574 | if (method_exists($this, "checkAuth")) { |
| 1503 | 1575 | // PEAR style method name |
| 1504 | - return $this->checkAuth(@$_SERVER["AUTH_TYPE"], | |
| 1505 | - @$_SERVER["PHP_AUTH_USER"], | |
| 1506 | - @$_SERVER["PHP_AUTH_PW"]); | |
| 1576 | + return $this->checkAuth(@$this->_SERVER["AUTH_TYPE"], | |
| 1577 | + @$this->_SERVER["PHP_AUTH_USER"], | |
| 1578 | + @$this->_SERVER["PHP_AUTH_PW"]); | |
| 1507 | 1579 | } else if (method_exists($this, "check_auth")) { |
| 1508 | 1580 | // old (pre 1.0) method name |
| 1509 | - return $this->check_auth(@$_SERVER["AUTH_TYPE"], | |
| 1510 | - @$_SERVER["PHP_AUTH_USER"], | |
| 1511 | - @$_SERVER["PHP_AUTH_PW"]); | |
| 1581 | + return $this->check_auth(@$this->_SERVER["AUTH_TYPE"], | |
| 1582 | + @$this->_SERVER["PHP_AUTH_USER"], | |
| 1583 | + @$this->_SERVER["PHP_AUTH_PW"]); | |
| 1512 | 1584 | } else { |
| 1513 | 1585 | // no method found -> no authentication required |
| 1514 | 1586 | return true; |
| ... | ... | @@ -1588,34 +1660,34 @@ class HTTP_WebDAV_Server |
| 1588 | 1660 | |
| 1589 | 1661 | // now it depends on what we found |
| 1590 | 1662 | switch ($c) { |
| 1591 | - case "<": | |
| 1592 | - // URIs are enclosed in <...> | |
| 1593 | - $pos2 = strpos($string, ">", $pos); | |
| 1594 | - $uri = substr($string, $pos, $pos2 - $pos); | |
| 1595 | - $pos = $pos2 + 1; | |
| 1596 | - return array("URI", $uri); | |
| 1597 | - | |
| 1598 | - case "[": | |
| 1599 | - //Etags are enclosed in [...] | |
| 1600 | - if ($string{$pos} == "W") { | |
| 1601 | - $type = "ETAG_WEAK"; | |
| 1602 | - $pos += 2; | |
| 1603 | - } else { | |
| 1604 | - $type = "ETAG_STRONG"; | |
| 1605 | - } | |
| 1606 | - $pos2 = strpos($string, "]", $pos); | |
| 1607 | - $etag = substr($string, $pos + 1, $pos2 - $pos - 2); | |
| 1608 | - $pos = $pos2 + 1; | |
| 1609 | - return array($type, $etag); | |
| 1610 | - | |
| 1611 | - case "N": | |
| 1612 | - // "N" indicates negation | |
| 1663 | + case "<": | |
| 1664 | + // URIs are enclosed in <...> | |
| 1665 | + $pos2 = strpos($string, ">", $pos); | |
| 1666 | + $uri = substr($string, $pos, $pos2 - $pos); | |
| 1667 | + $pos = $pos2 + 1; | |
| 1668 | + return array("URI", $uri); | |
| 1669 | + | |
| 1670 | + case "[": | |
| 1671 | + //Etags are enclosed in [...] | |
| 1672 | + if ($string{$pos} == "W") { | |
| 1673 | + $type = "ETAG_WEAK"; | |
| 1613 | 1674 | $pos += 2; |
| 1614 | - return array("NOT", "Not"); | |
| 1675 | + } else { | |
| 1676 | + $type = "ETAG_STRONG"; | |
| 1677 | + } | |
| 1678 | + $pos2 = strpos($string, "]", $pos); | |
| 1679 | + $etag = substr($string, $pos + 1, $pos2 - $pos - 2); | |
| 1680 | + $pos = $pos2 + 1; | |
| 1681 | + return array($type, $etag); | |
| 1682 | + | |
| 1683 | + case "N": | |
| 1684 | + // "N" indicates negation | |
| 1685 | + $pos += 2; | |
| 1686 | + return array("NOT", "Not"); | |
| 1615 | 1687 | |
| 1616 | - default: | |
| 1617 | - // anything else is passed verbatim char by char | |
| 1618 | - return array("CHAR", $c); | |
| 1688 | + default: | |
| 1689 | + // anything else is passed verbatim char by char | |
| 1690 | + return array("CHAR", $c); | |
| 1619 | 1691 | } |
| 1620 | 1692 | } |
| 1621 | 1693 | |
| ... | ... | @@ -1627,9 +1699,8 @@ class HTTP_WebDAV_Server |
| 1627 | 1699 | */ |
| 1628 | 1700 | function _if_header_parser($str) |
| 1629 | 1701 | { |
| 1630 | - $pos = 0; | |
| 1631 | - $len = strlen($str); | |
| 1632 | - | |
| 1702 | + $pos = 0; | |
| 1703 | + $len = strlen($str); | |
| 1633 | 1704 | $uris = array(); |
| 1634 | 1705 | |
| 1635 | 1706 | // parser loop |
| ... | ... | @@ -1639,7 +1710,7 @@ class HTTP_WebDAV_Server |
| 1639 | 1710 | |
| 1640 | 1711 | // check for URI |
| 1641 | 1712 | if ($token[0] == "URI") { |
| 1642 | - $uri = $token[1]; // remember URI | |
| 1713 | + $uri = $token[1]; // remember URI | |
| 1643 | 1714 | $token = $this->_if_header_lexer($str, $pos); // get next token |
| 1644 | 1715 | } else { |
| 1645 | 1716 | $uri = ""; |
| ... | ... | @@ -1650,9 +1721,9 @@ class HTTP_WebDAV_Server |
| 1650 | 1721 | return false; |
| 1651 | 1722 | } |
| 1652 | 1723 | |
| 1653 | - $list = array(); | |
| 1724 | + $list = array(); | |
| 1654 | 1725 | $level = 1; |
| 1655 | - $not = ""; | |
| 1726 | + $not = ""; | |
| 1656 | 1727 | while ($level) { |
| 1657 | 1728 | $token = $this->_if_header_lexer($str, $pos); |
| 1658 | 1729 | if ($token[0] == "NOT") { |
| ... | ... | @@ -1660,39 +1731,39 @@ class HTTP_WebDAV_Server |
| 1660 | 1731 | continue; |
| 1661 | 1732 | } |
| 1662 | 1733 | switch ($token[0]) { |
| 1663 | - case "CHAR": | |
| 1664 | - switch ($token[1]) { | |
| 1665 | - case "(": | |
| 1666 | - $level++; | |
| 1667 | - break; | |
| 1668 | - case ")": | |
| 1669 | - $level--; | |
| 1670 | - break; | |
| 1671 | - default: | |
| 1672 | - return false; | |
| 1673 | - } | |
| 1734 | + case "CHAR": | |
| 1735 | + switch ($token[1]) { | |
| 1736 | + case "(": | |
| 1737 | + $level++; | |
| 1674 | 1738 | break; |
| 1675 | - | |
| 1676 | - case "URI": | |
| 1677 | - $list[] = $not."<$token[1]>"; | |
| 1739 | + case ")": | |
| 1740 | + $level--; | |
| 1678 | 1741 | break; |
| 1742 | + default: | |
| 1743 | + return false; | |
| 1744 | + } | |
| 1745 | + break; | |
| 1679 | 1746 | |
| 1680 | - case "ETAG_WEAK": | |
| 1681 | - $list[] = $not."[W/'$token[1]']>"; | |
| 1682 | - break; | |
| 1747 | + case "URI": | |
| 1748 | + $list[] = $not."<$token[1]>"; | |
| 1749 | + break; | |
| 1683 | 1750 | |
| 1684 | - case "ETAG_STRONG": | |
| 1685 | - $list[] = $not."['$token[1]']>"; | |
| 1686 | - break; | |
| 1751 | + case "ETAG_WEAK": | |
| 1752 | + $list[] = $not."[W/'$token[1]']>"; | |
| 1753 | + break; | |
| 1687 | 1754 | |
| 1688 | - default: | |
| 1689 | - return false; | |
| 1755 | + case "ETAG_STRONG": | |
| 1756 | + $list[] = $not."['$token[1]']>"; | |
| 1757 | + break; | |
| 1758 | + | |
| 1759 | + default: | |
| 1760 | + return false; | |
| 1690 | 1761 | } |
| 1691 | 1762 | $not = ""; |
| 1692 | 1763 | } |
| 1693 | 1764 | |
| 1694 | 1765 | if (@is_array($uris[$uri])) { |
| 1695 | - $uris[$uri] = array_merge($uris[$uri],$list); | |
| 1766 | + $uris[$uri] = array_merge($uris[$uri], $list); | |
| 1696 | 1767 | } else { |
| 1697 | 1768 | $uris[$uri] = $list; |
| 1698 | 1769 | } |
| ... | ... | @@ -1712,26 +1783,28 @@ class HTTP_WebDAV_Server |
| 1712 | 1783 | */ |
| 1713 | 1784 | function _check_if_header_conditions() |
| 1714 | 1785 | { |
| 1715 | - if (isset($_SERVER["HTTP_IF"])) { | |
| 1786 | + if (isset($this->_SERVER["HTTP_IF"])) { | |
| 1716 | 1787 | $this->_if_header_uris = |
| 1717 | - $this->_if_header_parser($_SERVER["HTTP_IF"]); | |
| 1788 | + $this->_if_header_parser($this->_SERVER["HTTP_IF"]); | |
| 1718 | 1789 | |
| 1719 | - foreach($this->_if_header_uris as $uri => $conditions) { | |
| 1790 | + foreach ($this->_if_header_uris as $uri => $conditions) { | |
| 1720 | 1791 | if ($uri == "") { |
| 1721 | 1792 | $uri = $this->uri; |
| 1722 | 1793 | } |
| 1723 | 1794 | // all must match |
| 1724 | 1795 | $state = true; |
| 1725 | - foreach($conditions as $condition) { | |
| 1796 | + foreach ($conditions as $condition) { | |
| 1726 | 1797 | // lock tokens may be free form (RFC2518 6.3) |
| 1727 | 1798 | // but if opaquelocktokens are used (RFC2518 6.4) |
| 1728 | 1799 | // we have to check the format (litmus tests this) |
| 1729 | 1800 | if (!strncmp($condition, "<opaquelocktoken:", strlen("<opaquelocktoken"))) { |
| 1730 | - if (!ereg("^<opaquelocktoken:[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}>$", $condition)) { | |
| 1801 | + if (!preg_match('/^<opaquelocktoken:[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}>$/', $condition)) { | |
| 1802 | + $this->http_status("423 Locked"); | |
| 1731 | 1803 | return false; |
| 1732 | 1804 | } |
| 1733 | 1805 | } |
| 1734 | 1806 | if (!$this->_check_uri_condition($uri, $condition)) { |
| 1807 | + $this->http_status("412 Precondition failed"); | |
| 1735 | 1808 | $state = false; |
| 1736 | 1809 | break; |
| 1737 | 1810 | } |
| ... | ... | @@ -1761,6 +1834,13 @@ class HTTP_WebDAV_Server |
| 1761 | 1834 | { |
| 1762 | 1835 | // not really implemented here, |
| 1763 | 1836 | // implementations must override |
| 1837 | + | |
| 1838 | + // a lock token can never be from the DAV: scheme | |
| 1839 | + // litmus uses DAV:no-lock in some tests | |
| 1840 | + if (!strncmp("<DAV:", $condition, 5)) { | |
| 1841 | + return false; | |
| 1842 | + } | |
| 1843 | + | |
| 1764 | 1844 | return true; |
| 1765 | 1845 | } |
| 1766 | 1846 | |
| ... | ... | @@ -1781,7 +1861,7 @@ class HTTP_WebDAV_Server |
| 1781 | 1861 | // ... and lock is not owned? |
| 1782 | 1862 | if (is_array($lock) && count($lock)) { |
| 1783 | 1863 | // FIXME doesn't check uri restrictions yet |
| 1784 | - if (!strstr($_SERVER["HTTP_IF"], $lock["token"])) { | |
| 1864 | + if (!isset($this->_SERVER["HTTP_IF"]) || !strstr($this->_SERVER["HTTP_IF"], $lock["token"])) { | |
| 1785 | 1865 | if (!$exclusive_only || ($lock["scope"] !== "shared")) |
| 1786 | 1866 | return false; |
| 1787 | 1867 | } |
| ... | ... | @@ -1850,7 +1930,7 @@ class HTTP_WebDAV_Server |
| 1850 | 1930 | function http_status($status) |
| 1851 | 1931 | { |
| 1852 | 1932 | // simplified success case |
| 1853 | - if($status === true) { | |
| 1933 | + if ($status === true) { | |
| 1854 | 1934 | $status = "200 OK"; |
| 1855 | 1935 | } |
| 1856 | 1936 | |
| ... | ... | @@ -1918,7 +1998,8 @@ class HTTP_WebDAV_Server |
| 1918 | 1998 | * @param string directory path |
| 1919 | 1999 | * @returns string directory path wiht trailing slash |
| 1920 | 2000 | */ |
| 1921 | - function _slashify($path) { | |
| 2001 | + function _slashify($path) | |
| 2002 | + { | |
| 1922 | 2003 | if ($path[strlen($path)-1] != '/') { |
| 1923 | 2004 | $path = $path."/"; |
| 1924 | 2005 | } |
| ... | ... | @@ -1931,9 +2012,10 @@ class HTTP_WebDAV_Server |
| 1931 | 2012 | * @param string directory path |
| 1932 | 2013 | * @returns string directory path wihtout trailing slash |
| 1933 | 2014 | */ |
| 1934 | - function _unslashify($path) { | |
| 2015 | + function _unslashify($path) | |
| 2016 | + { | |
| 1935 | 2017 | if ($path[strlen($path)-1] == '/') { |
| 1936 | - $path = substr($path, 0, strlen($path, 0, -1)); | |
| 2018 | + $path = substr($path, 0, strlen($path) -1); | |
| 1937 | 2019 | } |
| 1938 | 2020 | return $path; |
| 1939 | 2021 | } |
| ... | ... | @@ -1955,10 +2037,10 @@ class HTTP_WebDAV_Server |
| 1955 | 2037 | } |
| 1956 | 2038 | } |
| 1957 | 2039 | |
| 1958 | - /* | |
| 1959 | - * Local variables: | |
| 1960 | - * tab-width: 4 | |
| 1961 | - * c-basic-offset: 4 | |
| 1962 | - * End: | |
| 1963 | - */ | |
| 2040 | +/* | |
| 2041 | + * Local variables: | |
| 2042 | + * tab-width: 4 | |
| 2043 | + * c-basic-offset: 4 | |
| 2044 | + * End: | |
| 2045 | + */ | |
| 1964 | 2046 | ?> | ... | ... |
thirdparty/pear/HTTP/WebDAV/Tools/_parse_lockinfo.php renamed to ktwebdav/thirdparty/pear/HTTP/WebDAV/Tools/_parse_lockinfo.php
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | // | Christian Stocker <chregu@bitflux.ch> | |
| 18 | 18 | // +----------------------------------------------------------------------+ |
| 19 | 19 | // |
| 20 | -// $Id$ | |
| 20 | +// $Id: _parse_lockinfo.php,v 1.4 2006/10/10 11:53:17 hholzgra Exp $ | |
| 21 | 21 | // |
| 22 | 22 | |
| 23 | 23 | /** |
| ... | ... | @@ -25,135 +25,135 @@ |
| 25 | 25 | * |
| 26 | 26 | * @package HTTP_WebDAV_Server |
| 27 | 27 | * @author Hartmut Holzgraefe <hholzgra@php.net> |
| 28 | - * @version 0.99.1dev | |
| 28 | + * @version @package-version@ | |
| 29 | 29 | */ |
| 30 | 30 | class _parse_lockinfo |
| 31 | 31 | { |
| 32 | - /** | |
| 33 | - * success state flag | |
| 34 | - * | |
| 35 | - * @var bool | |
| 36 | - * @access public | |
| 37 | - */ | |
| 38 | - var $success = false; | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * lock type, currently only "write" | |
| 42 | - * | |
| 43 | - * @var string | |
| 44 | - * @access public | |
| 45 | - */ | |
| 46 | - var $locktype = ""; | |
| 47 | - | |
| 48 | - /** | |
| 49 | - * lock scope, "shared" or "exclusive" | |
| 50 | - * | |
| 51 | - * @var string | |
| 52 | - * @access public | |
| 53 | - */ | |
| 54 | - var $lockscope = ""; | |
| 55 | - | |
| 56 | - /** | |
| 57 | - * lock owner information | |
| 58 | - * | |
| 59 | - * @var string | |
| 60 | - * @access public | |
| 61 | - */ | |
| 62 | - var $owner = ""; | |
| 63 | - | |
| 64 | - /** | |
| 65 | - * flag that is set during lock owner read | |
| 66 | - * | |
| 67 | - * @var bool | |
| 68 | - * @access private | |
| 69 | - */ | |
| 70 | - var $collect_owner = false; | |
| 71 | - | |
| 72 | - /** | |
| 73 | - * constructor | |
| 74 | - * | |
| 75 | - * @param string path of stream to read | |
| 76 | - * @access public | |
| 77 | - */ | |
| 32 | + /** | |
| 33 | + * success state flag | |
| 34 | + * | |
| 35 | + * @var bool | |
| 36 | + * @access public | |
| 37 | + */ | |
| 38 | + var $success = false; | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * lock type, currently only "write" | |
| 42 | + * | |
| 43 | + * @var string | |
| 44 | + * @access public | |
| 45 | + */ | |
| 46 | + var $locktype = ""; | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * lock scope, "shared" or "exclusive" | |
| 50 | + * | |
| 51 | + * @var string | |
| 52 | + * @access public | |
| 53 | + */ | |
| 54 | + var $lockscope = ""; | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * lock owner information | |
| 58 | + * | |
| 59 | + * @var string | |
| 60 | + * @access public | |
| 61 | + */ | |
| 62 | + var $owner = ""; | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * flag that is set during lock owner read | |
| 66 | + * | |
| 67 | + * @var bool | |
| 68 | + * @access private | |
| 69 | + */ | |
| 70 | + var $collect_owner = false; | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * constructor | |
| 74 | + * | |
| 75 | + * @param string path of stream to read | |
| 76 | + * @access public | |
| 77 | + */ | |
| 78 | 78 | function _parse_lockinfo($path) |
| 79 | - { | |
| 80 | - // we assume success unless problems occur | |
| 81 | - $this->success = true; | |
| 82 | - | |
| 83 | - // remember if any input was parsed | |
| 84 | - $had_input = false; | |
| 85 | - | |
| 86 | - // open stream | |
| 87 | - $f_in = fopen($path, "r"); | |
| 88 | - if (!$f_in) { | |
| 89 | - $this->success = false; | |
| 90 | - return; | |
| 91 | - } | |
| 92 | - | |
| 93 | - // create namespace aware parser | |
| 94 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); | |
| 95 | - | |
| 96 | - // set tag and data handlers | |
| 97 | - xml_set_element_handler($xml_parser, | |
| 98 | - array(&$this, "_startElement"), | |
| 99 | - array(&$this, "_endElement")); | |
| 100 | - xml_set_character_data_handler($xml_parser, | |
| 101 | - array(&$this, "_data")); | |
| 102 | - | |
| 103 | - // we want a case sensitive parser | |
| 104 | - xml_parser_set_option($xml_parser, | |
| 105 | - XML_OPTION_CASE_FOLDING, false); | |
| 106 | - | |
| 107 | - // parse input | |
| 108 | - while($this->success && !feof($f_in)) { | |
| 109 | - $line = fgets($f_in); | |
| 110 | - if (is_string($line)) { | |
| 111 | - $had_input = true; | |
| 112 | - $this->success &= xml_parse($xml_parser, $line, false); | |
| 113 | - } | |
| 114 | - } | |
| 115 | - | |
| 116 | - // finish parsing | |
| 117 | - if($had_input) { | |
| 118 | - $this->success &= xml_parse($xml_parser, "", true); | |
| 119 | - } | |
| 120 | - | |
| 121 | - // check if required tags where found | |
| 122 | - $this->success &= !empty($this->locktype); | |
| 123 | - $this->success &= !empty($this->lockscope); | |
| 124 | - | |
| 125 | - // free parser resource | |
| 126 | - xml_parser_free($xml_parser); | |
| 127 | - | |
| 128 | - // close input stream | |
| 129 | - fclose($f_in); | |
| 130 | - } | |
| 79 | + { | |
| 80 | + // we assume success unless problems occur | |
| 81 | + $this->success = true; | |
| 82 | + | |
| 83 | + // remember if any input was parsed | |
| 84 | + $had_input = false; | |
| 85 | + | |
| 86 | + // open stream | |
| 87 | + $f_in = fopen($path, "r"); | |
| 88 | + if (!$f_in) { | |
| 89 | + $this->success = false; | |
| 90 | + return; | |
| 91 | + } | |
| 92 | + | |
| 93 | + // create namespace aware parser | |
| 94 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); | |
| 95 | + | |
| 96 | + // set tag and data handlers | |
| 97 | + xml_set_element_handler($xml_parser, | |
| 98 | + array(&$this, "_startElement"), | |
| 99 | + array(&$this, "_endElement")); | |
| 100 | + xml_set_character_data_handler($xml_parser, | |
| 101 | + array(&$this, "_data")); | |
| 102 | + | |
| 103 | + // we want a case sensitive parser | |
| 104 | + xml_parser_set_option($xml_parser, | |
| 105 | + XML_OPTION_CASE_FOLDING, false); | |
| 106 | + | |
| 107 | + // parse input | |
| 108 | + while ($this->success && !feof($f_in)) { | |
| 109 | + $line = fgets($f_in); | |
| 110 | + if (is_string($line)) { | |
| 111 | + $had_input = true; | |
| 112 | + $this->success &= xml_parse($xml_parser, $line, false); | |
| 113 | + } | |
| 114 | + } | |
| 115 | + | |
| 116 | + // finish parsing | |
| 117 | + if ($had_input) { | |
| 118 | + $this->success &= xml_parse($xml_parser, "", true); | |
| 119 | + } | |
| 120 | + | |
| 121 | + // check if required tags where found | |
| 122 | + $this->success &= !empty($this->locktype); | |
| 123 | + $this->success &= !empty($this->lockscope); | |
| 124 | + | |
| 125 | + // free parser resource | |
| 126 | + xml_parser_free($xml_parser); | |
| 127 | + | |
| 128 | + // close input stream | |
| 129 | + fclose($f_in); | |
| 130 | + } | |
| 131 | 131 | |
| 132 | 132 | |
| 133 | - /** | |
| 134 | - * tag start handler | |
| 135 | - * | |
| 136 | - * @param resource parser | |
| 137 | - * @param string tag name | |
| 138 | - * @param array tag attributes | |
| 139 | - * @return void | |
| 140 | - * @access private | |
| 141 | - */ | |
| 133 | + /** | |
| 134 | + * tag start handler | |
| 135 | + * | |
| 136 | + * @param resource parser | |
| 137 | + * @param string tag name | |
| 138 | + * @param array tag attributes | |
| 139 | + * @return void | |
| 140 | + * @access private | |
| 141 | + */ | |
| 142 | 142 | function _startElement($parser, $name, $attrs) |
| 143 | 143 | { |
| 144 | - // namespace handling | |
| 144 | + // namespace handling | |
| 145 | 145 | if (strstr($name, " ")) { |
| 146 | 146 | list($ns, $tag) = explode(" ", $name); |
| 147 | 147 | } else { |
| 148 | - $ns = ""; | |
| 148 | + $ns = ""; | |
| 149 | 149 | $tag = $name; |
| 150 | 150 | } |
| 151 | - | |
| 151 | + | |
| 152 | 152 | |
| 153 | 153 | if ($this->collect_owner) { |
| 154 | - // everything within the <owner> tag needs to be collected | |
| 154 | + // everything within the <owner> tag needs to be collected | |
| 155 | 155 | $ns_short = ""; |
| 156 | - $ns_attr = ""; | |
| 156 | + $ns_attr = ""; | |
| 157 | 157 | if ($ns) { |
| 158 | 158 | if ($ns == "DAV:") { |
| 159 | 159 | $ns_short = "D:"; |
| ... | ... | @@ -163,75 +163,75 @@ class _parse_lockinfo |
| 163 | 163 | } |
| 164 | 164 | $this->owner .= "<$ns_short$tag$ns_attr>"; |
| 165 | 165 | } else if ($ns == "DAV:") { |
| 166 | - // parse only the essential tags | |
| 166 | + // parse only the essential tags | |
| 167 | 167 | switch ($tag) { |
| 168 | - case "write": | |
| 169 | - $this->locktype = $tag; | |
| 170 | - break; | |
| 171 | - case "exclusive": | |
| 172 | - case "shared": | |
| 173 | - $this->lockscope = $tag; | |
| 174 | - break; | |
| 175 | - case "owner": | |
| 176 | - $this->collect_owner = true; | |
| 177 | - break; | |
| 168 | + case "write": | |
| 169 | + $this->locktype = $tag; | |
| 170 | + break; | |
| 171 | + case "exclusive": | |
| 172 | + case "shared": | |
| 173 | + $this->lockscope = $tag; | |
| 174 | + break; | |
| 175 | + case "owner": | |
| 176 | + $this->collect_owner = true; | |
| 177 | + break; | |
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | - | |
| 182 | - /** | |
| 183 | - * data handler | |
| 184 | - * | |
| 185 | - * @param resource parser | |
| 186 | - * @param string data | |
| 187 | - * @return void | |
| 188 | - * @access private | |
| 189 | - */ | |
| 181 | + | |
| 182 | + /** | |
| 183 | + * data handler | |
| 184 | + * | |
| 185 | + * @param resource parser | |
| 186 | + * @param string data | |
| 187 | + * @return void | |
| 188 | + * @access private | |
| 189 | + */ | |
| 190 | 190 | function _data($parser, $data) |
| 191 | 191 | { |
| 192 | - // only the <owner> tag has data content | |
| 192 | + // only the <owner> tag has data content | |
| 193 | 193 | if ($this->collect_owner) { |
| 194 | 194 | $this->owner .= $data; |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - /** | |
| 199 | - * tag end handler | |
| 200 | - * | |
| 201 | - * @param resource parser | |
| 202 | - * @param string tag name | |
| 203 | - * @return void | |
| 204 | - * @access private | |
| 205 | - */ | |
| 198 | + /** | |
| 199 | + * tag end handler | |
| 200 | + * | |
| 201 | + * @param resource parser | |
| 202 | + * @param string tag name | |
| 203 | + * @return void | |
| 204 | + * @access private | |
| 205 | + */ | |
| 206 | 206 | function _endElement($parser, $name) |
| 207 | 207 | { |
| 208 | - // namespace handling | |
| 209 | - if (strstr($name, " ")) { | |
| 210 | - list($ns, $tag) = explode(" ", $name); | |
| 211 | - } else { | |
| 212 | - $ns = ""; | |
| 213 | - $tag = $name; | |
| 214 | - } | |
| 215 | - | |
| 216 | - // <owner> finished? | |
| 217 | - if (($ns == "DAV:") && ($tag == "owner")) { | |
| 218 | - $this->collect_owner = false; | |
| 219 | - } | |
| 220 | - | |
| 221 | - // within <owner> we have to collect everything | |
| 222 | - if ($this->collect_owner) { | |
| 223 | - $ns_short = ""; | |
| 224 | - $ns_attr = ""; | |
| 225 | - if ($ns) { | |
| 226 | - if ($ns == "DAV:") { | |
| 208 | + // namespace handling | |
| 209 | + if (strstr($name, " ")) { | |
| 210 | + list($ns, $tag) = explode(" ", $name); | |
| 211 | + } else { | |
| 212 | + $ns = ""; | |
| 213 | + $tag = $name; | |
| 214 | + } | |
| 215 | + | |
| 216 | + // <owner> finished? | |
| 217 | + if (($ns == "DAV:") && ($tag == "owner")) { | |
| 218 | + $this->collect_owner = false; | |
| 219 | + } | |
| 220 | + | |
| 221 | + // within <owner> we have to collect everything | |
| 222 | + if ($this->collect_owner) { | |
| 223 | + $ns_short = ""; | |
| 224 | + $ns_attr = ""; | |
| 225 | + if ($ns) { | |
| 226 | + if ($ns == "DAV:") { | |
| 227 | 227 | $ns_short = "D:"; |
| 228 | - } else { | |
| 229 | - $ns_attr = " xmlns='$ns'"; | |
| 230 | - } | |
| 231 | - } | |
| 232 | - $this->owner .= "</$ns_short$tag$ns_attr>"; | |
| 233 | - } | |
| 228 | + } else { | |
| 229 | + $ns_attr = " xmlns='$ns'"; | |
| 230 | + } | |
| 231 | + } | |
| 232 | + $this->owner .= "</$ns_short$tag$ns_attr>"; | |
| 233 | + } | |
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | -?> | |
| 238 | 237 | \ No newline at end of file |
| 238 | +?> | ... | ... |
thirdparty/pear/HTTP/WebDAV/Tools/_parse_propfind.php renamed to ktwebdav/thirdparty/pear/HTTP/WebDAV/Tools/_parse_propfind.php
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | // | Christian Stocker <chregu@bitflux.ch> | |
| 18 | 18 | // +----------------------------------------------------------------------+ |
| 19 | 19 | // |
| 20 | -// $Id$ | |
| 20 | +// $Id: _parse_propfind.php,v 1.4 2006/10/10 11:53:17 hholzgra Exp $ | |
| 21 | 21 | // |
| 22 | 22 | |
| 23 | 23 | /** |
| ... | ... | @@ -25,154 +25,154 @@ |
| 25 | 25 | * |
| 26 | 26 | * @package HTTP_WebDAV_Server |
| 27 | 27 | * @author Hartmut Holzgraefe <hholzgra@php.net> |
| 28 | - * @version 0.99.1dev | |
| 28 | + * @version @package-version@ | |
| 29 | 29 | */ |
| 30 | 30 | class _parse_propfind |
| 31 | 31 | { |
| 32 | - /** | |
| 33 | - * success state flag | |
| 34 | - * | |
| 35 | - * @var bool | |
| 36 | - * @access public | |
| 37 | - */ | |
| 38 | - var $success = false; | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * found properties are collected here | |
| 42 | - * | |
| 43 | - * @var array | |
| 44 | - * @access public | |
| 45 | - */ | |
| 46 | - var $props = false; | |
| 47 | - | |
| 48 | - /** | |
| 49 | - * internal tag nesting depth counter | |
| 50 | - * | |
| 51 | - * @var int | |
| 52 | - * @access private | |
| 53 | - */ | |
| 54 | - var $depth = 0; | |
| 55 | - | |
| 56 | - | |
| 57 | - /** | |
| 58 | - * constructor | |
| 59 | - * | |
| 60 | - * @access public | |
| 61 | - */ | |
| 62 | - function _parse_propfind($path) | |
| 63 | - { | |
| 64 | - // success state flag | |
| 65 | - $this->success = true; | |
| 66 | - | |
| 67 | - // property storage array | |
| 68 | - $this->props = array(); | |
| 69 | - | |
| 70 | - // internal tag depth counter | |
| 71 | - $this->depth = 0; | |
| 72 | - | |
| 73 | - // remember if any input was parsed | |
| 74 | - $had_input = false; | |
| 75 | - | |
| 76 | - // open input stream | |
| 77 | - $f_in = fopen($path, "r"); | |
| 78 | - if (!$f_in) { | |
| 79 | - $this->success = false; | |
| 80 | - return; | |
| 81 | - } | |
| 82 | - | |
| 83 | - // create XML parser | |
| 84 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); | |
| 85 | - | |
| 86 | - // set tag and data handlers | |
| 87 | - xml_set_element_handler($xml_parser, | |
| 88 | - array(&$this, "_startElement"), | |
| 89 | - array(&$this, "_endElement")); | |
| 90 | - | |
| 91 | - // we want a case sensitive parser | |
| 92 | - xml_parser_set_option($xml_parser, | |
| 93 | - XML_OPTION_CASE_FOLDING, false); | |
| 94 | - | |
| 95 | - | |
| 96 | - // parse input | |
| 97 | - while($this->success && !feof($f_in)) { | |
| 98 | - $line = fgets($f_in); | |
| 99 | - if (is_string($line)) { | |
| 100 | - $had_input = true; | |
| 101 | - $this->success &= xml_parse($xml_parser, $line, false); | |
| 102 | - } | |
| 103 | - } | |
| 104 | - | |
| 105 | - // finish parsing | |
| 106 | - if($had_input) { | |
| 107 | - $this->success &= xml_parse($xml_parser, "", true); | |
| 108 | - } | |
| 109 | - | |
| 110 | - // free parser | |
| 111 | - xml_parser_free($xml_parser); | |
| 112 | - | |
| 113 | - // close input stream | |
| 114 | - fclose($f_in); | |
| 115 | - | |
| 116 | - // if no input was parsed it was a request | |
| 117 | - if(!count($this->props)) $this->props = "all"; // default | |
| 118 | - } | |
| 119 | - | |
| 120 | - | |
| 121 | - /** | |
| 122 | - * start tag handler | |
| 123 | - * | |
| 124 | - * @access private | |
| 125 | - * @param resource parser | |
| 126 | - * @param string tag name | |
| 127 | - * @param array tag attributes | |
| 128 | - */ | |
| 129 | - function _startElement($parser, $name, $attrs) | |
| 130 | - { | |
| 131 | - // name space handling | |
| 132 | - if (strstr($name, " ")) { | |
| 133 | - list($ns, $tag) = explode(" ", $name); | |
| 134 | - if ($ns == "") | |
| 135 | - $this->success = false; | |
| 136 | - } else { | |
| 137 | - $ns = ""; | |
| 138 | - $tag = $name; | |
| 139 | - } | |
| 140 | - | |
| 141 | - // special tags at level 1: <allprop> and <propname> | |
| 142 | - if ($this->depth == 1) { | |
| 143 | - if ($tag == "allprop") | |
| 144 | - $this->props = "all"; | |
| 145 | - | |
| 146 | - if ($tag == "propname") | |
| 147 | - $this->props = "names"; | |
| 148 | - } | |
| 149 | - | |
| 150 | - // requested properties are found at level 2 | |
| 151 | - if ($this->depth == 2) { | |
| 152 | - $prop = array("name" => $tag); | |
| 153 | - if ($ns) | |
| 154 | - $prop["xmlns"] = $ns; | |
| 155 | - $this->props[] = $prop; | |
| 156 | - } | |
| 157 | - | |
| 158 | - // increment depth count | |
| 159 | - $this->depth++; | |
| 160 | - } | |
| 161 | - | |
| 162 | - | |
| 163 | - /** | |
| 164 | - * end tag handler | |
| 165 | - * | |
| 166 | - * @access private | |
| 167 | - * @param resource parser | |
| 168 | - * @param string tag name | |
| 169 | - */ | |
| 170 | - function _endElement($parser, $name) | |
| 171 | - { | |
| 172 | - // here we only need to decrement the depth count | |
| 173 | - $this->depth--; | |
| 174 | - } | |
| 32 | + /** | |
| 33 | + * success state flag | |
| 34 | + * | |
| 35 | + * @var bool | |
| 36 | + * @access public | |
| 37 | + */ | |
| 38 | + var $success = false; | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * found properties are collected here | |
| 42 | + * | |
| 43 | + * @var array | |
| 44 | + * @access public | |
| 45 | + */ | |
| 46 | + var $props = false; | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * internal tag nesting depth counter | |
| 50 | + * | |
| 51 | + * @var int | |
| 52 | + * @access private | |
| 53 | + */ | |
| 54 | + var $depth = 0; | |
| 55 | + | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * constructor | |
| 59 | + * | |
| 60 | + * @access public | |
| 61 | + */ | |
| 62 | + function _parse_propfind($path) | |
| 63 | + { | |
| 64 | + // success state flag | |
| 65 | + $this->success = true; | |
| 66 | + | |
| 67 | + // property storage array | |
| 68 | + $this->props = array(); | |
| 69 | + | |
| 70 | + // internal tag depth counter | |
| 71 | + $this->depth = 0; | |
| 72 | + | |
| 73 | + // remember if any input was parsed | |
| 74 | + $had_input = false; | |
| 75 | + | |
| 76 | + // open input stream | |
| 77 | + $f_in = fopen($path, "r"); | |
| 78 | + if (!$f_in) { | |
| 79 | + $this->success = false; | |
| 80 | + return; | |
| 81 | + } | |
| 82 | + | |
| 83 | + // create XML parser | |
| 84 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); | |
| 85 | + | |
| 86 | + // set tag and data handlers | |
| 87 | + xml_set_element_handler($xml_parser, | |
| 88 | + array(&$this, "_startElement"), | |
| 89 | + array(&$this, "_endElement")); | |
| 90 | + | |
| 91 | + // we want a case sensitive parser | |
| 92 | + xml_parser_set_option($xml_parser, | |
| 93 | + XML_OPTION_CASE_FOLDING, false); | |
| 94 | + | |
| 95 | + | |
| 96 | + // parse input | |
| 97 | + while ($this->success && !feof($f_in)) { | |
| 98 | + $line = fgets($f_in); | |
| 99 | + if (is_string($line)) { | |
| 100 | + $had_input = true; | |
| 101 | + $this->success &= xml_parse($xml_parser, $line, false); | |
| 102 | + } | |
| 103 | + } | |
| 104 | + | |
| 105 | + // finish parsing | |
| 106 | + if ($had_input) { | |
| 107 | + $this->success &= xml_parse($xml_parser, "", true); | |
| 108 | + } | |
| 109 | + | |
| 110 | + // free parser | |
| 111 | + xml_parser_free($xml_parser); | |
| 112 | + | |
| 113 | + // close input stream | |
| 114 | + fclose($f_in); | |
| 115 | + | |
| 116 | + // if no input was parsed it was a request | |
| 117 | + if(!count($this->props)) $this->props = "all"; // default | |
| 118 | + } | |
| 119 | + | |
| 120 | + | |
| 121 | + /** | |
| 122 | + * start tag handler | |
| 123 | + * | |
| 124 | + * @access private | |
| 125 | + * @param resource parser | |
| 126 | + * @param string tag name | |
| 127 | + * @param array tag attributes | |
| 128 | + */ | |
| 129 | + function _startElement($parser, $name, $attrs) | |
| 130 | + { | |
| 131 | + // name space handling | |
| 132 | + if (strstr($name, " ")) { | |
| 133 | + list($ns, $tag) = explode(" ", $name); | |
| 134 | + if ($ns == "") | |
| 135 | + $this->success = false; | |
| 136 | + } else { | |
| 137 | + $ns = ""; | |
| 138 | + $tag = $name; | |
| 139 | + } | |
| 140 | + | |
| 141 | + // special tags at level 1: <allprop> and <propname> | |
| 142 | + if ($this->depth == 1) { | |
| 143 | + if ($tag == "allprop") | |
| 144 | + $this->props = "all"; | |
| 145 | + | |
| 146 | + if ($tag == "propname") | |
| 147 | + $this->props = "names"; | |
| 148 | + } | |
| 149 | + | |
| 150 | + // requested properties are found at level 2 | |
| 151 | + if ($this->depth == 2) { | |
| 152 | + $prop = array("name" => $tag); | |
| 153 | + if ($ns) | |
| 154 | + $prop["xmlns"] = $ns; | |
| 155 | + $this->props[] = $prop; | |
| 156 | + } | |
| 157 | + | |
| 158 | + // increment depth count | |
| 159 | + $this->depth++; | |
| 160 | + } | |
| 161 | + | |
| 162 | + | |
| 163 | + /** | |
| 164 | + * end tag handler | |
| 165 | + * | |
| 166 | + * @access private | |
| 167 | + * @param resource parser | |
| 168 | + * @param string tag name | |
| 169 | + */ | |
| 170 | + function _endElement($parser, $name) | |
| 171 | + { | |
| 172 | + // here we only need to decrement the depth count | |
| 173 | + $this->depth--; | |
| 174 | + } | |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
| 178 | -?> | |
| 179 | 178 | \ No newline at end of file |
| 179 | +?> | ... | ... |
thirdparty/pear/HTTP/WebDAV/Tools/_parse_proppatch.php renamed to ktwebdav/thirdparty/pear/HTTP/WebDAV/Tools/_parse_proppatch.php
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | // | Christian Stocker <chregu@bitflux.ch> | |
| 18 | 18 | // +----------------------------------------------------------------------+ |
| 19 | 19 | // |
| 20 | -// $Id$ | |
| 20 | +// $Id: _parse_proppatch.php,v 1.6 2006/10/10 11:53:17 hholzgra Exp $ | |
| 21 | 21 | // |
| 22 | 22 | |
| 23 | 23 | /** |
| ... | ... | @@ -25,7 +25,7 @@ |
| 25 | 25 | * |
| 26 | 26 | * @package HTTP_WebDAV_Server |
| 27 | 27 | * @author Hartmut Holzgraefe <hholzgra@php.net> |
| 28 | - * @version 0.99.1dev | |
| 28 | + * @version @package-version@ | |
| 29 | 29 | */ |
| 30 | 30 | class _parse_proppatch |
| 31 | 31 | { |
| ... | ... | @@ -152,8 +152,10 @@ class _parse_proppatch |
| 152 | 152 | |
| 153 | 153 | if ($this->depth >= 4) { |
| 154 | 154 | $this->current["val"] .= "<$tag"; |
| 155 | - foreach ($attr as $key => $val) { | |
| 156 | - $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; | |
| 155 | + if (isset($attr)) { | |
| 156 | + foreach ($attr as $key => $val) { | |
| 157 | + $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; | |
| 158 | + } | |
| 157 | 159 | } |
| 158 | 160 | $this->current["val"] .= ">"; |
| 159 | 161 | } |
| ... | ... | @@ -204,11 +206,18 @@ class _parse_proppatch |
| 204 | 206 | * @return void |
| 205 | 207 | * @access private |
| 206 | 208 | */ |
| 207 | - function _data($parser, $data) { | |
| 209 | + function _data($parser, $data) | |
| 210 | + { | |
| 208 | 211 | if (isset($this->current)) { |
| 209 | 212 | $this->current["val"] .= $data; |
| 210 | 213 | } |
| 211 | 214 | } |
| 212 | 215 | } |
| 213 | 216 | |
| 214 | -?> | |
| 215 | 217 | \ No newline at end of file |
| 218 | +/* | |
| 219 | + * Local variables: | |
| 220 | + * tab-width: 4 | |
| 221 | + * c-basic-offset: 4 | |
| 222 | + * indent-tabs-mode:nil | |
| 223 | + * End: | |
| 224 | + */ | ... | ... |