mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-90 Imported PEAR's HTTP_WebDAV_Server from HEAD @ 28-01-2008
This is a very strict import - did not include any of the sample files (which are quite dangerous!). See the README_MOODLE.txt for details.
This commit is contained in:
parent
c01a1ce0f2
commit
22fc3bc537
3
lib/pear/HTTP/WebDAV/AUTHORS
Normal file
3
lib/pear/HTTP/WebDAV/AUTHORS
Normal file
@ -0,0 +1,3 @@
|
||||
Authors: Hartmut Holzgraefe <hholzgra@php.net>
|
||||
Christian Stocker <chregu@bitflux.ch>
|
||||
|
29
lib/pear/HTTP/WebDAV/COPYING
Normal file
29
lib/pear/HTTP/WebDAV/COPYING
Normal file
@ -0,0 +1,29 @@
|
||||
Copyright (c) 2002-2007 Christian Stocker, Hartmut Holzgraefe
|
||||
All rights reserved
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
22
lib/pear/HTTP/WebDAV/LICENSE
Normal file
22
lib/pear/HTTP/WebDAV/LICENSE
Normal file
@ -0,0 +1,22 @@
|
||||
Redistribution and use in source and binary forms, with or without modification
|
||||
, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, th
|
||||
is list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/
|
||||
or other materials provided with the distribution.
|
||||
|
||||
3. The name of the author may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WA
|
||||
RRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABIL
|
||||
ITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR C
|
||||
ONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOW
|
||||
EVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILI
|
||||
TY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE U
|
||||
SE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
18
lib/pear/HTTP/WebDAV/README_MOODLE.txt
Normal file
18
lib/pear/HTTP/WebDAV/README_MOODLE.txt
Normal file
@ -0,0 +1,18 @@
|
||||
This is a limited import of PEAR's HTTP_WebDAV_Server library.
|
||||
|
||||
Important notes:
|
||||
|
||||
- It does _not_ include all the files, as the tests and example
|
||||
files are a serious security risk. It includes the minimal files
|
||||
needed - updates need to be extremely careful to avoid including
|
||||
file.php, FileSystem dir and Server dir. Also removed documentation,
|
||||
while AUTHORS and COPYING remain.
|
||||
|
||||
- The code corresponds to the HEAD branch on Jan 28th 2008, you can
|
||||
get a checkout matching these files by passing the date to the
|
||||
checkout or update command.
|
||||
|
||||
- The license is new BSD license.
|
||||
|
||||
|
||||
~ martin langhoff <martin@catalyst.net.nz> 28-01-2008
|
2126
lib/pear/HTTP/WebDAV/Server.php
Executable file
2126
lib/pear/HTTP/WebDAV/Server.php
Executable file
File diff suppressed because it is too large
Load Diff
251
lib/pear/HTTP/WebDAV/Tools/_parse_lockinfo.php
Normal file
251
lib/pear/HTTP/WebDAV/Tools/_parse_lockinfo.php
Normal file
@ -0,0 +1,251 @@
|
||||
<?php // $Id$
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2002-2007 Christian Stocker, Hartmut Holzgraefe |
|
||||
| All rights reserved |
|
||||
| |
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions |
|
||||
| are met: |
|
||||
| |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in |
|
||||
| the documentation and/or other materials provided with the |
|
||||
| distribution. |
|
||||
| 3. The names of the authors may not be used to endorse or promote |
|
||||
| products derived from this software without specific prior |
|
||||
| written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
| FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
| COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
| INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
| BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
||||
| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
||||
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
| LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
||||
| ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
| POSSIBILITY OF SUCH DAMAGE. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* helper class for parsing LOCK request bodies
|
||||
*
|
||||
* @package HTTP_WebDAV_Server
|
||||
* @author Hartmut Holzgraefe <hholzgra@php.net>
|
||||
* @version @package-version@
|
||||
*/
|
||||
class _parse_lockinfo
|
||||
{
|
||||
/**
|
||||
* success state flag
|
||||
*
|
||||
* @var bool
|
||||
* @access public
|
||||
*/
|
||||
var $success = false;
|
||||
|
||||
/**
|
||||
* lock type, currently only "write"
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $locktype = "";
|
||||
|
||||
/**
|
||||
* lock scope, "shared" or "exclusive"
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $lockscope = "";
|
||||
|
||||
/**
|
||||
* lock owner information
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $owner = "";
|
||||
|
||||
/**
|
||||
* flag that is set during lock owner read
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $collect_owner = false;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param string path of stream to read
|
||||
* @access public
|
||||
*/
|
||||
function _parse_lockinfo($path)
|
||||
{
|
||||
// we assume success unless problems occur
|
||||
$this->success = true;
|
||||
|
||||
// remember if any input was parsed
|
||||
$had_input = false;
|
||||
|
||||
// open stream
|
||||
$f_in = fopen($path, "r");
|
||||
if (!$f_in) {
|
||||
$this->success = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// create namespace aware parser
|
||||
$xml_parser = xml_parser_create_ns("UTF-8", " ");
|
||||
|
||||
// set tag and data handlers
|
||||
xml_set_element_handler($xml_parser,
|
||||
array(&$this, "_startElement"),
|
||||
array(&$this, "_endElement"));
|
||||
xml_set_character_data_handler($xml_parser,
|
||||
array(&$this, "_data"));
|
||||
|
||||
// we want a case sensitive parser
|
||||
xml_parser_set_option($xml_parser,
|
||||
XML_OPTION_CASE_FOLDING, false);
|
||||
|
||||
// parse input
|
||||
while ($this->success && !feof($f_in)) {
|
||||
$line = fgets($f_in);
|
||||
if (is_string($line)) {
|
||||
$had_input = true;
|
||||
$this->success &= xml_parse($xml_parser, $line, false);
|
||||
}
|
||||
}
|
||||
|
||||
// finish parsing
|
||||
if ($had_input) {
|
||||
$this->success &= xml_parse($xml_parser, "", true);
|
||||
}
|
||||
|
||||
// check if required tags where found
|
||||
$this->success &= !empty($this->locktype);
|
||||
$this->success &= !empty($this->lockscope);
|
||||
|
||||
// free parser resource
|
||||
xml_parser_free($xml_parser);
|
||||
|
||||
// close input stream
|
||||
fclose($f_in);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* tag start handler
|
||||
*
|
||||
* @param resource parser
|
||||
* @param string tag name
|
||||
* @param array tag attributes
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function _startElement($parser, $name, $attrs)
|
||||
{
|
||||
// namespace handling
|
||||
if (strstr($name, " ")) {
|
||||
list($ns, $tag) = explode(" ", $name);
|
||||
} else {
|
||||
$ns = "";
|
||||
$tag = $name;
|
||||
}
|
||||
|
||||
|
||||
if ($this->collect_owner) {
|
||||
// everything within the <owner> tag needs to be collected
|
||||
$ns_short = "";
|
||||
$ns_attr = "";
|
||||
if ($ns) {
|
||||
if ($ns == "DAV:") {
|
||||
$ns_short = "D:";
|
||||
} else {
|
||||
$ns_attr = " xmlns='$ns'";
|
||||
}
|
||||
}
|
||||
$this->owner .= "<$ns_short$tag$ns_attr>";
|
||||
} else if ($ns == "DAV:") {
|
||||
// parse only the essential tags
|
||||
switch ($tag) {
|
||||
case "write":
|
||||
$this->locktype = $tag;
|
||||
break;
|
||||
case "exclusive":
|
||||
case "shared":
|
||||
$this->lockscope = $tag;
|
||||
break;
|
||||
case "owner":
|
||||
$this->collect_owner = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* data handler
|
||||
*
|
||||
* @param resource parser
|
||||
* @param string data
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function _data($parser, $data)
|
||||
{
|
||||
// only the <owner> tag has data content
|
||||
if ($this->collect_owner) {
|
||||
$this->owner .= $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tag end handler
|
||||
*
|
||||
* @param resource parser
|
||||
* @param string tag name
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function _endElement($parser, $name)
|
||||
{
|
||||
// namespace handling
|
||||
if (strstr($name, " ")) {
|
||||
list($ns, $tag) = explode(" ", $name);
|
||||
} else {
|
||||
$ns = "";
|
||||
$tag = $name;
|
||||
}
|
||||
|
||||
// <owner> finished?
|
||||
if (($ns == "DAV:") && ($tag == "owner")) {
|
||||
$this->collect_owner = false;
|
||||
}
|
||||
|
||||
// within <owner> we have to collect everything
|
||||
if ($this->collect_owner) {
|
||||
$ns_short = "";
|
||||
$ns_attr = "";
|
||||
if ($ns) {
|
||||
if ($ns == "DAV:") {
|
||||
$ns_short = "D:";
|
||||
} else {
|
||||
$ns_attr = " xmlns='$ns'";
|
||||
}
|
||||
}
|
||||
$this->owner .= "</$ns_short$tag$ns_attr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
191
lib/pear/HTTP/WebDAV/Tools/_parse_propfind.php
Normal file
191
lib/pear/HTTP/WebDAV/Tools/_parse_propfind.php
Normal file
@ -0,0 +1,191 @@
|
||||
<?php // $Id$
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2002-2007 Christian Stocker, Hartmut Holzgraefe |
|
||||
| All rights reserved |
|
||||
| |
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions |
|
||||
| are met: |
|
||||
| |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in |
|
||||
| the documentation and/or other materials provided with the |
|
||||
| distribution. |
|
||||
| 3. The names of the authors may not be used to endorse or promote |
|
||||
| products derived from this software without specific prior |
|
||||
| written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
| FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
| COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
| INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
| BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
||||
| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
||||
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
| LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
||||
| ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
| POSSIBILITY OF SUCH DAMAGE. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* helper class for parsing PROPFIND request bodies
|
||||
*
|
||||
* @package HTTP_WebDAV_Server
|
||||
* @author Hartmut Holzgraefe <hholzgra@php.net>
|
||||
* @version @package-version@
|
||||
*/
|
||||
class _parse_propfind
|
||||
{
|
||||
/**
|
||||
* success state flag
|
||||
*
|
||||
* @var bool
|
||||
* @access public
|
||||
*/
|
||||
var $success = false;
|
||||
|
||||
/**
|
||||
* found properties are collected here
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $props = false;
|
||||
|
||||
/**
|
||||
* internal tag nesting depth counter
|
||||
*
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
var $depth = 0;
|
||||
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function _parse_propfind($path)
|
||||
{
|
||||
// success state flag
|
||||
$this->success = true;
|
||||
|
||||
// property storage array
|
||||
$this->props = array();
|
||||
|
||||
// internal tag depth counter
|
||||
$this->depth = 0;
|
||||
|
||||
// remember if any input was parsed
|
||||
$had_input = false;
|
||||
|
||||
// open input stream
|
||||
$f_in = fopen($path, "r");
|
||||
if (!$f_in) {
|
||||
$this->success = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// create XML parser
|
||||
$xml_parser = xml_parser_create_ns("UTF-8", " ");
|
||||
|
||||
// set tag and data handlers
|
||||
xml_set_element_handler($xml_parser,
|
||||
array(&$this, "_startElement"),
|
||||
array(&$this, "_endElement"));
|
||||
|
||||
// we want a case sensitive parser
|
||||
xml_parser_set_option($xml_parser,
|
||||
XML_OPTION_CASE_FOLDING, false);
|
||||
|
||||
|
||||
// parse input
|
||||
while ($this->success && !feof($f_in)) {
|
||||
$line = fgets($f_in);
|
||||
if (is_string($line)) {
|
||||
$had_input = true;
|
||||
$this->success &= xml_parse($xml_parser, $line, false);
|
||||
}
|
||||
}
|
||||
|
||||
// finish parsing
|
||||
if ($had_input) {
|
||||
$this->success &= xml_parse($xml_parser, "", true);
|
||||
}
|
||||
|
||||
// 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->props)) $this->props = "all"; // default
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* start tag handler
|
||||
*
|
||||
* @access private
|
||||
* @param resource parser
|
||||
* @param string tag name
|
||||
* @param array tag attributes
|
||||
*/
|
||||
function _startElement($parser, $name, $attrs)
|
||||
{
|
||||
// name space handling
|
||||
if (strstr($name, " ")) {
|
||||
list($ns, $tag) = explode(" ", $name);
|
||||
if ($ns == "")
|
||||
$this->success = false;
|
||||
} else {
|
||||
$ns = "";
|
||||
$tag = $name;
|
||||
}
|
||||
|
||||
// special tags at level 1: <allprop> and <propname>
|
||||
if ($this->depth == 1) {
|
||||
if ($tag == "allprop")
|
||||
$this->props = "all";
|
||||
|
||||
if ($tag == "propname")
|
||||
$this->props = "names";
|
||||
}
|
||||
|
||||
// requested properties are found at level 2
|
||||
if ($this->depth == 2) {
|
||||
$prop = array("name" => $tag);
|
||||
if ($ns)
|
||||
$prop["xmlns"] = $ns;
|
||||
$this->props[] = $prop;
|
||||
}
|
||||
|
||||
// increment depth count
|
||||
$this->depth++;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* end tag handler
|
||||
*
|
||||
* @access private
|
||||
* @param resource parser
|
||||
* @param string tag name
|
||||
*/
|
||||
function _endElement($parser, $name)
|
||||
{
|
||||
// here we only need to decrement the depth count
|
||||
$this->depth--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
237
lib/pear/HTTP/WebDAV/Tools/_parse_proppatch.php
Normal file
237
lib/pear/HTTP/WebDAV/Tools/_parse_proppatch.php
Normal file
@ -0,0 +1,237 @@
|
||||
<?php // $Id$
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2002-2007 Christian Stocker, Hartmut Holzgraefe |
|
||||
| All rights reserved |
|
||||
| |
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions |
|
||||
| are met: |
|
||||
| |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in |
|
||||
| the documentation and/or other materials provided with the |
|
||||
| distribution. |
|
||||
| 3. The names of the authors may not be used to endorse or promote |
|
||||
| products derived from this software without specific prior |
|
||||
| written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
| FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
| COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
| INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
| BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
||||
| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
||||
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
| LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
||||
| ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
| POSSIBILITY OF SUCH DAMAGE. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* helper class for parsing PROPPATCH request bodies
|
||||
*
|
||||
* @package HTTP_WebDAV_Server
|
||||
* @author Hartmut Holzgraefe <hholzgra@php.net>
|
||||
* @version @package-version@
|
||||
*/
|
||||
class _parse_proppatch
|
||||
{
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var
|
||||
* @access
|
||||
*/
|
||||
var $success;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var
|
||||
* @access
|
||||
*/
|
||||
var $props;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var
|
||||
* @access
|
||||
*/
|
||||
var $depth;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var
|
||||
* @access
|
||||
*/
|
||||
var $mode;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var
|
||||
* @access
|
||||
*/
|
||||
var $current;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param string path of input stream
|
||||
* @access public
|
||||
*/
|
||||
function _parse_proppatch($path)
|
||||
{
|
||||
$this->success = true;
|
||||
|
||||
$this->depth = 0;
|
||||
$this->props = array();
|
||||
$had_input = false;
|
||||
|
||||
$f_in = fopen($path, "r");
|
||||
if (!$f_in) {
|
||||
$this->success = false;
|
||||
return;
|
||||
}
|
||||
|
||||
$xml_parser = xml_parser_create_ns("UTF-8", " ");
|
||||
|
||||
xml_set_element_handler($xml_parser,
|
||||
array(&$this, "_startElement"),
|
||||
array(&$this, "_endElement"));
|
||||
|
||||
xml_set_character_data_handler($xml_parser,
|
||||
array(&$this, "_data"));
|
||||
|
||||
xml_parser_set_option($xml_parser,
|
||||
XML_OPTION_CASE_FOLDING, false);
|
||||
|
||||
while($this->success && !feof($f_in)) {
|
||||
$line = fgets($f_in);
|
||||
if (is_string($line)) {
|
||||
$had_input = true;
|
||||
$this->success &= xml_parse($xml_parser, $line, false);
|
||||
}
|
||||
}
|
||||
|
||||
if($had_input) {
|
||||
$this->success &= xml_parse($xml_parser, "", true);
|
||||
}
|
||||
|
||||
xml_parser_free($xml_parser);
|
||||
|
||||
fclose($f_in);
|
||||
}
|
||||
|
||||
/**
|
||||
* tag start handler
|
||||
*
|
||||
* @param resource parser
|
||||
* @param string tag name
|
||||
* @param array tag attributes
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function _startElement($parser, $name, $attrs)
|
||||
{
|
||||
if (strstr($name, " ")) {
|
||||
list($ns, $tag) = explode(" ", $name);
|
||||
if ($ns == "")
|
||||
$this->success = false;
|
||||
} else {
|
||||
$ns = "";
|
||||
$tag = $name;
|
||||
}
|
||||
|
||||
if ($this->depth == 1) {
|
||||
$this->mode = $tag;
|
||||
}
|
||||
|
||||
if ($this->depth == 3) {
|
||||
$prop = array("name" => $tag);
|
||||
$this->current = array("name" => $tag, "ns" => $ns, "status"=> 200);
|
||||
if ($this->mode == "set") {
|
||||
$this->current["val"] = ""; // default set val
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->depth >= 4) {
|
||||
$this->current["val"] .= "<$tag";
|
||||
if (isset($attr)) {
|
||||
foreach ($attr as $key => $val) {
|
||||
$this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"';
|
||||
}
|
||||
}
|
||||
$this->current["val"] .= ">";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->depth++;
|
||||
}
|
||||
|
||||
/**
|
||||
* tag end handler
|
||||
*
|
||||
* @param resource parser
|
||||
* @param string tag name
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function _endElement($parser, $name)
|
||||
{
|
||||
if (strstr($name, " ")) {
|
||||
list($ns, $tag) = explode(" ", $name);
|
||||
if ($ns == "")
|
||||
$this->success = false;
|
||||
} else {
|
||||
$ns = "";
|
||||
$tag = $name;
|
||||
}
|
||||
|
||||
$this->depth--;
|
||||
|
||||
if ($this->depth >= 4) {
|
||||
$this->current["val"] .= "</$tag>";
|
||||
}
|
||||
|
||||
if ($this->depth == 3) {
|
||||
if (isset($this->current)) {
|
||||
$this->props[] = $this->current;
|
||||
unset($this->current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* input data handler
|
||||
*
|
||||
* @param resource parser
|
||||
* @param string data
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function _data($parser, $data)
|
||||
{
|
||||
if (isset($this->current)) {
|
||||
$this->current["val"] .= $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode:nil
|
||||
* End:
|
||||
*/
|
@ -55,7 +55,11 @@ In detail, the libraries added here are:
|
||||
- by Andrei Zmievski, Greg Beaver, Stig Bakken
|
||||
- License: PHP (Permission given to Moodle to redistribute under GPL)
|
||||
- http://pear.php.net/package/Console_Getopt
|
||||
|
||||
- PEAR HTTP_WebDAV_Server
|
||||
- Current version: HEAD @ 28-01-2008
|
||||
- by Hartmut Holzgraefe and Christian Stocker
|
||||
- License: BSD
|
||||
- http://pear.php.net/package/HTTP_WebDAV_Server
|
||||
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user