/** * Returns the repository version * * @return integer Repository version * @access public */ public function getVersion() { if ($this->_repVersion > 0) { return $this->_repVersion; } $this->_repVersion = -1; $this->initQuery($args, "PROPFIND", $this->cleanURL($this->_url . "/!svn/vcc/default")); $args['Body'] = PHPSVN_VERSION_REQUEST; $args['Headers']['Content-Length'] = strlen(PHPSVN_NORMAL_REQUEST); $args['Headers']['Depth'] = 0; //echo $vini."\r\n"; //echo $vend."\r\n"; //echo "Args: \r\n"; //print_r($args); //echo "Headers: \r\n"; //print_r($tmp); if (!$this->Request($args, $tmp, $body)) { return $this->_repVersion; } $parser = new xml_parser_class(); $parser->Parse($body, true); $enable = false; foreach ($parser->structure as $value) { if ($enable) { $t = explode("/", $value); // start from the end and move backwards until we find a non-blank entry $index = count($t) - 1; while ($t[$index] == "") { $index--; } // check the last non-empty element to see if it's numeric. If so, it's the revision number if (is_numeric($t[$index])) { $this->_repVersion = $t[$index]; break; } else { $enable = false; continue; } } if (is_array($value) && $value['Tag'] == 'D:href') { $enable = true; } } return $this->_repVersion; }
function XMLParseString(&$parser, $str, $store_positions, $cache = "", $case_folding = 0, $target_encoding = "ISO-8859-1", $simplified_xml = 0, $fail_on_non_simplified_xml = 0) { if (strcmp($cache, "")) { if (file_exists($cache) && filectime($file) <= filectime($cache)) { if ($cache_file = fopen($cache, "r")) { if (function_exists("set_file_buffer")) { set_file_buffer($cache_file, 0); } if (!($cache_contents = fread($cache_file, filesize($cache)))) { $error = "could not read from the XML cache file {$cache}"; } else { $error = ""; } fclose($cache_file); if (!strcmp($error, "")) { if (GetType($parser = unserialize($cache_contents)) == "object" && isset($parser->structure)) { if (!isset($parser->simplified_xml)) { $parser->simplified_xml = 0; } if (($simplified_xml || !$parser->simplified_xml) && (!$store_positions || $parser->store_positions)) { return ""; } } else { $error = "it was not specified a valid cache object in XML file ({$cache})"; } } } else { $error = "could not open cache XML file ({$cache})"; } if (strcmp($error, "")) { return $error; } } } $parser = new xml_parser_class(); $parser->store_positions = $store_positions; $parser->case_folding = $case_folding; $parser->target_encoding = $target_encoding; $parser->simplified_xml = $simplified_xml; $parser->fail_on_non_simplified_xml = $fail_on_non_simplified_xml; if (!strcmp($error = $parser->Parse($str, TRUE), "") && strcmp($cache, "")) { if ($cache_file = fopen($cache, "w")) { if (function_exists("set_file_buffer")) { set_file_buffer($cache_file, 0); } if (!fwrite($cache_file, serialize($parser))) { $error = "could to write to the XML cache file ({$cache})"; } fclose($cache_file); if (strcmp($error, "")) { unlink($cache); } } else { $error = "could not open for writing to the cache file ({$cache})"; } } return $error; }