--- /dev/null
+<?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('./includes/init.php');
+
+/*=====================================================================*\
+|| ###################################################################
+|| # $HeadURL$
+|| # $Id$
+|| ###################################################################
+\*=====================================================================*/
+?>
\ No newline at end of file
// ###################################################################
// configuration file
-if (!file_exists('./config.php'))
+if (!file_exists('./includes/config.php'))
{
echo 'includes/config.php needs to be present!';
exit;
}
-require_once('./config.php');
+require_once('./includes/config.php');
// ###################################################################
// init isso
// ###################################################################
// imaginary reporter
-require_once('./imaginary.php');
+require_once('./includes/imaginary.php');
$viewsvn->trigger =& new Imaginary();
// ###################################################################
// load shell subsystem
-require_once('./shellcmd.php');
+require_once('./includes/shellcmd.php');
$viewsvn->shell =& new Shell();
// ###################################################################
// setup repository
-require_once('./repository.php');
+require_once('./includes/repository.php');
$viewsvn->repos =& new Repository($repository, $iscontainer);
+// ###################################################################
+// path manager
+require_once('./includes/paths.php');
+$viewsvn->paths =& new Paths($pathtype);
+
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
--- /dev/null
+<?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/ # ||
+|| ################################################################### ||
+\*=====================================================================*/
+
+/**
+* Handles the various methods that are used to navigate
+* browser paths
+*
+* @package ViewSVN
+*/
+
+/**
+* Path managing class that constructs and parses input
+* and output for paths
+*
+* @package ViewSVN
+* @version $Id$
+*/
+class Paths
+{
+ /**
+ * Path manager type
+ * @var integer
+ */
+ var $type;
+
+ /**
+ * Constructor: determine the type of linking to use
+ *
+ * @param integer Path management type
+ */
+ function Paths($type)
+ {
+ global $viewsvn;
+
+ if ($type < 1 OR $type > 2)
+ {
+ $viewsvn->trigger->error('invalid path management type');
+ }
+
+ $this->type = (int)$type;
+ }
+
+ /**
+ * Constructs a repository browser link
+ *
+ * @access public
+ *
+ * @param string Base path
+ * @param string Browser path, separated using '/'
+ *
+ * @return string Link path
+ */
+ function out($base, $addpath)
+ {
+ global $viewsvn;
+
+ $url = $this->fetch_arguments($base);
+ $addpath = $this->sanitize($addpath);
+
+ // standard URL type
+ if ($this->type == 1)
+ {
+ return $url[0] . '?path=' . $addpath . ($url[1] ? '&' . $url[1] : '');
+ }
+ // advanced path system
+ else if ($this->type == 2)
+ {
+ return $url[0] . '/' . $viewsvn->fetch_sourcepath($addpath) . ($url[1] ? '?' . $url[1] : '');
+ }
+ }
+
+ /**
+ * Fetches any URL parameters a link has
+ *
+ * @access public
+ *
+ * @param string Original URL
+ *
+ * @return array Two-element array: base path (no trailing '?'), arguments
+ */
+ function fetch_arguments($url)
+ {
+ $return = array();
+
+ if (($pos = strpos($url, '?')) !== false)
+ {
+ $return[0] = substr($url, 0, strlen($url) - $pos);
+ $return[1] = substr($url, $pos + 1);
+ }
+ else
+ {
+ $return[0] = $url;
+ $return[1] = '';
+ }
+
+ return $return;
+ }
+
+ /**
+ * Sanitizes a path for passing
+ *
+ * @access private
+ *
+ * @param string Path
+ *
+ * @return string Cleaned string
+ */
+ function sanitize($path)
+ {
+ return preg_replace('#[^a-z0-9\.]*#i', '', $path);
+ }
+}
+
+/*=====================================================================*\
+|| ###################################################################
+|| # $HeadURL$
+|| # $Id$
+|| ###################################################################
+\*=====================================================================*/
+?>
\ No newline at end of file
*/
class Repository
{
+ /**
+ * Array of valid repositories
+ * @var array
+ */
+ var $repositories = array();
+
+ /**
+ * Root path to the repository
+ * @var string
+ */
+ var $path;
+
+ /**
+ * Whether or not the path is a container
+ * @var bool
+ */
+ var $container;
+
/**
* Constructor: prepare for repository
*
{
global $viewsvn;
- $repos = array();
+ $this->path = $viewsvn->fetch_sourcepath($path);
+ $this->container = (bool)$iscontainer;
- $path = $viewsvn->fetch_sourcepath($path);
-
- if ($iscontainer)
+ if ($this->container)
{
- if ($dir = @opendir($path))
+ if ($dir = @opendir($this->path))
{
while (($file = readdir($dir)) !== false)
{
- if (is_dir($path . $file) AND $file{0} != '.' AND is_dir($path . $file . '/' . 'db'))
+ if (is_dir($this->path . $file) AND $file{0} != '.' AND is_dir($this->path . $file . '/' . 'db'))
{
- $repos[] = $file;
+ $this->repositories[] = $file;
}
}
closedir($dir);
}
else
{
- if (is_dir($path . 'db'))
+ if (is_dir($this->path . 'db'))
{
- $repos[] = $path;
+ $this->repositories[] = $this->path;
}
}
- if (count($repos) < 1)
+ if (count($this->repositories) < 1)
{
$viewsvn->trigger->error('no valid repositories');
}
}
+
+ /**
+ * Returns a list of repositories
+ *
+ * @access public
+ *
+ * @return array List of repositories
+ */
+ function fetch_list()
+ {
+ return $this->repositories;
+ }
+
+ /**
+ * Returns a path to a repository
+ *
+ * @access public
+ *
+ * @param string Repository name
+ *
+ * @return string Full path to the repository
+ */
+ function fetch_path($repository = '')
+ {
+ global $viewsvn;
+
+ if (!in_array($repository, $this->fetch_list()))
+ {
+ $viewsvn->trigger->error('invalid repository name');
+ }
+
+ if ($this->container)
+ {
+ return $this->path . $repository;
+ }
+ else
+ {
+ return $this->path;
+ }
+ }
}
/*=====================================================================*\
|| ################################################################### ||
\*=====================================================================*/
+require_once('./global.php');
+
+echo '<ul>';
+echo "\n";
+
+foreach ($viewsvn->repos->fetch_list() AS $repos)
+{
+ echo '<li><a href="' . $viewsvn->paths->out('browse.php?do=stuff', $repos) . '">' . $repos . '</a></li>';
+ echo "\n";
+}
+
+echo '</ul>';
+
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$