@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | const WRITABLE = 'share_rw'; |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | - * Modes for sharing files |
|
| 76 | - * |
|
| 77 | - * @var array |
|
| 78 | - */ |
|
| 75 | + * Modes for sharing files |
|
| 76 | + * |
|
| 77 | + * @var array |
|
| 78 | + */ |
|
| 79 | 79 | static $modes = array( |
| 80 | 80 | self::ATTACH => array( |
| 81 | 81 | 'label' => 'Attachment', |
@@ -112,16 +112,16 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public static function get_token() |
| 114 | 114 | { |
| 115 | - // WebDAV has no concept of a query string and clients (including cadaver) |
|
| 116 | - // seem to pass '?' unencoded, so we need to extract the path info out |
|
| 117 | - // of the request URI ourselves |
|
| 118 | - // if request URI contains a full url, remove schema and domain |
|
| 115 | + // WebDAV has no concept of a query string and clients (including cadaver) |
|
| 116 | + // seem to pass '?' unencoded, so we need to extract the path info out |
|
| 117 | + // of the request URI ourselves |
|
| 118 | + // if request URI contains a full url, remove schema and domain |
|
| 119 | 119 | $matches = null; |
| 120 | - if (preg_match('|^https?://[^/]+(/.*)$|', $path_info=$_SERVER['REQUEST_URI'], $matches)) |
|
| 121 | - { |
|
| 122 | - $path_info = $matches[1]; |
|
| 123 | - } |
|
| 124 | - $path_info = substr($path_info, strlen($_SERVER['SCRIPT_NAME'])); |
|
| 120 | + if (preg_match('|^https?://[^/]+(/.*)$|', $path_info=$_SERVER['REQUEST_URI'], $matches)) |
|
| 121 | + { |
|
| 122 | + $path_info = $matches[1]; |
|
| 123 | + } |
|
| 124 | + $path_info = substr($path_info, strlen($_SERVER['SCRIPT_NAME'])); |
|
| 125 | 125 | list(, $token/*, $path*/) = preg_split('|[/?]|', $path_info, 3); |
| 126 | 126 | |
| 127 | 127 | return $token; |
@@ -228,10 +228,10 @@ |
||
| 228 | 228 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
| 229 | 229 | * |
| 230 | 230 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
| 231 | - * { |
|
| 231 | + * { |
|
| 232 | 232 | * $eof = !$eof; |
| 233 | 233 | * } |
| 234 | - * |
|
| 234 | + * |
|
| 235 | 235 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
| 236 | 236 | */ |
| 237 | 237 | function stream_eof ( ) |
@@ -80,10 +80,10 @@ |
||
| 80 | 80 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
| 81 | 81 | * |
| 82 | 82 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
| 83 | - * { |
|
| 83 | + * { |
|
| 84 | 84 | * $eof = !$eof; |
| 85 | 85 | * } |
| 86 | - * |
|
| 86 | + * |
|
| 87 | 87 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
| 88 | 88 | */ |
| 89 | 89 | function stream_eof ( ); |
@@ -43,209 +43,209 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class _parse_lockinfo |
| 45 | 45 | { |
| 46 | - /** |
|
| 47 | - * success state flag |
|
| 48 | - * |
|
| 49 | - * @var bool |
|
| 50 | - * @access public |
|
| 51 | - */ |
|
| 52 | - var $success = false; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * lock type, currently only "write" |
|
| 56 | - * |
|
| 57 | - * @var string |
|
| 58 | - * @access public |
|
| 59 | - */ |
|
| 60 | - var $locktype = ""; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * lock scope, "shared" or "exclusive" |
|
| 64 | - * |
|
| 65 | - * @var string |
|
| 66 | - * @access public |
|
| 67 | - */ |
|
| 68 | - var $lockscope = ""; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * lock owner information |
|
| 72 | - * |
|
| 73 | - * @var string |
|
| 74 | - * @access public |
|
| 75 | - */ |
|
| 76 | - var $owner = ""; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * flag that is set during lock owner read |
|
| 80 | - * |
|
| 81 | - * @var bool |
|
| 82 | - * @access private |
|
| 83 | - */ |
|
| 84 | - var $collect_owner = false; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * constructor |
|
| 88 | - * |
|
| 89 | - * @param string path of stream to read |
|
| 90 | - * @access public |
|
| 91 | - */ |
|
| 92 | - function __construct($path) |
|
| 93 | - { |
|
| 94 | - // we assume success unless problems occur |
|
| 95 | - $this->success = true; |
|
| 96 | - |
|
| 97 | - // remember if any input was parsed |
|
| 98 | - $had_input = false; |
|
| 99 | - |
|
| 100 | - // open stream |
|
| 101 | - $f_in = fopen($path, "r"); |
|
| 102 | - if (!$f_in) { |
|
| 103 | - $this->success = false; |
|
| 104 | - return; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - // create namespace aware parser |
|
| 108 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 109 | - |
|
| 110 | - // set tag and data handlers |
|
| 111 | - xml_set_element_handler($xml_parser, |
|
| 112 | - array(&$this, "_startElement"), |
|
| 113 | - array(&$this, "_endElement")); |
|
| 114 | - xml_set_character_data_handler($xml_parser, |
|
| 115 | - array(&$this, "_data")); |
|
| 116 | - |
|
| 117 | - // we want a case sensitive parser |
|
| 118 | - xml_parser_set_option($xml_parser, |
|
| 119 | - XML_OPTION_CASE_FOLDING, false); |
|
| 120 | - |
|
| 121 | - // parse input |
|
| 122 | - while ($this->success && !feof($f_in)) { |
|
| 123 | - $line = fgets($f_in); |
|
| 124 | - if (is_string($line)) { |
|
| 125 | - $had_input = true; |
|
| 126 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - // finish parsing |
|
| 131 | - if ($had_input) { |
|
| 132 | - $this->success &= xml_parse($xml_parser, "", true); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - // check if required tags where found |
|
| 136 | - $this->success &= !empty($this->locktype); |
|
| 137 | - $this->success &= !empty($this->lockscope); |
|
| 138 | - |
|
| 139 | - // free parser resource |
|
| 140 | - xml_parser_free($xml_parser); |
|
| 141 | - |
|
| 142 | - // close input stream |
|
| 143 | - fclose($f_in); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * tag start handler |
|
| 149 | - * |
|
| 150 | - * @param resource parser |
|
| 151 | - * @param string tag name |
|
| 152 | - * @param array tag attributes |
|
| 153 | - * @return void |
|
| 154 | - * @access private |
|
| 155 | - */ |
|
| 156 | - function _startElement($parser, $name, $attrs) |
|
| 157 | - { |
|
| 158 | - // namespace handling |
|
| 159 | - if (strstr($name, " ")) { |
|
| 160 | - list($ns, $tag) = explode(" ", $name); |
|
| 161 | - } else { |
|
| 162 | - $ns = ""; |
|
| 163 | - $tag = $name; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - if ($this->collect_owner) { |
|
| 168 | - // everything within the <owner> tag needs to be collected |
|
| 169 | - $ns_short = ""; |
|
| 170 | - $ns_attr = ""; |
|
| 171 | - if ($ns) { |
|
| 172 | - if ($ns == "DAV:") { |
|
| 173 | - $ns_short = "D:"; |
|
| 174 | - } else { |
|
| 175 | - $ns_attr = " xmlns='$ns'"; |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
| 179 | - } else if ($ns == "DAV:") { |
|
| 180 | - // parse only the essential tags |
|
| 181 | - switch ($tag) { |
|
| 182 | - case "write": |
|
| 183 | - $this->locktype = $tag; |
|
| 184 | - break; |
|
| 185 | - case "exclusive": |
|
| 186 | - case "shared": |
|
| 187 | - $this->lockscope = $tag; |
|
| 188 | - break; |
|
| 189 | - case "owner": |
|
| 190 | - $this->collect_owner = true; |
|
| 191 | - break; |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * data handler |
|
| 198 | - * |
|
| 199 | - * @param resource parser |
|
| 200 | - * @param string data |
|
| 201 | - * @return void |
|
| 202 | - * @access private |
|
| 203 | - */ |
|
| 204 | - function _data($parser, $data) |
|
| 205 | - { |
|
| 206 | - // only the <owner> tag has data content |
|
| 207 | - if ($this->collect_owner) { |
|
| 208 | - $this->owner .= $data; |
|
| 209 | - } |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * tag end handler |
|
| 214 | - * |
|
| 215 | - * @param resource parser |
|
| 216 | - * @param string tag name |
|
| 217 | - * @return void |
|
| 218 | - * @access private |
|
| 219 | - */ |
|
| 220 | - function _endElement($parser, $name) |
|
| 221 | - { |
|
| 222 | - // namespace handling |
|
| 223 | - if (strstr($name, " ")) { |
|
| 224 | - list($ns, $tag) = explode(" ", $name); |
|
| 225 | - } else { |
|
| 226 | - $ns = ""; |
|
| 227 | - $tag = $name; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - // <owner> finished? |
|
| 231 | - if (($ns == "DAV:") && ($tag == "owner")) { |
|
| 232 | - $this->collect_owner = false; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - // within <owner> we have to collect everything |
|
| 236 | - if ($this->collect_owner) { |
|
| 237 | - $ns_short = ""; |
|
| 238 | - $ns_attr = ""; |
|
| 239 | - if ($ns) { |
|
| 240 | - if ($ns == "DAV:") { |
|
| 241 | - $ns_short = "D:"; |
|
| 242 | - } else { |
|
| 243 | - $ns_attr = " xmlns='$ns'"; |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
| 247 | - } |
|
| 248 | - } |
|
| 46 | + /** |
|
| 47 | + * success state flag |
|
| 48 | + * |
|
| 49 | + * @var bool |
|
| 50 | + * @access public |
|
| 51 | + */ |
|
| 52 | + var $success = false; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * lock type, currently only "write" |
|
| 56 | + * |
|
| 57 | + * @var string |
|
| 58 | + * @access public |
|
| 59 | + */ |
|
| 60 | + var $locktype = ""; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * lock scope, "shared" or "exclusive" |
|
| 64 | + * |
|
| 65 | + * @var string |
|
| 66 | + * @access public |
|
| 67 | + */ |
|
| 68 | + var $lockscope = ""; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * lock owner information |
|
| 72 | + * |
|
| 73 | + * @var string |
|
| 74 | + * @access public |
|
| 75 | + */ |
|
| 76 | + var $owner = ""; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * flag that is set during lock owner read |
|
| 80 | + * |
|
| 81 | + * @var bool |
|
| 82 | + * @access private |
|
| 83 | + */ |
|
| 84 | + var $collect_owner = false; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * constructor |
|
| 88 | + * |
|
| 89 | + * @param string path of stream to read |
|
| 90 | + * @access public |
|
| 91 | + */ |
|
| 92 | + function __construct($path) |
|
| 93 | + { |
|
| 94 | + // we assume success unless problems occur |
|
| 95 | + $this->success = true; |
|
| 96 | + |
|
| 97 | + // remember if any input was parsed |
|
| 98 | + $had_input = false; |
|
| 99 | + |
|
| 100 | + // open stream |
|
| 101 | + $f_in = fopen($path, "r"); |
|
| 102 | + if (!$f_in) { |
|
| 103 | + $this->success = false; |
|
| 104 | + return; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + // create namespace aware parser |
|
| 108 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 109 | + |
|
| 110 | + // set tag and data handlers |
|
| 111 | + xml_set_element_handler($xml_parser, |
|
| 112 | + array(&$this, "_startElement"), |
|
| 113 | + array(&$this, "_endElement")); |
|
| 114 | + xml_set_character_data_handler($xml_parser, |
|
| 115 | + array(&$this, "_data")); |
|
| 116 | + |
|
| 117 | + // we want a case sensitive parser |
|
| 118 | + xml_parser_set_option($xml_parser, |
|
| 119 | + XML_OPTION_CASE_FOLDING, false); |
|
| 120 | + |
|
| 121 | + // parse input |
|
| 122 | + while ($this->success && !feof($f_in)) { |
|
| 123 | + $line = fgets($f_in); |
|
| 124 | + if (is_string($line)) { |
|
| 125 | + $had_input = true; |
|
| 126 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + // finish parsing |
|
| 131 | + if ($had_input) { |
|
| 132 | + $this->success &= xml_parse($xml_parser, "", true); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + // check if required tags where found |
|
| 136 | + $this->success &= !empty($this->locktype); |
|
| 137 | + $this->success &= !empty($this->lockscope); |
|
| 138 | + |
|
| 139 | + // free parser resource |
|
| 140 | + xml_parser_free($xml_parser); |
|
| 141 | + |
|
| 142 | + // close input stream |
|
| 143 | + fclose($f_in); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * tag start handler |
|
| 149 | + * |
|
| 150 | + * @param resource parser |
|
| 151 | + * @param string tag name |
|
| 152 | + * @param array tag attributes |
|
| 153 | + * @return void |
|
| 154 | + * @access private |
|
| 155 | + */ |
|
| 156 | + function _startElement($parser, $name, $attrs) |
|
| 157 | + { |
|
| 158 | + // namespace handling |
|
| 159 | + if (strstr($name, " ")) { |
|
| 160 | + list($ns, $tag) = explode(" ", $name); |
|
| 161 | + } else { |
|
| 162 | + $ns = ""; |
|
| 163 | + $tag = $name; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + if ($this->collect_owner) { |
|
| 168 | + // everything within the <owner> tag needs to be collected |
|
| 169 | + $ns_short = ""; |
|
| 170 | + $ns_attr = ""; |
|
| 171 | + if ($ns) { |
|
| 172 | + if ($ns == "DAV:") { |
|
| 173 | + $ns_short = "D:"; |
|
| 174 | + } else { |
|
| 175 | + $ns_attr = " xmlns='$ns'"; |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
| 179 | + } else if ($ns == "DAV:") { |
|
| 180 | + // parse only the essential tags |
|
| 181 | + switch ($tag) { |
|
| 182 | + case "write": |
|
| 183 | + $this->locktype = $tag; |
|
| 184 | + break; |
|
| 185 | + case "exclusive": |
|
| 186 | + case "shared": |
|
| 187 | + $this->lockscope = $tag; |
|
| 188 | + break; |
|
| 189 | + case "owner": |
|
| 190 | + $this->collect_owner = true; |
|
| 191 | + break; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * data handler |
|
| 198 | + * |
|
| 199 | + * @param resource parser |
|
| 200 | + * @param string data |
|
| 201 | + * @return void |
|
| 202 | + * @access private |
|
| 203 | + */ |
|
| 204 | + function _data($parser, $data) |
|
| 205 | + { |
|
| 206 | + // only the <owner> tag has data content |
|
| 207 | + if ($this->collect_owner) { |
|
| 208 | + $this->owner .= $data; |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * tag end handler |
|
| 214 | + * |
|
| 215 | + * @param resource parser |
|
| 216 | + * @param string tag name |
|
| 217 | + * @return void |
|
| 218 | + * @access private |
|
| 219 | + */ |
|
| 220 | + function _endElement($parser, $name) |
|
| 221 | + { |
|
| 222 | + // namespace handling |
|
| 223 | + if (strstr($name, " ")) { |
|
| 224 | + list($ns, $tag) = explode(" ", $name); |
|
| 225 | + } else { |
|
| 226 | + $ns = ""; |
|
| 227 | + $tag = $name; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + // <owner> finished? |
|
| 231 | + if (($ns == "DAV:") && ($tag == "owner")) { |
|
| 232 | + $this->collect_owner = false; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + // within <owner> we have to collect everything |
|
| 236 | + if ($this->collect_owner) { |
|
| 237 | + $ns_short = ""; |
|
| 238 | + $ns_attr = ""; |
|
| 239 | + if ($ns) { |
|
| 240 | + if ($ns == "DAV:") { |
|
| 241 | + $ns_short = "D:"; |
|
| 242 | + } else { |
|
| 243 | + $ns_attr = " xmlns='$ns'"; |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | ?> |
@@ -43,198 +43,198 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class _parse_proppatch |
| 45 | 45 | { |
| 46 | - /** |
|
| 47 | - * |
|
| 48 | - * |
|
| 49 | - * @var |
|
| 50 | - * @access |
|
| 51 | - */ |
|
| 52 | - var $success; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * |
|
| 56 | - * |
|
| 57 | - * @var |
|
| 58 | - * @access |
|
| 59 | - */ |
|
| 60 | - var $props; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * |
|
| 64 | - * |
|
| 65 | - * @var |
|
| 66 | - * @access |
|
| 67 | - */ |
|
| 68 | - var $depth; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * |
|
| 72 | - * |
|
| 73 | - * @var |
|
| 74 | - * @access |
|
| 75 | - */ |
|
| 76 | - var $mode; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * |
|
| 80 | - * |
|
| 81 | - * @var |
|
| 82 | - * @access |
|
| 83 | - */ |
|
| 84 | - var $current; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * On return whole request, if $store_request == true was specified in constructor |
|
| 88 | - * |
|
| 89 | - * @var string |
|
| 90 | - */ |
|
| 91 | - var $request; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * constructor |
|
| 95 | - * |
|
| 96 | - * @param string path of input stream |
|
| 97 | - * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
| 98 | - * @access public |
|
| 99 | - */ |
|
| 100 | - function __construct($path, $store_request=false) |
|
| 101 | - { |
|
| 102 | - $this->success = true; |
|
| 103 | - |
|
| 104 | - $this->depth = 0; |
|
| 105 | - $this->props = array(); |
|
| 106 | - $had_input = false; |
|
| 107 | - |
|
| 108 | - $f_in = fopen($path, "r"); |
|
| 109 | - if (!$f_in) { |
|
| 110 | - $this->success = false; |
|
| 111 | - return; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 115 | - |
|
| 116 | - xml_set_element_handler($xml_parser, |
|
| 117 | - array(&$this, "_startElement"), |
|
| 118 | - array(&$this, "_endElement")); |
|
| 119 | - |
|
| 120 | - xml_set_character_data_handler($xml_parser, |
|
| 121 | - array(&$this, "_data")); |
|
| 122 | - |
|
| 123 | - xml_parser_set_option($xml_parser, |
|
| 124 | - XML_OPTION_CASE_FOLDING, false); |
|
| 125 | - |
|
| 126 | - while($this->success && !feof($f_in)) { |
|
| 127 | - $line = fgets($f_in); |
|
| 128 | - if ($store_request) $this->request .= $line; |
|
| 129 | - if (is_string($line)) { |
|
| 130 | - $had_input = true; |
|
| 131 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - if($had_input) { |
|
| 136 | - $this->success &= xml_parse($xml_parser, "", true); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - xml_parser_free($xml_parser); |
|
| 140 | - |
|
| 141 | - fclose($f_in); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * tag start handler |
|
| 146 | - * |
|
| 147 | - * @param resource parser |
|
| 148 | - * @param string tag name |
|
| 149 | - * @param array tag attributes |
|
| 150 | - * @return void |
|
| 151 | - * @access private |
|
| 152 | - */ |
|
| 153 | - function _startElement($parser, $name, $attrs) |
|
| 154 | - { |
|
| 155 | - if (strstr($name, " ")) { |
|
| 156 | - list($ns, $tag) = explode(" ", $name); |
|
| 157 | - if ($ns == "") |
|
| 158 | - $this->success = false; |
|
| 159 | - } else { |
|
| 160 | - $ns = ""; |
|
| 161 | - $tag = $name; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - if ($this->depth == 1) { |
|
| 165 | - $this->mode = $tag; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - if ($this->depth == 3) { |
|
| 169 | - $prop = array("name" => $tag); |
|
| 170 | - $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
|
| 171 | - if ($this->mode == "set") { |
|
| 172 | - $this->current["val"] = ""; // default set val |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - if ($this->depth >= 4) { |
|
| 177 | - $this->current["val"] .= "<$tag"; |
|
| 178 | - if (isset($attr)) { |
|
| 179 | - foreach ($attr as $key => $val) { |
|
| 180 | - $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - $this->current["val"] .= ">"; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - $this->depth++; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * tag end handler |
|
| 193 | - * |
|
| 194 | - * @param resource parser |
|
| 195 | - * @param string tag name |
|
| 196 | - * @return void |
|
| 197 | - * @access private |
|
| 198 | - */ |
|
| 199 | - function _endElement($parser, $name) |
|
| 200 | - { |
|
| 201 | - if (strstr($name, " ")) { |
|
| 202 | - list($ns, $tag) = explode(" ", $name); |
|
| 203 | - if ($ns == "") |
|
| 204 | - $this->success = false; |
|
| 205 | - } else { |
|
| 206 | - $ns = ""; |
|
| 207 | - $tag = $name; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - $this->depth--; |
|
| 211 | - |
|
| 212 | - if ($this->depth >= 4) { |
|
| 213 | - $this->current["val"] .= "</$tag>"; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - if ($this->depth == 3) { |
|
| 217 | - if (isset($this->current)) { |
|
| 218 | - $this->props[] = $this->current; |
|
| 219 | - unset($this->current); |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * input data handler |
|
| 226 | - * |
|
| 227 | - * @param resource parser |
|
| 228 | - * @param string data |
|
| 229 | - * @return void |
|
| 230 | - * @access private |
|
| 231 | - */ |
|
| 232 | - function _data($parser, $data) |
|
| 233 | - { |
|
| 234 | - if (isset($this->current)) { |
|
| 235 | - $this->current["val"] .= $data; |
|
| 236 | - } |
|
| 237 | - } |
|
| 46 | + /** |
|
| 47 | + * |
|
| 48 | + * |
|
| 49 | + * @var |
|
| 50 | + * @access |
|
| 51 | + */ |
|
| 52 | + var $success; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * |
|
| 56 | + * |
|
| 57 | + * @var |
|
| 58 | + * @access |
|
| 59 | + */ |
|
| 60 | + var $props; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * |
|
| 64 | + * |
|
| 65 | + * @var |
|
| 66 | + * @access |
|
| 67 | + */ |
|
| 68 | + var $depth; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * |
|
| 72 | + * |
|
| 73 | + * @var |
|
| 74 | + * @access |
|
| 75 | + */ |
|
| 76 | + var $mode; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * |
|
| 80 | + * |
|
| 81 | + * @var |
|
| 82 | + * @access |
|
| 83 | + */ |
|
| 84 | + var $current; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * On return whole request, if $store_request == true was specified in constructor |
|
| 88 | + * |
|
| 89 | + * @var string |
|
| 90 | + */ |
|
| 91 | + var $request; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * constructor |
|
| 95 | + * |
|
| 96 | + * @param string path of input stream |
|
| 97 | + * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
| 98 | + * @access public |
|
| 99 | + */ |
|
| 100 | + function __construct($path, $store_request=false) |
|
| 101 | + { |
|
| 102 | + $this->success = true; |
|
| 103 | + |
|
| 104 | + $this->depth = 0; |
|
| 105 | + $this->props = array(); |
|
| 106 | + $had_input = false; |
|
| 107 | + |
|
| 108 | + $f_in = fopen($path, "r"); |
|
| 109 | + if (!$f_in) { |
|
| 110 | + $this->success = false; |
|
| 111 | + return; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 115 | + |
|
| 116 | + xml_set_element_handler($xml_parser, |
|
| 117 | + array(&$this, "_startElement"), |
|
| 118 | + array(&$this, "_endElement")); |
|
| 119 | + |
|
| 120 | + xml_set_character_data_handler($xml_parser, |
|
| 121 | + array(&$this, "_data")); |
|
| 122 | + |
|
| 123 | + xml_parser_set_option($xml_parser, |
|
| 124 | + XML_OPTION_CASE_FOLDING, false); |
|
| 125 | + |
|
| 126 | + while($this->success && !feof($f_in)) { |
|
| 127 | + $line = fgets($f_in); |
|
| 128 | + if ($store_request) $this->request .= $line; |
|
| 129 | + if (is_string($line)) { |
|
| 130 | + $had_input = true; |
|
| 131 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + if($had_input) { |
|
| 136 | + $this->success &= xml_parse($xml_parser, "", true); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + xml_parser_free($xml_parser); |
|
| 140 | + |
|
| 141 | + fclose($f_in); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * tag start handler |
|
| 146 | + * |
|
| 147 | + * @param resource parser |
|
| 148 | + * @param string tag name |
|
| 149 | + * @param array tag attributes |
|
| 150 | + * @return void |
|
| 151 | + * @access private |
|
| 152 | + */ |
|
| 153 | + function _startElement($parser, $name, $attrs) |
|
| 154 | + { |
|
| 155 | + if (strstr($name, " ")) { |
|
| 156 | + list($ns, $tag) = explode(" ", $name); |
|
| 157 | + if ($ns == "") |
|
| 158 | + $this->success = false; |
|
| 159 | + } else { |
|
| 160 | + $ns = ""; |
|
| 161 | + $tag = $name; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + if ($this->depth == 1) { |
|
| 165 | + $this->mode = $tag; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + if ($this->depth == 3) { |
|
| 169 | + $prop = array("name" => $tag); |
|
| 170 | + $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
|
| 171 | + if ($this->mode == "set") { |
|
| 172 | + $this->current["val"] = ""; // default set val |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + if ($this->depth >= 4) { |
|
| 177 | + $this->current["val"] .= "<$tag"; |
|
| 178 | + if (isset($attr)) { |
|
| 179 | + foreach ($attr as $key => $val) { |
|
| 180 | + $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + $this->current["val"] .= ">"; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + $this->depth++; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * tag end handler |
|
| 193 | + * |
|
| 194 | + * @param resource parser |
|
| 195 | + * @param string tag name |
|
| 196 | + * @return void |
|
| 197 | + * @access private |
|
| 198 | + */ |
|
| 199 | + function _endElement($parser, $name) |
|
| 200 | + { |
|
| 201 | + if (strstr($name, " ")) { |
|
| 202 | + list($ns, $tag) = explode(" ", $name); |
|
| 203 | + if ($ns == "") |
|
| 204 | + $this->success = false; |
|
| 205 | + } else { |
|
| 206 | + $ns = ""; |
|
| 207 | + $tag = $name; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + $this->depth--; |
|
| 211 | + |
|
| 212 | + if ($this->depth >= 4) { |
|
| 213 | + $this->current["val"] .= "</$tag>"; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + if ($this->depth == 3) { |
|
| 217 | + if (isset($this->current)) { |
|
| 218 | + $this->props[] = $this->current; |
|
| 219 | + unset($this->current); |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * input data handler |
|
| 226 | + * |
|
| 227 | + * @param resource parser |
|
| 228 | + * @param string data |
|
| 229 | + * @return void |
|
| 230 | + * @access private |
|
| 231 | + */ |
|
| 232 | + function _data($parser, $data) |
|
| 233 | + { |
|
| 234 | + if (isset($this->current)) { |
|
| 235 | + $this->current["val"] .= $data; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /* |
@@ -255,20 +255,20 @@ |
||
| 255 | 255 | */ |
| 256 | 256 | static public function parse_digest($txt) |
| 257 | 257 | { |
| 258 | - // protect against missing data |
|
| 259 | - $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1); |
|
| 260 | - $data = array(); |
|
| 261 | - $keys = implode('|', array_keys($needed_parts)); |
|
| 258 | + // protect against missing data |
|
| 259 | + $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1); |
|
| 260 | + $data = array(); |
|
| 261 | + $keys = implode('|', array_keys($needed_parts)); |
|
| 262 | 262 | |
| 263 | 263 | $matches = null; |
| 264 | - preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); |
|
| 264 | + preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); |
|
| 265 | 265 | |
| 266 | - foreach ($matches as $m) |
|
| 267 | - { |
|
| 268 | - $data[$m[1]] = $m[3] ? $m[3] : $m[4]; |
|
| 269 | - unset($needed_parts[$m[1]]); |
|
| 270 | - } |
|
| 271 | - //error_log(__METHOD__."('$txt') returning ".array2string($needed_parts ? false : $data)); |
|
| 272 | - return $needed_parts ? false : $data; |
|
| 266 | + foreach ($matches as $m) |
|
| 267 | + { |
|
| 268 | + $data[$m[1]] = $m[3] ? $m[3] : $m[4]; |
|
| 269 | + unset($needed_parts[$m[1]]); |
|
| 270 | + } |
|
| 271 | + //error_log(__METHOD__."('$txt') returning ".array2string($needed_parts ? false : $data)); |
|
| 272 | + return $needed_parts ? false : $data; |
|
| 273 | 273 | } |
| 274 | 274 | } |
@@ -238,10 +238,10 @@ |
||
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
| 241 | - * Delete a directory RECURSIVELY |
|
| 242 | - * @param string $dir - directory path |
|
| 243 | - * @link http://php.net/manual/en/function.rmdir.php |
|
| 244 | - */ |
|
| 241 | + * Delete a directory RECURSIVELY |
|
| 242 | + * @param string $dir - directory path |
|
| 243 | + * @link http://php.net/manual/en/function.rmdir.php |
|
| 244 | + */ |
|
| 245 | 245 | private static function rrmdir($dir) |
| 246 | 246 | { |
| 247 | 247 | if (is_dir($dir)) |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | * while it uses select-account for owner in historylog (containing all users). |
| 34 | 34 | * |
| 35 | 35 | * @param string $cname |
| 36 | - */ |
|
| 36 | + */ |
|
| 37 | 37 | public function beforeSendToClient($cname) |
| 38 | 38 | { |
| 39 | 39 | $form_name = self::form_name($cname, $this->id); |
@@ -903,12 +903,12 @@ |
||
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | /** |
| 906 | - * Check if we have not ignored validation errors |
|
| 907 | - * |
|
| 908 | - * @param string $ignore_validation ='' if not empty regular expression for validation-errors to ignore |
|
| 909 | - * @param string $cname =null name-prefix, which need to be ignored, default self::$name_vars |
|
| 910 | - * @return boolean true if there are not ignored validation errors, false otherwise |
|
| 911 | - */ |
|
| 906 | + * Check if we have not ignored validation errors |
|
| 907 | + * |
|
| 908 | + * @param string $ignore_validation ='' if not empty regular expression for validation-errors to ignore |
|
| 909 | + * @param string $cname =null name-prefix, which need to be ignored, default self::$name_vars |
|
| 910 | + * @return boolean true if there are not ignored validation errors, false otherwise |
|
| 911 | + */ |
|
| 912 | 912 | public static function validation_errors($ignore_validation='',$cname='') |
| 913 | 913 | { |
| 914 | 914 | // not yet used: if (is_null($cname)) $cname = self::$name_vars; |