From e01ef96b1bdce056e766e030cb1746c608a67b1a Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 27 Aug 2005 19:03:13 +0000 Subject: [PATCH] Path parser is done --- browse.php | 27 +++++++++++++++ includes/paths.php | 74 +++++++++++++++++++++++++++++++++++++++++ includes/repository.php | 24 +++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 browse.php diff --git a/browse.php b/browse.php new file mode 100644 index 0000000..22073f8 --- /dev/null +++ b/browse.php @@ -0,0 +1,27 @@ +paths->parse(); +$repos = $viewsvn->paths->fetch_repos($path); +$relpath = $viewsvn->paths->fetch_path($path); + + + +/*=====================================================================*\ +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ +?> \ No newline at end of file diff --git a/includes/paths.php b/includes/paths.php index 92ac110..3d8e593 100644 --- a/includes/paths.php +++ b/includes/paths.php @@ -78,6 +78,80 @@ class Paths } } + /** + * Parses an incoming path with the various methods + * and returns a universal form + * + * @access public + * + * @return string Universal path, separated using '/' + */ + function parse() + { + global $viewsvn; + + // standard URL type + if ($this->type == 1) + { + $path = $viewsvn->in['path']; + } + // advanced path system + else if ($this->type == 2) + { + if ($_SERVER['PATH_INFO']) + { + $path = $viewsvn->sanitize($_SERVER['PATH_INFO']); + } + else + { + $viewsvn->trigger->error('server does not support type 2 management'); + } + } + + if (!$path) + { + $viewsvn->trigger->error('invalid path sent'); + } + + if (!$viewsvn->repos->verify($this->fetch_repos($path), $this->fetch_path($path))) + { + $viewsvn->trigger->error('invalid path'); + } + + return $path; + } + + /** + * Returns the name of the repository from a upath + * + * @access public + * + * @param string Universal path + * + * @return string Repository name + */ + function fetch_repos($path) + { + $temp = preg_split('#/#', $path, 0, PREG_SPLIT_NO_EMPTY); + return $temp[0]; + } + + /** + * Returns the path without the repository from a upath + * + * @access public + * + * @param string Universal path + * + * @return string Relative path + */ + function fetch_path($path) + { + $temp = preg_split('#/#', $path, 0, PREG_SPLIT_NO_EMPTY); + unset($temp[0]); + return '/' . implode('/', $temp); + } + /** * Fetches any URL parameters a link has * diff --git a/includes/repository.php b/includes/repository.php index f50a0f4..82d77aa 100644 --- a/includes/repository.php +++ b/includes/repository.php @@ -124,6 +124,30 @@ class Repository return $this->path; } } + + /** + * Verifies a path inside a repository + * + * @access public + * + * @param string Repository name + * @param string Path + * + * @return bool Validity + */ + function verify($repos, $path) + { + global $viewsvn; + + if ($repospath = $this->fetch_path($repos)) + { + return true; + } + else + { + return false; + } + } } /*=====================================================================*\ -- 2.22.5