= 2)
$svninfo[$l[0]] = $l[1];
}
return $svninfo;
}
### Create temporary directory name
function tempdir($dir, $prefix='', $mode=0700) {
if (substr($dir, -1) != '/') $dir .= '/';
do $path = $dir.$prefix.mt_rand(0, 9999999);
while (!mkdir($path, $mode));
return $path;
}
if (empty($_REQUEST['path'])) $_REQUEST['path'] = '';
if (empty($_REQUEST['to'])) $_REQUEST['to'] = 'html';
### Convert local paths
$cwd = getcwd();
$svnbase = strtr($svn, ":/", "--");
$svnpath = "$cwd/$svnbase";
#mkdir("$cwd/.subversion");
$path = "$svnpath/$_REQUEST[path]";
### Check out from SVN if required
if (!is_dir($svnpath))
system("svn -q --config-dir $cwd/.subversion co $svn $svnpath 2>&1");
if (!is_dir($svnpath))
print "Error checking out subversion.
";
### Update from SVN always
system("svn -q --config-dir $cwd/.subversion up $path 2>&1");
### Show directory index if directory
if (is_dir($path)) {
$svninfo = svn_info($svnpath);
?>
$output"; } @rmdir($tempdir); } elseif ($_REQUEST['to'] == 'odt') { $tempdir = tempdir('/tmp', 'wascii-'); $output = system("/usr/bin/a2x -f odt --icons --icons-dir=../icons/ -d article -D $tempdir/ $path 2>&1"); $tempbase = basename($path, ".txt").".odt"; $tempfile = "$tempdir/$tempbase"; if (is_file($tempfile)) { header("Content-type: application/vnd.oasis.opendocument.text"); header("Content-Disposition: attachment; filename=\"$tempbase\""); readfile($tempfile); @unlink($tempfile); } else { print "Error: File could not be converted. Possibly syntax error.
$output"; } @rmdir($tempdir); } else { passthru("asciidoc -b xhtml11 -a toc -a toclevels=2 -a icons -a iconsdir=$script_dir/icons/ -d article -o- $path"); } } elseif (is_file($path) and preg_match('/\.(htm|html)$/', $path)) { readfile($path); } elseif (is_file($path) and preg_match('/\.pdf$/', $path)) { $tempbase = basename($path); header("Content-type: application/pdf"); header("Content-Disposition: attachment; filename=\"$tempbase\""); readfile($path); } elseif (is_file($path) and preg_match('/\.odt$/', $path)) { $tempbase = basename($path); header("Content-type: application/vnd.oasis.opendocument.text"); header("Content-Disposition: attachment; filename=\"$tempbase\""); readfile($path); } elseif (is_file($path)) { print "File '$_REQUEST[path]' can not be displayed."; } elseif (is_dir($path)) { print "Directory '$_REQUEST[path]/' is missing."; } else { print "Unknown error."; } ?>