Path parser is done
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 27 Aug 2005 19:03:13 +0000 (19:03 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 27 Aug 2005 19:03:13 +0000 (19:03 +0000)
browse.php [new file with mode: 0644]
includes/paths.php
includes/repository.php

diff --git a/browse.php b/browse.php
new file mode 100644 (file)
index 0000000..22073f8
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+/*=====================================================================*\
+|| ################################################################### ||
+|| # ViewSVN [#]version[#]
+|| # --------------------------------------------------------------- # ||
+|| # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
+|| # This file may not be reproduced in any way without permission.  # ||
+|| # --------------------------------------------------------------- # ||
+|| # User License Agreement at http://www.iris-studios.com/license/  # ||
+|| ################################################################### ||
+\*=====================================================================*/
+
+require_once('./global.php');
+
+$path = $viewsvn->paths->parse();
+$repos = $viewsvn->paths->fetch_repos($path);
+$relpath = $viewsvn->paths->fetch_path($path);
+
+
+
+/*=====================================================================*\
+|| ###################################################################
+|| # $HeadURL$
+|| # $Id$
+|| ###################################################################
+\*=====================================================================*/
+?>
\ No newline at end of file
index 92ac110ba15081cbfc54452ab8a35249b08fc42e..3d8e593a9d94e88ae910d2c4584b3db0062f33e5 100644 (file)
@@ -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
        *
index f50a0f40e3f8cde865468f5f6ac6372d8bcbb985..82d77aa5e5d26283719189851732c35bfe81f28f 100644 (file)
@@ -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;
+               }
+       }
 }
 
 /*=====================================================================*\