Subject: FW: [Moderator Action] Webdav and php

From: "Jim Whitehead" <[email-masked]>
Date: Tue, 20 Nov 2001 09:33:30 -0800

Accidentally caught by the spam filter. I'm also cc'ing the dav-dev mailing
list.

- Jim
-----Original Message-----
From: Michael Lam [mailto:[email-masked]]
Sent: Monday, November 19, 2001 8:22 PM
To: [email-masked]
Subject: [Moderator Action] Webdav and php

Hi,

I am not sure if this is the right place for me to ask the following
question, but I've decided to give it a try.

Currently I am trying to use php for the webdav properties. I have set up
apache in my local computer and php. The MKCOL and DELETE properties works
fine. But I am having problem getting the PROPPATCH and PROFIND property to
work in php. I have obtained a VB script and all the properties works fine
with the VB script (thus, it create a new resource, set properties, remove
properties, find the properties and delete resources).

The following is the code I have written in php...

-----------------------------------------

$socket = fsockopen ("127.0.0.1", 80);

if ($socket < 0) {
    echo "socket() failed: reason: " . "\n";
} else {
    "socket() successful: " . "\n";
}

   /* PROPATCH - */
   /* set or remove properties defined */
 $r = htmlentities("<?xml version=1.0 encoding=utf-8 ?>");
 $r .= htmlentities("<D:propertyupdate xmlns:D='DAV:'
xmlns:Z='http://www.tedis.com.au/'");
 $r .= htmlentities("<D:set>");
 $r .= htmlentities("<D:prop>");
 $r .= htmlentities("<Z:Order>");
 $r .= htmlentities("<Z:Type>ORDER</Z:Type>");
 $r .= htmlentities("<Z:Status>OK</Z:Status>");
 $r .= htmlentities("</Z:Order>");
 $r .= htmlentities("</D:prop>");
 $r .= htmlentities("</D:set>");
 $r .= htmlentities("</D:propertyupdate>");
 $in = "PROPPATCH /webdisc/xyz.txt / HTTP/1.1\r\n";
 $in .= "Host: localhost\r\n";
 $in .= "Content-Type: text/plain\r\n";
 $in .= "Content-Length: ". strlen($r) ."\r\n";
 $in .= $r."\r\n";

   /* PROPFIND */
  /*$r = htmlentities("<?xml version=1.0 encoding=utf-8 ?>");
  $r .= htmlentities("<D:propfind xmlns:D='DAV:'>");
  $r .= htmlentities("<D:allprop/>");
  $r .= htmlentities("</D:propfind>");
  $in = "PROPFIND /webdisc/xyz.txt / HTTP/1.1\r\n";
  $in .= "Host: localhost\r\n";
  $in .= "Content-Type: text/plain\r\n";
  $in .= "Content-Length: \r\n";
  $in .= $r."\r\n";*/

$out = '';

fputs($socket, $in."\r\n");

while (!feof($socket)) {
 $out .= fread($socket, 4096);
}

fclose ($socket);

------------------------------------------

when I send the request with PROPPATCH property in php, it does not return
me anything.

When I use the VB script to set the property for a resource and then try to
use php to send a PROPFIND, it return me the followings but without the xml
containing the result I requested.

TCP/IP Connection
Attempting to connect to '127.0.0.1' on port 80...

Request = PROPFIND /webdisc/xyz.txt / HTTP/1.1 Host: localhost Content-Type:
text/plain Content-Length: <?xml version=1.0 encoding=utf-8 ?><D:propfind
xmlns:D='DAV:'><D:prop><T:Type/><T:Reference/><T:Status/></D:prop></D:propfi
nd> Sending HTTP HEAD request...
OK.

Reading response:
HTTP/1.1 207 Multi-Status Date: Tue, 20 Nov 2001 03:38:40 GMT Server:
Apache/1.3.22 (Win32) DAV/1.0.3-dev Connection: close Content-Type:
text/xml; charset="utf-8" /webdisc/xyz.txt Order 1234 New
2001-11-15T06:25:51Z 5599 Tue, 20 Nov 2001 02:58:02 GMT "0-15df-3bf9c6ba"
text/plain HTTP/1.1 200 OK Closing socket...OK.

thank you for your help.

Michael