$repos = $viewsvn->paths->fetch_repos($path);
$relpath = $viewsvn->paths->fetch_path($path);
+$listing = $viewsvn->svn->ls($repos, $relpath, 0);
+print_r($listing);
+
+echo '<ul>';
+echo "\n";
+
+echo '<li><a href="/viewsvn/' . $viewsvn->paths->out('browse.php', $path . '..') . '">Up One Level</a></li>';
+echo "\n";
+
+foreach ($listing AS $item)
+{
+ echo '<li>';
+ if ($item{ strlen($item) - 1 } == '/')
+ {
+ echo '<a href="/viewsvn/' . $viewsvn->paths->out('browse.php', $path . $item) . '">' . $item . '</a>';
+ }
+ else
+ {
+ echo '<a href="/viewsvn/' . $viewsvn->paths->out('log.php', $path . $item) . '">'. $item . '</a>';
+ }
+ echo '</li>';
+ echo "\n";
+}
+
+echo '</ul>';
/*=====================================================================*\
|| ###################################################################
// advanced path system
else if ($this->type == 2)
{
- return $url[0] . '/' . $viewsvn->fetch_sourcepath($addpath) . ($url[1] ? '?' . $url[1] : '');
+ return $url[0] . ($addpath{0} != '/' ? '/' : '') . $viewsvn->fetch_sourcepath($addpath) . ($url[1] ? '?' . $url[1] : '');
}
}
// advanced path system
else if ($this->type == 2)
{
- if ($_SERVER['PATH_INFO'])
+ if (@$_SERVER['PATH_INFO'])
{
$path = $viewsvn->sanitize($_SERVER['PATH_INFO']);
}
*/
function sanitize($path)
{
- return preg_replace('#[^a-z0-9\.]*#i', '', $path);
+ return preg_replace('#[^a-z0-9\./\-]*#i', '', $path);
}
}
|| ################################################################### ||
\*=====================================================================*/
+/**
+* Command line interface with the SVN commands
+*
+* @package ViewSVN
+*/
+
+/**
+* Interacts with the command line subsystem to
+* access SVN information
+*
+* @package ViewSVN
+* @version $Id$
+*/
+class SVNLib
+{
+ /**
+ * Path to the SVN binary
+ * @var string
+ */
+ var $svnpath;
+
+ /**
+ * Constructor: validate SVN path
+ *
+ * @param string Path to SVN binary
+ */
+ function SVNLib($svnpath)
+ {
+ global $viewsvn;
+
+ $this->svnpath = $viewsvn->shell->cmd($svnpath);
+
+ $access = $viewsvn->shell->exec($this->svnpath . ' --version');
+
+ if (!$access)
+ {
+ $viewsvn->trigger->error('svn binary could not be found');
+ }
+
+ if (!preg_match('#^svn, version (.*?)\)$#i', trim($access[0])))
+ {
+ $viewsvn->trigger->error('svn binary does not pass test');
+ }
+ }
+
+ /**
+ * Executes the SVN binary
+ *
+ * @access private
+ *
+ * @param string Command
+ *
+ * @return array Output
+ */
+ function svn($command)
+ {
+ global $viewsvn;
+
+ return $viewsvn->shell->exec($this->svnpath . ' ' . $command . ' 2>&1');
+ }
+
+ /**
+ * SVN Wrapper: standard command system
+ *
+ * @access private
+ *
+ * @param string SVN command
+ * @param string Repository
+ * @param string Path
+ * @param integer Revision
+ *
+ * @return array Lines of output
+ */
+ function std($command, $repos, $path, $revision)
+ {
+ global $viewsvn;
+
+ $revision = $this->rev($revision);
+ $repospath = $viewsvn->repos->fetch_path($repos);
+
+ return $this->svn($command . ' -r' . $revision . ' ' . $repospath . $path);
+ }
+
+ /**
+ * SVN Wrapper: blame
+ *
+ * @access protected
+ *
+ * @param string Repository
+ * @param string Path
+ * @param integer Revision
+ *
+ * @return array Lines of blame output
+ */
+ function blame($repos, $path, $revision)
+ {
+ return $this->std('blame', $repos, $path, $revision);
+ }
+
+ /**
+ * SVN Wrapper: cat
+ *
+ * @access protected
+ *
+ * @param string Repository
+ * @param string Path
+ * @param integer Revision
+ *
+ * @return array Lines of cat output
+ */
+ function cat($repos, $path, $revision)
+ {
+ return $this->std('cat', $repos, $path, $revision);
+ }
+
+ /**
+ * SVN Wrapper: ls (list)
+ *
+ * @access protected
+ *
+ * @param string Repository
+ * @param string Path
+ * @param integer Revision
+ *
+ * @return array Lines of list output
+ */
+ function ls($repos, $path, $revision)
+ {
+ return $this->std('list', $repos, $path, $revision);
+ }
+
+ /**
+ * Generates a clean revision number
+ *
+ * @access public
+ *
+ * @param integer Revision number
+ *
+ * @return mixed Cleaned revision or HEAD
+ */
+ function rev($revision)
+ {
+ if (($revision = intval($revision)) < 1)
+ {
+ $revision = 'HEAD';
+ }
+ return $revision;
+ }
+}
+
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$