From: Michael M Slusarz Date: Mon, 13 Jul 2009 19:41:36 +0000 (-0600) Subject: whitespace X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a8faa084c42c8bc345183b88ee5e665969e9079e;p=horde.git whitespace --- diff --git a/framework/Rpc/lib/Horde/Rpc/Webdav.php b/framework/Rpc/lib/Horde/Rpc/Webdav.php index 5787ffa23..910d2ba27 100644 --- a/framework/Rpc/lib/Horde/Rpc/Webdav.php +++ b/framework/Rpc/lib/Horde/Rpc/Webdav.php @@ -47,7 +47,6 @@ * @author Ben Klang * @author Hartmut Holzgraefe * @author Christian Stocker - * @since Horde 3.0 * @package Horde_Rpc */ class Horde_Rpc_Webdav extends Horde_Rpc @@ -131,7 +130,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc /** * - * + * * @var * @access */ @@ -139,7 +138,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc /** * - * + * * @var * @access */ @@ -148,15 +147,15 @@ class Horde_Rpc_Webdav extends Horde_Rpc /** * complete URI for this request * - * @var string + * @var string */ var $uri; - - + + /** * base URI for this request * - * @var string + * @var string */ var $base_uri; @@ -164,12 +163,12 @@ class Horde_Rpc_Webdav extends Horde_Rpc /** * URI path for this request * - * @var string + * @var string */ var $path; /** - * Remember parsed If: (RFC2518/9.4) header conditions + * Remember parsed If: (RFC2518/9.4) header conditions * * @var array */ @@ -480,12 +479,13 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @return mixed Array of objects with properties if the request is a dir, * array of file metadata + data if request is a file, * false if the object is not found. + * @throws Horde_Exception */ function _list($options) { global $registry; - // $path (or $options['path']) is the node on which we will list + // $path (or $options['path']) is the node on which we will list // collections and resources. $this->path is the path of the original // request from the client. $path = $options['path']; @@ -510,7 +510,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc // $list will contain the data to return to the client $list = array(); - + if ($path == '/') { // $root is a virtual collection describing the root of the Horde // WebDAV space @@ -664,7 +664,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc $props[] = $this->mkprop('caldav', 'calendar-home-set', $calendar_home_set); unset($properties[self::CALDAVNS]['calendar-home-set']); } - + if (in_array('calendar-user-address-set', $properties[self::CALDAVNS]) && isset($item[self::CALDAVNS . ':calendar-user-address-set'])) { $calendar_user_address_set = array(); @@ -910,15 +910,15 @@ class Horde_Rpc_Webdav extends Horde_Rpc } } - /** + /** * Serve WebDAV HTTP request * * dispatch WebDAV HTTP request to the apropriate method handler - * + * * @param void * @return void */ - function ServeRequest() + function ServeRequest() { // prevent warning in litmus check 'delete_fragment' if (strstr($this->_SERVER["REQUEST_URI"], '#')) { @@ -932,7 +932,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc $uri = "https"; } $uri.= "://".$this->_SERVER["HTTP_HOST"].$this->_SERVER["SCRIPT_NAME"]; - + // WebDAV has no concept of a query string and clients (including cadaver) // seem to pass '?' unencoded, so we need to extract the path info out // of the request URI ourselves @@ -959,13 +959,13 @@ class Horde_Rpc_Webdav extends Horde_Rpc // if a WebDAV client didn't give a path we just assume '/' $this->path = "/"; } - } - + } + if (ini_get("magic_quotes_gpc")) { $this->path = stripslashes($this->path); } - - + + // identify ourselves if (empty($this->dav_powered_by)) { header("X-Dav-Powered-By: PHP class: ".get_class($this)); @@ -974,7 +974,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc } // check authentication - // for the motivation for not checking OPTIONS requests on / see + // for the motivation for not checking OPTIONS requests on / see // http://pear.php.net/bugs/bug.php?id=5363 if ( ( !(($this->_SERVER['REQUEST_METHOD'] == 'OPTIONS') && ($this->path == "/"))) && (!$this->_check_auth())) { @@ -990,21 +990,21 @@ class Horde_Rpc_Webdav extends Horde_Rpc return; } - - // check + + // check if (! $this->_check_if_header_conditions()) { return; } - + // detect requested method names $method = strtolower($this->_SERVER["REQUEST_METHOD"]); $wrapper = "http_".$method; - + // activate HEAD emulation by GET if no HEAD method found if ($method == "head" && !method_exists($this, "head")) { $method = "get"; } - + if (method_exists($this, $wrapper) && ($method == "options" || method_exists($this, $method))) { $this->$wrapper(); // call method by name } else { // method not found/implemented @@ -1019,254 +1019,254 @@ class Horde_Rpc_Webdav extends Horde_Rpc // }}} - // {{{ abstract WebDAV methods + // {{{ abstract WebDAV methods - // {{{ GET() + // {{{ GET() /** * GET implementation * * overload this method to retrieve resources from your server *
- * * - * @abstract + * + * @abstract * @param array &$params Array of input and output parameters *
input *
output * @returns int HTTP-Statuscode */ /* abstract - function GET(&$params) + function GET(&$params) { // dummy entry for PHPDoc - } + } */ // }}} - // {{{ PUT() + // {{{ PUT() /** * PUT implementation * * PUT implementation * - * @abstract + * @abstract * @param array &$params * @returns int HTTP-Statuscode */ - + /* abstract - function PUT() + function PUT() { // dummy entry for PHPDoc - } + } */ - + // }}} - // {{{ COPY() + // {{{ COPY() /** * COPY implementation * * COPY implementation * - * @abstract + * @abstract * @param array &$params * @returns int HTTP-Statuscode */ - + /* abstract - function COPY() + function COPY() { // dummy entry for PHPDoc - } + } */ // }}} - // {{{ MOVE() + // {{{ MOVE() /** * MOVE implementation * * MOVE implementation * - * @abstract + * @abstract * @param array &$params * @returns int HTTP-Statuscode */ - + /* abstract - function MOVE() + function MOVE() { // dummy entry for PHPDoc - } + } */ // }}} - // {{{ DELETE() + // {{{ DELETE() /** * DELETE implementation * * DELETE implementation * - * @abstract + * @abstract * @param array &$params * @returns int HTTP-Statuscode */ - + /* abstract - function DELETE() + function DELETE() { // dummy entry for PHPDoc - } + } */ // }}} - // {{{ PROPFIND() + // {{{ PROPFIND() /** * PROPFIND implementation * * PROPFIND implementation * - * @abstract + * @abstract * @param array &$params * @returns int HTTP-Statuscode */ - + /* abstract - function PROPFIND() + function PROPFIND() { // dummy entry for PHPDoc - } + } */ // }}} - // {{{ PROPPATCH() + // {{{ PROPPATCH() /** * PROPPATCH implementation * * PROPPATCH implementation * - * @abstract + * @abstract * @param array &$params * @returns int HTTP-Statuscode */ - + /* abstract - function PROPPATCH() + function PROPPATCH() { // dummy entry for PHPDoc - } + } */ // }}} - // {{{ LOCK() + // {{{ LOCK() /** * LOCK implementation * * LOCK implementation * - * @abstract + * @abstract * @param array &$params * @returns int HTTP-Statuscode */ - + /* abstract - function LOCK() + function LOCK() { // dummy entry for PHPDoc - } + } */ // }}} - // {{{ UNLOCK() + // {{{ UNLOCK() /** * UNLOCK implementation * * UNLOCK implementation * - * @abstract + * @abstract * @param array &$params * @returns int HTTP-Statuscode */ /* abstract - function UNLOCK() + function UNLOCK() { // dummy entry for PHPDoc - } + } */ // }}} // }}} - // {{{ other abstract methods + // {{{ other abstract methods - // {{{ check_auth() + // {{{ check_auth() /** * check authentication * * overload this method to retrieve and confirm authentication information * - * @abstract + * @abstract * @param string type Authentication type, e.g. "basic" or "digest" * @param string username Transmitted username * @param string passwort Transmitted password * @returns bool Authentication status */ - + /* abstract - function checkAuth($type, $username, $password) + function checkAuth($type, $username, $password) { // dummy entry for PHPDoc - } + } */ - + // }}} - // {{{ checklock() + // {{{ checklock() /** * check lock status for a resource * - * overload this method to return shared and exclusive locks + * overload this method to return shared and exclusive locks * active for this resource * - * @abstract + * @abstract * @param string resource Resource path to check * @returns array An array of lock entries each consisting * of 'type' ('shared'/'exclusive'), 'token' and 'timeout' */ - + /* abstract - function checklock($resource) + function checklock($resource) { // dummy entry for PHPDoc - } + } */ // }}} // }}} - // {{{ WebDAV HTTP method wrappers + // {{{ WebDAV HTTP method wrappers - // {{{ http_OPTIONS() + // {{{ http_OPTIONS() /** * OPTIONS method handler @@ -1278,9 +1278,9 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @return void */ - function http_OPTIONS() + function http_OPTIONS() { - // Microsoft clients default to the Frontpage protocol + // Microsoft clients default to the Frontpage protocol // unless we tell them to use WebDAV header("MS-Author-Via: DAV"); @@ -1290,7 +1290,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc // dav header $dav = array(1); // assume we are always dav class 1 compliant if (isset($allow['LOCK'])) { - $dav[] = 2; // dav class 2 requires that locking is supported + $dav[] = 2; // dav class 2 requires that locking is supported } // tell clients what we found @@ -1304,7 +1304,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc // }}} - // {{{ http_PROPFIND() + // {{{ http_PROPFIND() /** * PROPFIND method handler @@ -1312,19 +1312,19 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @return void */ - function http_PROPFIND() + function http_PROPFIND() { $options = Array(); $files = Array(); $options["path"] = $this->path; - + // search depth from header (default is "infinity) if (isset($this->_SERVER['HTTP_DEPTH'])) { $options["depth"] = $this->_SERVER["HTTP_DEPTH"]; } else { $options["depth"] = "infinity"; - } + } // analyze request payload $propinfo = $this->_parse_propfind("php://input"); @@ -1360,55 +1360,55 @@ class Horde_Rpc_Webdav extends Horde_Rpc return; } } - + $this->_xml = new Horde_Xml_Element(''); // Microsoft Clients need this special namespace for date and // time values // FIXME: Unless we use this XMLNS on an attribute H_X_E will not send // it with the output. - $this->_xml->registerNamespace('xmldata', "urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"); + $this->_xml->registerNamespace('xmldata', "urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"); $this->_xml->registerNamespace('caldav', self::CALDAVNS); - + // now we loop over all returned file entries foreach ($files["files"] as $filekey => $file) { - + // nothing to do if no properties were returend for a file if (!isset($file["props"]) || !is_array($file["props"])) { continue; } - + // now loop over all returned properties foreach ($file["props"] as $key => $prop) { // as a convenience feature we do not require that user handlers // restrict returned properties to the requested ones // here we strip all unrequested entries out of the response - + switch($options['props']) { case "all": // nothing to remove break; - + case "names": // only the names of all existing properties were requested // so we remove all values unset($files["files"][$filekey]["props"][$key]["val"]); break; - + default: $found = false; - - // search property name in requested properties + + // search property name in requested properties foreach ((array)$options["props"] as $reqprop) { if (!isset($reqprop["xmlns"])) { $reqprop["xmlns"] = ""; } - if ( $reqprop["name"] == $prop["name"] + if ( $reqprop["name"] == $prop["name"] && $reqprop["xmlns"] == $prop["ns"]) { $found = true; break; } } - + // unset property and continue with next one if not found/requested if (!$found) { $files["files"][$filekey]["props"][$key]=""; @@ -1416,27 +1416,27 @@ class Horde_Rpc_Webdav extends Horde_Rpc } break; } - - // namespace handling + + // namespace handling if (empty($prop["ns"])) continue; // no namespace - $ns = $prop["ns"]; + $ns = $prop["ns"]; if ($ns == "DAV:") continue; // default namespace if (isset($this->ns_hash[$ns])) continue; // already known - // register namespace + // register namespace $ns_name = "ns".(count($this->ns_hash)); $this->ns_hash[$ns] = $ns_name; $this->_xml->registerNamespace($ns_name, $ns); } - + // we also need to add empty entries for properties that were requested // but for which no values where returned by the user handler if (is_array($options['props'])) { foreach ($options["props"] as $reqprop) { if ($reqprop['name']=="") continue; // skip empty entries - + $found = false; - + if (!isset($reqprop["xmlns"])) { $reqprop["xmlns"] = ""; } @@ -1449,13 +1449,13 @@ class Horde_Rpc_Webdav extends Horde_Rpc break; } } - + if (!$found) { if ($reqprop["xmlns"]==="DAV:" && $reqprop["name"]==="lockdiscovery") { // lockdiscovery is handled by the base class - $files["files"][$filekey]["props"][] - = $this->mkprop("DAV:", - "lockdiscovery", + $files["files"][$filekey]["props"][] + = $this->mkprop("DAV:", + "lockdiscovery", $this->lockdiscovery($files["files"][$filekey]['path'])); } else { // add empty value for this property @@ -1473,21 +1473,21 @@ class Horde_Rpc_Webdav extends Horde_Rpc } } } - + // now we generate the reply header ... $this->http_status("207 Multi-Status"); header('Content-Type: text/xml; charset="utf-8"'); - + // ... and payload foreach ($files["files"] as $file) { // ignore empty or incomplete entries if (!is_array($file) || empty($file) || !isset($file["path"])) continue; - $path = $file['path']; + $path = $file['path']; if (!is_string($path) || $path==="") continue; $xmldata = array('D:response' => array()); #echo " \n"; - + /* TODO right now the user implementation has to make sure collections end in a slash, this should be done in here by checking the resource attribute */ @@ -1496,7 +1496,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc /* minimal urlencoding is needed for the resource path */ $xmldata['D:response']['D:href'] = $this->_urlencode($href); #echo " $href\n"; - + // report all found properties and their values (if any) if (isset($file["props"]) && is_array($file["props"])) { #echo " \n"; @@ -1505,10 +1505,10 @@ class Horde_Rpc_Webdav extends Horde_Rpc #echo " \n"; foreach ($file["props"] as $key => $prop) { - + if (!is_array($prop)) continue; if (!isset($prop["name"])) continue; - + if (!isset($prop["val"]) || $prop["val"] === "" || $prop["val"] === false) { // empty properties (cannot use empty() for check as "0" is a legal value here) if ($prop["ns"]=="DAV:") { @@ -1544,7 +1544,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc $propstats[$i]['D:prop']['D:supportedlock'] = $prop['val']; #echo " $prop[val]\n"; break; - case "lockdiscovery": + case "lockdiscovery": $propstats[$i]['D:prop']['D:lockdiscovery'] = $prop['val']; #echo " \n"; #echo $prop["val"]; @@ -1563,11 +1563,11 @@ class Horde_Rpc_Webdav extends Horde_Rpc # . is_string($prop['val']) ? $prop['val'] : ($prop['val'] ? 'true' : 'false') # . "\n"; break; - default: + default: $propstats[$i]['D:prop']['D:'. $prop['name']] = $prop['val']; #echo " " # . $this->_prop_encode(htmlspecialchars($prop['val'])) - # . "\n"; + # . "\n"; break; } } else { @@ -1584,7 +1584,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc } // Increment to the next propstat stanza. $i++; - + // now report all properties requested but not found if (isset($file["noprops"])) { #echo " \n"; @@ -1609,19 +1609,19 @@ class Horde_Rpc_Webdav extends Horde_Rpc #echo " HTTP/1.1 404 Not Found\n"; #echo " \n"; } - + $xmldata['D:response']['D:propstat'] = $propstats; #echo " \n"; } - + #echo "\n"; echo $this->_xml->saveXml(); } - + // }}} - - // {{{ http_PROPPATCH() + + // {{{ http_PROPPATCH() /** * PROPPATCH method handler @@ -1629,7 +1629,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @return void */ - function http_PROPPATCH() + function http_PROPPATCH() { if ($this->_check_lock_status($this->path)) { $options = Array(); @@ -1637,19 +1637,19 @@ class Horde_Rpc_Webdav extends Horde_Rpc $options["path"] = $this->path; $propinfo = $this->_parse_proppatch("php://input"); - + if (!$this->parseSuccess) { $this->http_status("400 Error"); return; } - + $options['props'] = $this->parseProps; - + $responsedescr = $this->PROPPATCH($options); - + $this->http_status("207 Multi-Status"); header('Content-Type: text/xml; charset="utf-8"'); - + echo "\n"; echo "\n"; @@ -1675,11 +1675,11 @@ class Horde_Rpc_Webdav extends Horde_Rpc $this->http_status("423 Locked"); } } - + // }}} - // {{{ http_MKCOL() + // {{{ http_MKCOL() /** * MKCOL method handler @@ -1687,7 +1687,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @return void */ - function http_MKCOL() + function http_MKCOL() { $options = Array(); @@ -1701,7 +1701,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc // }}} - // {{{ http_GET() + // {{{ http_GET() /** * GET method handler @@ -1709,7 +1709,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @returns void */ - function http_GET() + function http_GET() { // TODO check for invalid stream $options = Array(); @@ -1725,19 +1725,19 @@ class Horde_Rpc_Webdav extends Horde_Rpc $options['mimetype'] = "application/octet-stream"; } header("Content-type: $options[mimetype]"); - + if (isset($options['mtime'])) { header("Last-modified:".gmdate("D, d M Y H:i:s ", $options['mtime'])."GMT"); } - + if (isset($options['stream'])) { // GET handler returned a stream if (!empty($options['ranges']) && (0===fseek($options['stream'], 0, SEEK_SET))) { - // partial request and stream is seekable - + // partial request and stream is seekable + if (count($options['ranges']) === 1) { $range = $options['ranges'][0]; - + if (isset($range['start'])) { fseek($options['stream'], $range['start'], SEEK_SET); if (feof($options['stream'])) { @@ -1776,12 +1776,12 @@ class Horde_Rpc_Webdav extends Horde_Rpc // TODO what if size unknown? 500? if (isset($range['start'])) { $from = $range['start']; - $to = !empty($range['end']) ? $range['end'] : $options['size']-1; + $to = !empty($range['end']) ? $range['end'] : $options['size']-1; } else { $from = $options['size'] - $range['last']-1; $to = $options['size'] -1; } - $total = isset($options['size']) ? $options['size'] : "*"; + $total = isset($options['size']) ? $options['size'] : "*"; $size = $to - $from + 1; $this->_multipart_byterange_header($options['mimetype'], $from, $to, $total); @@ -1811,8 +1811,8 @@ class Horde_Rpc_Webdav extends Horde_Rpc echo $options['data']; } } - } - } + } + } if (!headers_sent()) { if (false === $status) { @@ -1831,7 +1831,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param array options array to store result in * @return void */ - function _get_ranges(&$options) + function _get_ranges(&$options) { // process Range: header if present if (isset($this->_SERVER['HTTP_RANGE'])) { @@ -1844,8 +1844,8 @@ class Horde_Rpc_Webdav extends Horde_Rpc foreach (explode(",", $matches[1]) as $range) { // ranges are either from-to pairs or just end positions list($start, $end) = explode("-", $range); - $options["ranges"][] = ($start==="") - ? array("last"=>$end) + $options["ranges"][] = ($start==="") + ? array("last"=>$end) : array("start"=>$start, "end"=>$end); } } @@ -1855,7 +1855,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc /** * generate separator headers for multipart response * - * first and last call happen without parameters to generate + * first and last call happen without parameters to generate * the initial header and closing sequence, all calls inbetween * require content mimetype, start and end byte position and * optionaly the total byte length of the requested resource @@ -1865,20 +1865,20 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param int end byte position * @param int total resource byte size */ - function _multipart_byterange_header($mimetype = false, $from = false, $to=false, $total=false) + function _multipart_byterange_header($mimetype = false, $from = false, $to=false, $total=false) { if ($mimetype === false) { if (!isset($this->multipart_separator)) { // initial // a little naive, this sequence *might* be part of the content - // but it's really not likely and rather expensive to check + // but it's really not likely and rather expensive to check $this->multipart_separator = "SEPARATOR_".md5(microtime()); // generate HTTP header header("Content-type: multipart/byteranges; boundary=".$this->multipart_separator); } else { - // final + // final // generate closing multipart sequence echo "\n--{$this->multipart_separator}--"; @@ -1892,11 +1892,11 @@ class Horde_Rpc_Webdav extends Horde_Rpc } } - + // }}} - // {{{ http_HEAD() + // {{{ http_HEAD() /** * HEAD method handler @@ -1904,12 +1904,12 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @return void */ - function http_HEAD() + function http_HEAD() { $status = false; $options = Array(); $options["path"] = $this->path; - + if (method_exists($this, "HEAD")) { $status = $this->head($options); } else if (method_exists($this, "GET")) { @@ -1920,29 +1920,29 @@ class Horde_Rpc_Webdav extends Horde_Rpc } ob_end_clean(); } - + if (!isset($options['mimetype'])) { $options['mimetype'] = "application/octet-stream"; } header("Content-type: $options[mimetype]"); - + if (isset($options['mtime'])) { header("Last-modified:".gmdate("D, d M Y H:i:s ", $options['mtime'])."GMT"); } - + if (isset($options['size'])) { header("Content-length: ".$options['size']); } if ($status === true) $status = "200 OK"; if ($status === false) $status = "404 Not found"; - + $this->http_status($status); } // }}} - // {{{ http_PUT() + // {{{ http_PUT() /** * PUT method handler @@ -1950,14 +1950,14 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @return void */ - function http_PUT() + function http_PUT() { if ($this->_check_lock_status($this->path)) { $options = Array(); $options["path"] = $this->path; $options["content_length"] = $this->_SERVER["CONTENT_LENGTH"]; - // get the Content-type + // get the Content-type if (isset($this->_SERVER["CONTENT_TYPE"])) { // for now we do not support any sort of multipart requests if (!strncmp($this->_SERVER["CONTENT_TYPE"], "multipart/", 10)) { @@ -1971,17 +1971,17 @@ class Horde_Rpc_Webdav extends Horde_Rpc $options["content_type"] = "application/octet-stream"; } - /* RFC 2616 2.6 says: "The recipient of the entity MUST NOT - ignore any Content-* (e.g. Content-Range) headers that it - does not understand or implement and MUST return a 501 + /* RFC 2616 2.6 says: "The recipient of the entity MUST NOT + ignore any Content-* (e.g. Content-Range) headers that it + does not understand or implement and MUST return a 501 (Not Implemented) response in such cases." - */ + */ foreach ($this->_SERVER as $key => $val) { if (strncmp($key, "HTTP_CONTENT", 11)) continue; switch ($key) { case 'HTTP_CONTENT_ENCODING': // RFC 2616 14.11 // TODO support this if ext/zlib filters are available - $this->http_status("501 not implemented"); + $this->http_status("501 not implemented"); echo "The service does not support '$val' content encoding"; return; @@ -1996,8 +1996,8 @@ class Horde_Rpc_Webdav extends Horde_Rpc break; case 'HTTP_CONTENT_LOCATION': // RFC 2616 14.14 - /* The meaning of the Content-Location header in PUT - or POST requests is undefined; servers are free + /* The meaning of the Content-Location header in PUT + or POST requests is undefined; servers are free to ignore it in those cases. */ break; @@ -2006,11 +2006,11 @@ class Horde_Rpc_Webdav extends Horde_Rpc // the header format is also specified in RFC 2616 14.16 // TODO we have to ensure that implementations support this or send 501 instead if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches)) { - $this->http_status("400 bad request"); + $this->http_status("400 bad request"); echo "The service does only support single byte ranges"; return; } - + $range = array("start"=>$matches[1], "end"=>$matches[2]); if (is_numeric($matches[3])) { $range["total_length"] = $matches[3]; @@ -2028,14 +2028,14 @@ class Horde_Rpc_Webdav extends Horde_Rpc case 'HTTP_CONTENT_MD5': // RFC 2616 14.15 // TODO: maybe we can just pretend here? - $this->http_status("501 not implemented"); - echo "The service does not support content MD5 checksum verification"; + $this->http_status("501 not implemented"); + echo "The service does not support content MD5 checksum verification"; return; - default: + default: // any other unknown Content-* headers - $this->http_status("501 not implemented"); - echo "The service does not support '$key'"; + $this->http_status("501 not implemented"); + echo "The service does not support '$key'"; return; } } @@ -2056,22 +2056,22 @@ class Horde_Rpc_Webdav extends Horde_Rpc if (0 == fseek($stream, $range[0]["start"], SEEK_SET)) { $length = $range[0]["end"]-$range[0]["start"]+1; if (!fwrite($stream, fread($options["stream"], $length))) { - $stat = "403 Forbidden"; + $stat = "403 Forbidden"; } } else { - $stat = "403 Forbidden"; + $stat = "403 Forbidden"; } } else { while (!feof($options["stream"])) { if (false === fwrite($stream, fread($options["stream"], 4096))) { - $stat = "403 Forbidden"; + $stat = "403 Forbidden"; break; } } } - fclose($stream); - } + fclose($stream); + } $this->http_status($stat); } else { @@ -2082,7 +2082,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc // }}} - // {{{ http_DELETE() + // {{{ http_DELETE() /** * DELETE method handler @@ -2090,7 +2090,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @return void */ - function http_DELETE() + function http_DELETE() { // check RFC 2518 Section 9.2, last paragraph if (isset($this->_SERVER["HTTP_DEPTH"])) { @@ -2117,7 +2117,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc // }}} - // {{{ http_COPY() + // {{{ http_COPY() /** * COPY method handler @@ -2125,16 +2125,16 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @return void */ - function http_COPY() + function http_COPY() { - // no need to check source lock status here + // no need to check source lock status here // destination lock status is always checked by the helper method $this->_copymove("copy"); } // }}} - // {{{ http_MOVE() + // {{{ http_MOVE() /** * MOVE method handler @@ -2142,7 +2142,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @return void */ - function http_MOVE() + function http_MOVE() { if ($this->_check_lock_status($this->path)) { // destination lock status is always checked by the helper method @@ -2155,7 +2155,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc // }}} - // {{{ http_LOCK() + // {{{ http_LOCK() /** * LOCK method handler @@ -2163,21 +2163,21 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @return void */ - function http_LOCK() + function http_LOCK() { $options = Array(); $options["path"] = $this->path; - + if (isset($this->_SERVER['HTTP_DEPTH'])) { $options["depth"] = $this->_SERVER["HTTP_DEPTH"]; } else { $options["depth"] = "infinity"; } - + if (isset($this->_SERVER["HTTP_TIMEOUT"])) { $options["timeout"] = explode(",", $this->_SERVER["HTTP_TIMEOUT"]); } - + if (empty($this->_SERVER['CONTENT_LENGTH']) && !empty($this->_SERVER['HTTP_IF'])) { // check if locking is possible if (!$this->_check_lock_status($this->path)) { @@ -2200,7 +2200,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc // extract lock request information from request XML payload $lockinfo = $this->_parse_lockinfo("php://input"); if (!$lockinfo->parseSuccess) { - $this->http_status("400 bad request"); + $this->http_status("400 bad request"); } // check if locking is possible @@ -2209,23 +2209,23 @@ class Horde_Rpc_Webdav extends Horde_Rpc return; } - // new lock + // new lock $options["scope"] = $this->lockscope; $options["type"] = $this->locktype; - $options["owner"] = $this->owner; + $options["owner"] = $this->owner; $options["locktoken"] = $this->_new_locktoken(); - - $stat = $this->LOCK($options); + + $stat = $this->LOCK($options); } - + if (is_bool($stat)) { $http_stat = $stat ? "200 OK" : "423 Locked"; } else { $http_stat = (string)$stat; } $this->http_status($http_stat); - - if ($http_stat{0} == 2) { // 2xx states are ok + + if ($http_stat{0} == 2) { // 2xx states are ok if ($options["timeout"]) { // if multiple timeout values were given we take the first only if (is_array($options["timeout"])) { @@ -2250,7 +2250,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc } else { $timeout = "Infinite"; } - + header('Content-Type: text/xml; charset="utf-8"'); header("Lock-Token: <$options[locktoken]>"); echo "\n"; @@ -2268,11 +2268,11 @@ class Horde_Rpc_Webdav extends Horde_Rpc echo "\n\n"; } } - + // }}} - // {{{ http_UNLOCK() + // {{{ http_UNLOCK() /** * UNLOCK method handler @@ -2280,7 +2280,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @return void */ - function http_UNLOCK() + function http_UNLOCK() { $options = Array(); $options["path"] = $this->path; @@ -2292,7 +2292,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc } // strip surrounding <> - $options["token"] = substr(trim($this->_SERVER["HTTP_LOCK_TOKEN"]), 1, -1); + $options["token"] = substr(trim($this->_SERVER["HTTP_LOCK_TOKEN"]), 1, -1); // call user method $stat = $this->UNLOCK($options); @@ -2304,9 +2304,9 @@ class Horde_Rpc_Webdav extends Horde_Rpc // }}} - // {{{ _copymove() + // {{{ _copymove() - function _copymove($what) + function _copymove($what) { $options = Array(); $options["path"] = $this->path; @@ -2358,7 +2358,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc // }}} - // {{{ _allow() + // {{{ _allow() /** * check for implemented HTTP methods @@ -2366,7 +2366,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @return array something */ - function _allow() + function _allow() { // OPTIONS is always there $allow = array("OPTIONS" =>"OPTIONS"); @@ -2406,7 +2406,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param string property value * @return array property array */ - function mkprop() + function mkprop() { $args = func_get_args(); if (count($args) == 3) { @@ -2416,26 +2416,26 @@ class Horde_Rpc_Webdav extends Horde_Rpc } } - // {{{ _check_auth + // {{{ _check_auth /** * check authentication if check is implemented - * + * * @param void * @return bool true if authentication succeded or not necessary */ - function _check_auth() + function _check_auth() { - $auth_type = isset($this->_SERVER["AUTH_TYPE"]) - ? $this->_SERVER["AUTH_TYPE"] + $auth_type = isset($this->_SERVER["AUTH_TYPE"]) + ? $this->_SERVER["AUTH_TYPE"] : null; - $auth_user = isset($this->_SERVER["PHP_AUTH_USER"]) - ? $this->_SERVER["PHP_AUTH_USER"] + $auth_user = isset($this->_SERVER["PHP_AUTH_USER"]) + ? $this->_SERVER["PHP_AUTH_USER"] : null; - $auth_pw = isset($this->_SERVER["PHP_AUTH_PW"]) - ? $this->_SERVER["PHP_AUTH_PW"] + $auth_pw = isset($this->_SERVER["PHP_AUTH_PW"]) + ? $this->_SERVER["PHP_AUTH_PW"] : null; if (method_exists($this, "checkAuth")) { @@ -2452,31 +2452,31 @@ class Horde_Rpc_Webdav extends Horde_Rpc // }}} - // {{{ UUID stuff - + // {{{ UUID stuff + /** * create a new opaque lock token as defined in RFC2518 * * @param void * @return string new RFC2518 opaque lock token */ - function _new_locktoken() + function _new_locktoken() { return "opaquelocktoken:" . ((string)new Horde_Support_Uuid()); } // }}} - // {{{ WebDAV If: header parsing + // {{{ WebDAV If: header parsing /** - * + * * * @param string header string to parse * @param int current parsing position * @return array next token (type and value) */ - function _if_header_lexer($string, &$pos) + function _if_header_lexer($string, &$pos) { // skip whitespace while (ctype_space($string{$pos})) { @@ -2524,13 +2524,13 @@ class Horde_Rpc_Webdav extends Horde_Rpc } } - /** + /** * parse If: header * * @param string header string * @return array URIs and their conditions */ - function _if_header_parser($str) + function _if_header_parser($str) { $pos = 0; $len = strlen($str); @@ -2606,7 +2606,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc } /** - * check if conditions from "If:" headers are meat + * check if conditions from "If:" headers are meat * * the "If:" header is an extension to HTTP/1.1 * defined in RFC 2518 section 9.4 @@ -2614,7 +2614,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param void * @return void */ - function _check_if_header_conditions() + function _check_if_header_conditions() { if (isset($this->_SERVER["HTTP_IF"])) { $this->_if_header_uris = @@ -2658,14 +2658,14 @@ class Horde_Rpc_Webdav extends Horde_Rpc * * Check a single URI condition parsed from an if-header * - * @abstract + * @abstract * @param string $uri URI to check * @param string $condition Condition to check for this URI * @returns bool Condition check result */ - function _check_uri_condition($uri, $condition) + function _check_uri_condition($uri, $condition) { - // not really implemented here, + // not really implemented here, // implementations must override // a lock token can never be from the DAV: scheme @@ -2679,12 +2679,12 @@ class Horde_Rpc_Webdav extends Horde_Rpc /** - * + * * * @param string path of resource to check * @param bool exclusive lock? */ - function _check_lock_status($path, $exclusive_only = false) + function _check_lock_status($path, $exclusive_only = false) { // FIXME depth -> ignored for now if (method_exists($this, "checkLock")) { @@ -2713,7 +2713,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param string resource path to check * @return string lockdiscovery response */ - function lockdiscovery($path) + function lockdiscovery($path) { // no lock support without checklock() method if (!method_exists($this, "checklock")) { @@ -2760,7 +2760,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param string status code and message * @return void */ - function http_status($status) + function http_status($status) { // simplified success case if ($status === true) { @@ -2784,7 +2784,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param string URL to encode * @return string encoded URL */ - function _urlencode($url) + function _urlencode($url) { return strtr($url, array(" "=>"%20", "%"=>"%25", @@ -2802,7 +2802,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param string URL to decode * @return string decoded URL */ - function _urldecode($path) + function _urldecode($path) { return rawurldecode($path); } @@ -2813,7 +2813,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param string text to encode * @return string utf-8 encoded text */ - function _prop_encode($text) + function _prop_encode($text) { switch (strtolower($this->_prop_encoding)) { case "utf-8": @@ -2832,7 +2832,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param string directory path * @returns string directory path wiht trailing slash */ - function _slashify($path) + function _slashify($path) { if ($path[strlen($path)-1] != '/') { $path = $path."/"; @@ -2846,7 +2846,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param string directory path * @returns string directory path wihtout trailing slash */ - function _unslashify($path) + function _unslashify($path) { if ($path[strlen($path)-1] == '/') { $path = substr($path, 0, strlen($path) -1); @@ -2861,7 +2861,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc * @param string child path * @return string merged path */ - function _mergePaths($parent, $child) + function _mergePaths($parent, $child) { if ($child{0} == '/') { return $this->_unslashify($parent).$child; @@ -2875,7 +2875,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); $res = array(); - // properties from namespaces != "DAV:" or without any namespace + // properties from namespaces != "DAV:" or without any namespace if ($prop["ns"]) { $key = $this->ns_hash[$prop['ns']] . ':' . $prop['name']; #$res .= "<" . $this->ns_hash[$prop["ns"]] . ":$prop[name]>"; @@ -2900,7 +2900,7 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); return $res; } - + /** * mbstring.func_overload save strlen version: counting the bytes not the chars * @@ -2910,7 +2910,7 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); function bytes($str) { static $func_overload; - + if (is_null($func_overload)) { $func_overload = @extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; @@ -2919,11 +2919,11 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); } - function _parse_propfind($path) + function _parse_propfind($path) { // success state flag $this->parseSuccess = true; - + // property storage array $this->parseProps = array(); @@ -2949,7 +2949,7 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); array(&$this, "_endPropinfoElement")); // we want a case sensitive parser - xml_parser_set_option($xml_parser, + xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); @@ -2960,8 +2960,8 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); $had_input = true; $this->parseSuccess &= xml_parse($xml_parser, $line, false); } - } - + } + // finish parsing if ($had_input) { $this->parseSuccess &= xml_parse($xml_parser, "", true); @@ -2969,24 +2969,24 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); // free parser xml_parser_free($xml_parser); - + // close input stream fclose($f_in); // if no input was parsed it was a request if(!count($this->parseProps)) $this->parseProps = "all"; // default } - + /** * start tag handler - * + * * @access private * @param resource parser * @param string tag name * @param array tag attributes */ - function _startPropinfoElement($parser, $name, $attrs) + function _startPropinfoElement($parser, $name, $attrs) { // name space handling if (strstr($name, " ")) { @@ -3018,29 +3018,29 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); // increment depth count $this->parseDepth++; } - + /** * end tag handler - * + * * @access private * @param resource parser * @param string tag name */ - function _endPropinfoElement($parser, $name) + function _endPropinfoElement($parser, $name) { // here we only need to decrement the depth count $this->parseDepth--; } - function _parse_lockinfo($path) + function _parse_lockinfo($path) { // we assume success unless problems occur $this->parseSuccess = true; // remember if any input was parsed $had_input = false; - + // open stream $f_in = fopen($path, "r"); if (!$f_in) { @@ -3069,7 +3069,7 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); $had_input = true; $this->parseSuccess &= xml_parse($xml_parser, $line, false); } - } + } // finish parsing if ($had_input) { @@ -3084,9 +3084,9 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); xml_parser_free($xml_parser); // close input stream - fclose($f_in); + fclose($f_in); } - + /** * tag start handler @@ -3097,7 +3097,7 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); * @return void * @access private */ - function _startLockElement($parser, $name, $attrs) + function _startLockElement($parser, $name, $attrs) { // namespace handling if (strstr($name, " ")) { @@ -3106,8 +3106,8 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); $ns = ""; $tag = $name; } - - + + if ($this->collect_owner) { // everything within the tag needs to be collected $ns_short = ""; @@ -3136,7 +3136,7 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); } } } - + /** * data handler * @@ -3145,7 +3145,7 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); * @return void * @access private */ - function _lockData($parser, $data) + function _lockData($parser, $data) { // only the tag has data content if ($this->collect_owner) { @@ -3161,7 +3161,7 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); * @return void * @access private */ - function _endLockElement($parser, $name) + function _endLockElement($parser, $name) { // namespace handling if (strstr($name, " ")) { @@ -3191,7 +3191,7 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); } } - function _parse_proppatch($path) + function _parse_proppatch($path) { $this->parseSuccess = true; @@ -3223,8 +3223,8 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); $had_input = true; $this->parseSuccess &= xml_parse($xml_parser, $line, false); } - } - + } + if($had_input) { $this->parseSuccess &= xml_parse($xml_parser, "", true); } @@ -3243,7 +3243,7 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); * @return void * @access private */ - function _startProppatchElement($parser, $name, $attrs) + function _startProppatchElement($parser, $name, $attrs) { if (strstr($name, " ")) { list($ns, $tag) = explode(" ", $name); @@ -3256,7 +3256,7 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); if ($this->parseDepth == 1) { $this->mode = $tag; - } + } if ($this->parseDepth == 3) { $prop = array("name" => $tag); @@ -3276,7 +3276,7 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); $this->current["val"] .= ">"; } - + $this->parseDepth++; } @@ -3289,7 +3289,7 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); * @return void * @access private */ - function _endProppatchElement($parser, $name) + function _endProppatchElement($parser, $name) { if (strstr($name, " ")) { list($ns, $tag) = explode(" ", $name); @@ -3322,11 +3322,11 @@ Horde::logMessage(print_r($prop, true), __FILE__, __LINE__, PEAR_LOG_ERR); * @return void * @access private */ - function _proppatchData($parser, $data) + function _proppatchData($parser, $data) { if (isset($this->current)) { $this->current["val"] .= $data; } } -} +}