38 require_once
"DAV/_parse_propfind.php";
39 require_once
"DAV/_parse_proppatch.php";
40 require_once
"DAV/_parse_lockinfo.php";
118 ini_set(
"display_errors", 0);
137 if (strstr($this->_SERVER[
"REQUEST_URI"],
'#')) {
142 $uri = (@$this->_SERVER[
"HTTPS"] ===
"on" ?
"https:" :
"http:");
143 $uri.=
"//$this->_SERVER[HTTP_HOST]$this->_SERVER[SCRIPT_NAME]";
145 $path_info = empty($this->_SERVER[
"PATH_INFO"]) ?
"/" : $this->_SERVER[
"PATH_INFO"];
147 $this->base_uri =
$uri;
148 $this->uri =
$uri . $path_info;
151 if (!strlen($this->
path)) {
152 if ($this->_SERVER[
"REQUEST_METHOD"] ==
"GET") {
156 header(
"Location: " . $this->base_uri .
"/");
164 if (ini_get(
"magic_quotes_gpc")) {
165 $this->
path = stripslashes($this->
path);
168 if (empty($this->dav_powered_by)) {
169 header(
"X-Dav-Powered-By: PHP class: " . get_class($this));
171 header(
"X-Dav-Powered-By: " . $this->dav_powered_by);
176 if ((!(($this->_SERVER[
'REQUEST_METHOD'] ==
'OPTIONS') && ($this->
path ==
"/"))) && (!$this->
_check_auth())) {
181 header(
'WWW-Authenticate: Basic realm="' . ($this->
http_auth_realm) .
'"');
193 $method = strtolower($this->_SERVER[
"REQUEST_METHOD"]);
196 if (
$method ==
"head" && !method_exists($this,
"head")) {
200 if (method_exists($this, $wrapper) && (
$method ==
"options" || method_exists($this,
$method))) {
204 $this->logContents();
211 if ($this->_SERVER[
"REQUEST_METHOD"] ==
"LOCK") {
215 header(
"Allow: " . join(
", ", $this->
_allow()));
221 private function logContents()
223 $a = ob_get_contents();
224 if (substr(
$a, 0, 5) ==
'<?xml') {
225 $c = explode(
"\n",
$a);
463 header(
"MS-Author-Via: DAV");
470 if (isset($allow[
'LOCK'])) {
476 header(
"DAV: " . join(
", ", $dav));
477 header(
"Allow: " . join(
", ", $allow));
479 header(
"Content-length: 0");
497 if (isset($this->_SERVER[
'HTTP_DEPTH'])) {
498 $options[
"depth"] = $this->_SERVER[
"HTTP_DEPTH"];
500 $options[
"depth"] =
"infinity";
504 if (!$propinfo->success) {
508 $options[
'props'] = $propinfo->props;
510 if (!$this->PROPFIND($options, $files)) {
514 if (method_exists($this,
"checkLock")) {
516 $lock = $this->checkLock($this->
path);
518 if (is_array($lock) && count($lock)) {
519 $created = isset($lock[
'created']) ? $lock[
'created'] : time();
520 $modified = isset($lock[
'modified']) ? $lock[
'modified'] : time();
521 $files[
'files'][] = array(
525 $this->
mkprop(
"creationdate", $created) ,
526 $this->
mkprop(
"getlastmodified", $modified) ,
527 $this->
mkprop(
"resourcetype",
"") ,
528 $this->
mkprop(
"getcontenttype",
"") ,
529 $this->
mkprop(
"getcontentlength", 0)
535 if (empty($files[
'files'])) {
543 $ns_defs =
"xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\"";
545 foreach ($files[
"files"] as $filekey =>
$file) {
547 if (!isset(
$file[
"props"]) || !is_array(
$file[
"props"])) {
551 foreach (
$file[
"props"] as $key => $prop) {
555 switch ($options[
'props']) {
563 unset($files[
"files"][$filekey][
"props"][$key][
"val"]);
569 foreach ((array)$options[
"props"] as $reqprop) {
570 if ($reqprop[
"name"] == $prop[
"name"] && @$reqprop[
"xmlns"] == $prop[
"ns"]) {
577 $files[
"files"][$filekey][
"props"][$key] =
"";
583 if (empty($prop[
"ns"]))
continue;
585 if ($ns ==
"DAV:")
continue;
586 if (isset($ns_hash[$ns]))
continue;
588 $ns_name =
"ns" . (count($ns_hash) + 1);
589 $ns_hash[$ns] = $ns_name;
590 $ns_defs.=
" xmlns:$ns_name=\"$ns\"";
594 if (is_array($options[
'props'])) {
595 foreach ($options[
"props"] as $reqprop) {
596 if ($reqprop[
'name'] ==
"")
continue;
599 foreach (
$file[
"props"] as $prop) {
600 if ($reqprop[
"name"] == $prop[
"name"] && @$reqprop[
"xmlns"] == $prop[
"ns"]) {
607 if ($reqprop[
"xmlns"] ===
"DAV:" && $reqprop[
"name"] ===
"lockdiscovery") {
609 $files[
"files"][$filekey][
"props"][] = $this->
mkprop(
"DAV:",
"lockdiscovery", $this->
lockdiscovery($files[
"files"][$filekey][
'path']));
612 $files[
"files"][$filekey][
"noprops"][] = $this->
mkprop($reqprop[
"xmlns"], $reqprop[
"name"],
"");
614 if ($reqprop[
"xmlns"] !=
"DAV:" && !isset($ns_hash[$reqprop[
"xmlns"]])) {
615 $ns_name =
"ns" . (count($ns_hash) + 1);
616 $ns_hash[$reqprop[
"xmlns"]] = $ns_name;
617 $ns_defs.=
" xmlns:$ns_name=\"$reqprop[xmlns]\"";
626 header(
'Content-Type: text/xml; charset="utf-8"');
628 echo
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
629 echo
"<D:multistatus xmlns:D=\"DAV:\">\n";
631 foreach ($files[
"files"] as
$file) {
633 if (!is_array($file) || empty($file) || !isset($file[
"path"]))
continue;
634 $path = $file[
'path'];
635 if (!is_string(
$path) ||
$path ===
"")
continue;
637 echo
" <D:response $ns_defs>\n";
643 echo
" <D:href>" . $this->
_urlencode($href) .
"</D:href>\n";
645 if (isset($file[
"props"]) && is_array($file[
"props"])) {
646 echo
" <D:propstat>\n";
649 foreach ($file[
"props"] as $key => $prop) {
651 if (!is_array($prop))
continue;
652 if (!isset($prop[
"name"]))
continue;
654 if (!isset($prop[
"val"]) || $prop[
"val"] ===
"" || $prop[
"val"] ===
false) {
656 if ($prop[
"ns"] ==
"DAV:") {
657 echo
" <D:$prop[name]/>\n";
658 }
else if (!empty($prop[
"ns"])) {
659 echo
" <" . $ns_hash[$prop[
"ns"]] .
":$prop[name]/>\n";
661 echo
" <$prop[name] xmlns=\"\"/>";
663 }
else if ($prop[
"ns"] ==
"DAV:") {
665 switch ($prop[
"name"]) {
667 echo
" <D:creationdate ns0:dt=\"dateTime.tz\">" . gmdate(
"Y-m-d\\TH:i:s\\Z", $prop[
'val']) .
"</D:creationdate>\n";
670 case "getlastmodified":
671 echo
" <D:getlastmodified ns0:dt=\"dateTime.rfc1123\">" . gmdate(
"D, d M Y H:i:s ", $prop[
'val']) .
"GMT</D:getlastmodified>\n";
675 echo
" <D:resourcetype><D:$prop[val]/></D:resourcetype>\n";
678 case "supportedlock":
679 echo
" <D:supportedlock>$prop[val]</D:supportedlock>\n";
682 case "lockdiscovery":
683 echo
" <D:lockdiscovery>\n";
685 echo
" </D:lockdiscovery>\n";
689 echo
" <D:$prop[name]>" . $this->
_prop_encode(htmlspecialchars($prop[
'val'])) .
"</D:$prop[name]>\n";
695 echo
" <" . $ns_hash[$prop[
"ns"]] .
":$prop[name]>" . $this->
_prop_encode(htmlspecialchars($prop[
'val'])) .
"</" . $ns_hash[$prop[
"ns"]] .
":$prop[name]>\n";
697 echo
" <$prop[name] xmlns=\"\">" . $this->
_prop_encode(htmlspecialchars($prop[
'val'])) .
"</$prop[name]>\n";
703 echo
" <D:status>HTTP/1.1 200 OK</D:status>\n";
704 echo
" </D:propstat>\n";
707 if (isset($file[
"noprops"])) {
708 echo
" <D:propstat>\n";
711 foreach ($file[
"noprops"] as $key => $prop) {
712 if ($prop[
"ns"] ==
"DAV:") {
713 echo
" <D:$prop[name]/>\n";
714 }
else if ($prop[
"ns"] ==
"") {
715 echo
" <$prop[name] xmlns=\"\"/>\n";
717 echo
" <" . $ns_hash[$prop[
"ns"]] .
":$prop[name]/>\n";
722 echo
" <D:status>HTTP/1.1 404 Not Found</D:status>\n";
723 echo
" </D:propstat>\n";
726 echo
" </D:response>\n";
729 echo
"</D:multistatus>\n";
749 if (!$propinfo->success) {
754 $options[
'props'] = $propinfo->props;
756 $responsedescr = $this->PROPPATCH($options);
759 header(
'Content-Type: text/xml; charset="utf-8"');
761 echo
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
763 echo
"<D:multistatus xmlns:D=\"DAV:\">\n";
764 echo
" <D:response>\n";
767 foreach ($options[
"props"] as $prop) {
768 echo
" <D:propstat>\n";
769 echo
" <D:prop><$prop[name] xmlns=\"$prop[ns]\"/></D:prop>\n";
770 echo
" <D:status>HTTP/1.1 $prop[status]</D:status>\n";
771 echo
" </D:propstat>\n";
774 if ($responsedescr) {
775 echo
" <D:responsedescription>" . $this->
_prop_encode(htmlspecialchars($responsedescr)) .
"</D:responsedescription>\n";
778 echo
" </D:response>\n";
779 echo
"</D:multistatus>\n";
799 $stat = $this->MKCOL($options);
820 if (
true === ($status = $this->GET($options))) {
821 if (!headers_sent()) {
824 if (!isset($options[
'mimetype'])) {
825 $options[
'mimetype'] =
"application/octet-stream";
827 header(
"Content-type: $options[mimetype]");
829 if (isset($options[
'mtime'])) {
830 header(
"Last-modified:" . gmdate(
"D, d M Y H:i:s ", $options[
'mtime']) .
"GMT");
833 if (isset($options[
'stream'])) {
835 if (!empty($options[
'ranges']) && (0 === fseek($options[
'stream'], 0, SEEK_SET))) {
837 if (count($options[
'ranges']) === 1) {
838 $range = $options[
'ranges'][0];
840 if (isset($range[
'start'])) {
841 fseek($options[
'stream'], $range[
'start'], SEEK_SET);
842 if (feof($options[
'stream'])) {
843 $this->
http_status(
"416 Requested range not satisfiable");
847 if (isset($range[
'end'])) {
848 $size = $range[
'end'] - $range[
'start'] + 1;
850 header(
"Content-length: $size");
851 header(
"Content-range: $range[start]-$range[end]/" . (isset($options[
'size']) ? $options[
'size'] :
"*"));
852 while (
$size && !feof($options[
'stream'])) {
853 $buffer = fread($options[
'stream'], 4096);
854 $size-= strlen($buffer);
859 if (isset($options[
'size'])) {
860 header(
"Content-length: " . ($options[
'size'] - $range[
'start']));
861 header(
"Content-range: " . $range[
'start'] .
"-" . $range[
'end'] .
"/" . (isset($options[
'size']) ? $options[
'size'] :
"*"));
863 fpassthru($options[
'stream']);
866 header(
"Content-length: " . $range[
'last']);
867 fseek($options[
'stream'], -$range[
'last'], SEEK_END);
868 fpassthru($options[
'stream']);
872 foreach ($options[
'ranges'] as $range) {
874 if (isset($range[
'start'])) {
875 $from = $range[
'start'];
876 $to = !empty($range[
'end']) ? $range[
'end'] : $options[
'size'] - 1;
878 $from = $options[
'size'] - $range[
'last'] - 1;
879 $to = $options[
'size'] - 1;
881 $total = isset($options[
'size']) ? $options[
'size'] :
"*";
885 fseek($options[
'stream'], $from, SEEK_SET);
886 while (
$size && !feof($options[
'stream'])) {
887 $buffer = fread($options[
'stream'], 4096);
888 $size-= strlen($buffer);
897 if (isset($options[
'size'])) {
898 header(
"Content-length: " . $options[
'size']);
900 fpassthru($options[
'stream']);
904 } elseif (isset($options[
'data'])) {
905 if (is_array($options[
'data'])) {
909 header(
"Content-length: " . strlen($options[
'data']));
910 echo $options[
'data'];
916 if (!headers_sent()) {
917 if (
false === $status) {
934 if (isset($this->_SERVER[
'HTTP_RANGE'])) {
936 if (preg_match(
'/bytes\s*=\s*(.+)/', $this->_SERVER[
'HTTP_RANGE'], $matches)) {
937 $options[
"ranges"] = array();
939 foreach (explode(
",", $matches[1]) as $range) {
941 list(
$start, $end) = explode(
"-", $range);
942 $options[
"ranges"][] = (
$start ===
"") ? array(
968 if (!isset($this->multipart_separator)) {
972 $this->multipart_separator =
"SEPARATOR_" . md5(microtime());
974 header(
"Content-type: multipart/byteranges; boundary=" . $this->multipart_separator);
978 echo
"\n--{$this->multipart_separator}--";
982 echo
"\n--{$this->multipart_separator}\n";
983 echo
"Content-type: $mimetype\n";
984 echo
"Content-range: $from-$to/" . (
$total ===
false ?
"*" :
$total);
1003 if (method_exists($this,
"HEAD")) {
1004 $status = $this->
head($options);
1005 }
else if (method_exists($this,
"GET")) {
1007 $status = $this->GET($options);
1008 if (!isset($options[
'size'])) {
1009 $options[
'size'] = ob_get_length();
1014 if (!isset($options[
'mimetype'])) {
1015 $options[
'mimetype'] =
"application/octet-stream";
1017 header(
"Content-type: $options[mimetype]");
1019 if (isset($options[
'mtime'])) {
1020 header(
"Last-modified:" . gmdate(
"D, d M Y H:i:s ", $options[
'mtime']) .
"GMT");
1023 if (isset($options[
'size'])) {
1024 header(
"Content-length: " . $options[
'size']);
1027 if ($status ===
true) $status =
"200 OK";
1028 if ($status ===
false) $status =
"404 Not found";
1046 $options[
"content_length"] = $this->_SERVER[
"CONTENT_LENGTH"];
1048 if (isset($this->_SERVER[
"CONTENT_TYPE"])) {
1050 if (!strncmp($this->_SERVER[
"CONTENT_TYPE"],
"multipart/", 10)) {
1052 echo
"The service does not support mulipart PUT requests";
1055 $options[
"content_type"] = $this->_SERVER[
"CONTENT_TYPE"];
1058 $options[
"content_type"] =
"application/octet-stream";
1065 foreach ($this->_SERVER as $key => $val) {
1066 if (strncmp($key,
"HTTP_CONTENT", 11))
continue;
1068 case 'HTTP_CONTENT_ENCODING':
1071 echo
"The service does not support '$val' content encoding";
1073 case 'HTTP_CONTENT_LANGUAGE':
1076 $options[
"content_language"] = $val;
1079 case 'HTTP_CONTENT_LOCATION':
1085 case 'HTTP_CONTENT_RANGE':
1089 if (!preg_match(
'@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches)) {
1091 echo
"The service does only support single byte ranges";
1096 "start" => $matches[1],
1097 "end" => $matches[2]
1099 if (is_numeric($matches[3])) {
1100 $range[
"total_length"] = $matches[3];
1102 $option[
"ranges"][] = $range;
1108 case 'HTTP_CONTENT_MD5':
1111 echo
"The service does not support content MD5 checksum verification";
1116 echo
"The service does not support '$key'";
1121 $options[
"stream"] = fopen(
"php://input",
"r");
1123 $stat = $this->PUT($options);
1125 if (
$stat ===
false) {
1126 $stat =
"403 Forbidden";
1127 }
else if (is_resource(
$stat) && get_resource_type(
$stat) ==
"stream") {
1130 $stat = $options[
"new"] ?
"201 Created" :
"204 No Content";
1132 if (!empty($options[
"ranges"])) {
1134 if (0 == fseek($stream, $range[0][
"start"], SEEK_SET)) {
1135 $length = $range[0][
"end"] - $range[0][
"start"] + 1;
1136 if (!fwrite($stream, fread($options[
"stream"], $length))) {
1137 $stat =
"403 Forbidden";
1140 $stat =
"403 Forbidden";
1143 while (!feof($options[
"stream"])) {
1144 if (
false === fwrite($stream, fread($options[
"stream"], 4096))) {
1145 $stat =
"403 Forbidden";
1171 if (isset($this->_SERVER[
"HTTP_DEPTH"])) {
1172 if ($this->_SERVER[
"HTTP_DEPTH"] !=
"infinity") {
1183 $stat = $this->DELETE($options);
1238 if (isset($this->_SERVER[
'HTTP_DEPTH'])) {
1239 $options[
"depth"] = $this->_SERVER[
"HTTP_DEPTH"];
1241 $options[
"depth"] =
"infinity";
1244 if (isset($this->_SERVER[
"HTTP_TIMEOUT"])) {
1245 $options[
"timeout"] = explode(
",", $this->_SERVER[
"HTTP_TIMEOUT"]);
1248 if (empty($this->_SERVER[
'CONTENT_LENGTH']) && !empty($this->_SERVER[
'HTTP_IF'])) {
1255 $options[
"locktoken"] = substr($this->_SERVER[
'HTTP_IF'], 2, -2);
1256 $options[
"update"] = $options[
"locktoken"];
1258 $options[
'owner'] =
"unknown";
1259 $options[
'scope'] =
"exclusive";
1260 $options[
'type'] =
"write";
1262 $stat = $this->LOCK($options);
1266 if (!$lockinfo->success) {
1275 $options[
"scope"] = $lockinfo->lockscope;
1276 $options[
"type"] = $lockinfo->locktype;
1277 $options[
"owner"] = $lockinfo->owner;
1280 $stat = $this->LOCK($options);
1283 if (is_bool(
$stat)) {
1284 $http_stat =
$stat ?
"200 OK" :
"423 Locked";
1290 if ($http_stat{0} == 2) {
1291 if ($options[
"timeout"]) {
1294 if ($options[
"timeout"] > 1000000) {
1295 $timeout =
"Second-" . ($options[
'timeout'] - time());
1297 $timeout =
"Second-$options[timeout]";
1300 $timeout =
"Infinite";
1303 header(
'Content-Type: text/xml; charset="utf-8"');
1304 header(
"Lock-Token: <$options[locktoken]>");
1305 echo
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
1306 echo
"<D:prop xmlns:D=\"DAV:\">\n";
1307 echo
" <D:lockdiscovery>\n";
1308 echo
" <D:activelock>\n";
1309 echo
" <D:lockscope><D:$options[scope]/></D:lockscope>\n";
1310 echo
" <D:locktype><D:$options[type]/></D:locktype>\n";
1311 echo
" <D:depth>$options[depth]</D:depth>\n";
1312 echo
" <D:owner>$options[owner]</D:owner>\n";
1313 echo
" <D:timeout>$timeout</D:timeout>\n";
1314 echo
" <D:locktoken><D:href>$options[locktoken]</D:href></D:locktoken>\n";
1315 echo
" </D:activelock>\n";
1316 echo
" </D:lockdiscovery>\n";
1317 echo
"</D:prop>\n\n";
1334 if (isset($this->_SERVER[
'HTTP_DEPTH'])) {
1335 $options[
"depth"] = $this->_SERVER[
"HTTP_DEPTH"];
1337 $options[
"depth"] =
"infinity";
1340 $options[
"token"] = trim($this->_SERVER[
"HTTP_LOCK_TOKEN"],
'<> ');
1342 $stat = $this->UNLOCK($options);
1354 if (isset($this->_SERVER[
"HTTP_DEPTH"])) {
1355 $options[
"depth"] = $this->_SERVER[
"HTTP_DEPTH"];
1357 $options[
"depth"] =
"infinity";
1360 extract(parse_url($this->_SERVER[
"HTTP_DESTINATION"]));
1364 if (isset(
$port) &&
$port != 80) $http_host.=
":$port";
1366 $http_header_host = preg_replace(
"/:80$/",
"", $this->_SERVER[
"HTTP_HOST"]);
1368 $basepath = dirname(
$_SERVER[
"PHP_SELF"]);
1369 if ($http_host == $http_header_host
1373 if (strlen($basepath) > 1) {
1376 $options[
"dest"] =
$path;
1383 $options[
"dest_url"] = $this->_SERVER[
"HTTP_DESTINATION"];
1386 if (isset($this->_SERVER[
"HTTP_OVERWRITE"])) {
1387 $options[
"overwrite"] = $this->_SERVER[
"HTTP_OVERWRITE"] ==
"T";
1389 $options[
"overwrite"] =
true;
1392 $stat = $this->$what($options);
1408 "OPTIONS" =>
"OPTIONS"
1413 foreach (get_class_methods($this) as
$method) {
1414 if (!strncmp(
"http_", $method, 5)) {
1415 $method = strtoupper(substr($method, 5));
1416 if (method_exists($this, $method)) {
1422 if (isset($allow[
"GET"])) $allow[
"HEAD"] =
"HEAD";
1424 if (!method_exists($this,
"checklock")) {
1425 unset($allow[
"LOCK"]);
1426 unset($allow[
"UNLOCK"]);
1443 $args = func_get_args();
1444 if (count($args) == 3) {
1468 if (method_exists($this,
"checkAuth")) {
1470 return $this->checkAuth(@$this->_SERVER[
"AUTH_TYPE"], @$this->_SERVER[
"PHP_AUTH_USER"], @$this->_SERVER[
"PHP_AUTH_PW"]);
1471 }
else if (method_exists($this,
"check_auth")) {
1473 return $this->check_auth(@$this->_SERVER[
"AUTH_TYPE"], @$this->_SERVER[
"PHP_AUTH_USER"], @$this->_SERVER[
"PHP_AUTH_PW"]);
1491 if (function_exists(
"uuid_create")) {
1492 return uuid_create();
1495 $uuid = md5(microtime() . getmypid());
1498 $n = 8 + (ord($uuid{16}) & 3);
1499 $hex =
"0123456789abcdef";
1500 $uuid{16} = $hex{$n};
1502 return substr($uuid, 0, 8) .
"-" . substr($uuid, 8, 4) .
"-" . substr($uuid, 12, 4) .
"-" . substr($uuid, 16, 4) .
"-" . substr($uuid, 20);
1512 return "opaquelocktoken:" . $this->
_new_uuid();
1527 while (ctype_space($string{$pos})) {
1531 if (strlen($string) <= $pos) {
1535 $c = $string{$pos++};
1540 $pos2 = strpos($string,
">", $pos);
1541 $uri = substr($string, $pos, $pos2 - $pos);
1549 if ($string{$pos} ==
"W") {
1550 $type =
"ETAG_WEAK";
1553 $type =
"ETAG_STRONG";
1555 $pos2 = strpos($string,
"]", $pos);
1556 $etag = substr($string, $pos + 1, $pos2 - $pos - 2);
1586 $len = strlen($str);
1589 while ($pos < $len) {
1593 if ($token[0] ==
"URI") {
1601 if ($token[0] !=
"CHAR" || $token[1] !=
"(") {
1610 if ($token[0] ==
"NOT") {
1614 switch ($token[0]) {
1616 switch ($token[1]) {
1631 $list[] = $not .
"<$token[1]>";
1635 $list[] = $not .
"[W/'$token[1]']>";
1639 $list[] = $not .
"['$token[1]']>";
1648 if (@is_array($uris[
$uri])) {
1649 $uris[
$uri] = array_merge($uris[$uri],
$list);
1668 if (isset($this->_SERVER[
"HTTP_IF"])) {
1671 foreach ($this->_if_header_uris as
$uri => $conditions) {
1677 foreach ($conditions as $condition) {
1681 if (!strncmp($condition,
"<opaquelocktoken:", strlen(
"<opaquelocktoken"))) {
1682 if (!preg_match(
'/^<opaquelocktoken:[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}>$/', $condition)) {
1694 if ($state ==
true) {
1718 if (!strncmp(
"<DAV:", $condition, 5)) {
1733 if (method_exists($this,
"checkLock")) {
1735 $lock = $this->checkLock(
$path);
1737 if (is_array($lock) && count($lock)) {
1739 if (!isset($this->_SERVER[
"HTTP_IF"]) || !strstr($this->_SERVER[
"HTTP_IF"], $lock[
"token"])) {
1740 if (!$exclusive_only || ($lock[
"scope"] !==
"shared"))
return false;
1758 if (!method_exists($this,
"checklock")) {
1764 $lock = $this->checklock(
$path);
1766 if (is_array($lock) && count($lock)) {
1768 if (!empty($lock[
"expires"])) {
1769 $timeout =
"Second-" . ($lock[
"expires"] - time());
1770 }
else if (!empty($lock[
"timeout"])) {
1771 $timeout =
"Second-$lock[timeout]";
1773 $timeout =
"Infinite";
1778 <D:lockscope><D:$lock[scope]/></D:lockscope>
1779 <D:locktype><D:$lock[type]/></D:locktype>
1780 <D:depth>$lock[depth]</D:depth>
1781 <D:owner>$lock[owner]</D:owner>
1782 <D:timeout>$timeout</D:timeout>
1783 <D:locktoken><D:href>$lock[token]</D:href></D:locktoken>
1788 return $activelocks;
1799 if ($status ===
true) {
1803 $this->_http_status = $status;
1805 header(
"HTTP/1.1 $status");
1806 header(
"X-WebDAV-Status: $status",
true);
1819 $r = rawurlencode($url);
1820 return str_replace(
"%2F",
"/",
$r);
1832 return urldecode(
$path);
1842 switch (strtolower($this->_prop_encoding)) {
1849 return utf8_encode($text);
1887 if ($child{0} ==
'/') {
1890 return $this->
_slashify($parent) . $child;