/WebSVN/listing.php
1,8 → 1,6
<?php
# vim:et:ts=3:sts=3:sw=3:fdm=marker:
 
// WebSVN - Subversion repository viewing via the web using PHP
// Copyright © 2004-2006 Tim Armes, Matt Sicker
// Copyright (C) 2004-2006 Tim Armes
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
11,12 → 9,12
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// --
//
24,446 → 22,621
//
// Show the listing for the given repository/path/revision
 
require_once("include/setup.inc");
require_once("include/svnlook.inc");
require_once("include/utils.inc");
require_once("include/template.inc");
require_once("include/bugtraq.inc");
require_once 'include/setup.php';
require_once 'include/svnlook.php';
require_once 'include/utils.php';
require_once 'include/template.php';
require_once 'include/bugtraq.php';
 
function removeURLSeparator($url)
{
return preg_replace('#(\?|&(amp;)?)$#', '', $url);
return preg_replace('#(\?|&(amp;)?)$#', '', $url);
}
 
function fileLink($path, $file, $returnjoin = false)
function urlForPath($fullpath, $passRevString)
{
global $rep, $passrev, $showchanged, $config;
if ($path == "" || $path{0} != "/")
$ppath = "/".$path;
else
$ppath = $path;
global $config, $rep;
 
if ($ppath{strlen($ppath)-1} != "/")
$ppath .= "/";
if ($file{0} == "/")
$pfile = substr($file, 1);
else
$pfile = $file;
$isDir = $fullpath[strlen($fullpath) - 1] == '/';
 
if ($returnjoin)
return $ppath.$pfile;
if ($isDir)
{
if ($config->treeView)
{
$url = $config->getURL($rep, $fullpath, 'dir').$passRevString;
$id = anchorForPath($fullpath);
$url .= '#'.$id.'" id="'.$id;
}
else
{
$url = $config->getURL($rep, $fullpath, 'dir').$passRevString;
}
}
else
{
$url = $config->getURL($rep, $fullpath, 'file').$passRevString;
}
return removeURLSeparator($url);
}
 
$isDir = $pfile{strlen($pfile) - 1} == "/";
if ($passrev) $passrevstr = "rev=$passrev&amp;"; else $passrevstr = "";
if ($showchanged) $showchangedstr = "sc=$showchanged"; else $showchangedstr = "";
function showDirFiles($svnrep, $subs, $level, $limit, $rev, $peg, $listing, $index, $treeview = true)
{
global $config, $lang, $rep, $passrev, $peg, $passRevString;
 
if ($isDir)
{
$url = $config->getURL($rep, $ppath.$pfile, "dir");
$path = '';
 
// XHTML doesn't allow slashes in IDs ~J
$id = str_replace('/', '_', $ppath.$pfile);
$url = "<a id='$id' href=\"${url}$passrevstr$showchangedstr";
if (!$treeview)
{
$level = $limit;
}
 
$url = removeURLSeparator($url);
if ($config->treeView) $url .= "#$id";
$url .= "\">$pfile</a>";
}
else
{
$url = $config->getURL($rep, $ppath.$pfile, "file");
$url .= $passrevstr.$showchangedstr;
$url = removeURLSeparator($url);
$url = "<a href=\"${url}\">$pfile</a>";
}
// TODO: Fix node links to use the path and number of peg revision (if exists)
// This applies to file detail, log, and RSS -- leave the download link as-is
for ($n = 0; $n <= $level; $n++)
{
$path .= $subs[$n].'/';
}
 
return $url;
}
// List each file in the current directory
$loop = 0;
$last_index = 0;
$accessToThisDir = $rep->hasReadAccess($path, false);
 
function fileLinkGetFile($path, $file)
{
global $rep, $passrev, $showchanged, $config;
// If using flat view and not at the root, create a '..' entry at the top.
if (!$treeview && count($subs) > 2)
{
$parentPath = $subs;
unset($parentPath[count($parentPath) - 2]);
$parentPath = implode('/', $parentPath);
 
if ($path == "" || $path{0} != "/")
$ppath = "/".$path;
else
$ppath = $path;
if ($rep->hasReadAccess($parentPath, false))
{
$listvar = &$listing[$index];
$listvar['rowparity'] = $index % 2;
$listvar['path'] = str_replace('%2F', '/', rawurlencode($parentPath));
$listvar['filetype'] = 'dir';
$listvar['filename'] = '..';
$listvar['fileurl'] = urlForPath($parentPath, $passRevString);
$listvar['filelink'] = '<a href="'.$listvar['fileurl'].'">'.$listvar['filename'].'</a>';
$listvar['level'] = 0;
$listvar['node'] = 0; // t-node
$listvar['revision'] = $rev;
$listvar['revurl'] = $config->getURL($rep, $parentPath, 'revision').'rev='.$rev.'&amp;isdir=1';
global $vars;
$listvar['date'] = $vars['date'];
$listvar['age'] = datetimeFormatDuration(time() - strtotime($vars['date']), true, true);
$index++;
}
}
 
if ($ppath{strlen($ppath)-1} != "/")
$ppath .= "/";
$openDir = false;
$logList = $svnrep->getList($path, $rev, $peg);
 
if ($file{0} == "/")
$pfile = substr($file, 1);
else
$pfile = $file;
if (!$logList)
{
return $listing;
}
 
$isDir = $pfile{strlen($pfile) - 1} == "/";
$downloadRevAndPeg = createRevAndPegString($rev, $peg ? $peg : $rev);
foreach ($logList->entries as $entry)
{
$isDir = $entry->isdir;
if (!$isDir && $level != $limit)
{
continue; // Skip any files outside the current directory
}
$file = $entry->file;
$isDirString = ($isDir) ? 'isdir=1&amp;' : '';
 
if (!$isDir)
{
$url = $config->getURL($rep, $ppath.$pfile, "file");
$url = removeURLSeparator($url);
$url = "<a href=\"${url}&getfile\">Get</a>";
}
// Only list files/directories that are not designated as off-limits
$access = ($isDir) ? $rep->hasReadAccess($path.$file, false)
: $accessToThisDir;
 
return $url;
if (!$access)
{
continue;
}
 
$listvar = &$listing[$index];
$listvar['rowparity'] = $index % 2;
 
if ($isDir)
{
$openDir = isset($subs[$level + 1]) && (!strcmp($subs[$level + 1].'/', $file) || !strcmp($subs[$level + 1], $file));
$listvar['filetype'] = ($openDir) ? 'diropen' : 'dir';
}
else
{
$openDir = false;
$listvar['filetype'] = strtolower(strrchr($file, '.'));
}
 
$listvar['isDir'] = $isDir;
$listvar['openDir'] = $openDir;
$listvar['level'] = ($treeview) ? $level : 0;
$listvar['node'] = 0; // t-node
$listvar['path'] = str_replace('%2F', '/', rawurlencode($path.$file));
$listvar['filename'] = escape($file);
 
if ($isDir)
{
$listvar['fileurl'] = urlForPath($path.$file, $passRevString);
}
else
{
$listvar['fileurl'] = urlForPath($path.$file, createDifferentRevAndPegString($passrev, $peg));
}
 
$listvar['filelink'] = '<a href="'.$listvar['fileurl'].'">'.$listvar['filename'].'</a>';
 
if ($isDir)
{
$listvar['logurl'] = $config->getURL($rep, $path.$file, 'log').$isDirString.$passRevString;
}
else
{
$listvar['logurl'] = $config->getURL($rep, $path.$file, 'log').$isDirString.createDifferentRevAndPegString($passrev, $peg);
}
 
if ($treeview)
{
$listvar['compare_box'] = '<input type="checkbox" name="compare[]" value="'.escape($path.$file).'@'.$passrev.'" onclick="enforceOnlyTwoChecked(this)" />';
}
 
if ($config->showLastModInListing())
{
$listvar['committime'] = $entry->committime;
$listvar['revision'] = $entry->rev;
$listvar['author'] = $entry->author;
$listvar['age'] = $entry->age;
$listvar['date'] = $entry->date;
$listvar['revurl'] = $config->getURL($rep, $path.$file, 'revision').$isDirString.createRevAndPegString($entry->rev, $peg ? $peg : $rev);
}
 
if ($rep->isDownloadAllowed($path.$file))
{
$downloadurl = $config->getURL($rep, $path.$file, 'dl').$isDirString.$downloadRevAndPeg;
 
if ($isDir)
{
$listvar['downloadurl'] = $downloadurl;
$listvar['downloadplainurl'] = '';
}
else
{
$listvar['downloadplainurl'] = $downloadurl;
$listvar['downloadurl'] = '';
}
}
else
{
$listvar['downloadplainurl'] = '';
$listvar['downloadurl'] = '';
}
 
if ($rep->isRssEnabled())
{
// RSS should always point to the latest revision, so don't include rev
$listvar['rssurl'] = $config->getURL($rep, $path.$file, 'rss').$isDirString.createRevAndPegString('', $peg);
}
 
$loop++;
$index++;
$last_index = $index;
 
if ($isDir && ($level != $limit))
{
// @todo remove the alternate check with htmlentities when assured that there are not side effects
if (isset($subs[$level + 1]) && (!strcmp($subs[$level + 1].'/', $file) || !strcmp(htmlentities($subs[$level + 1], ENT_QUOTES).'/', htmlentities($file))))
{
$listing = showDirFiles($svnrep, $subs, $level + 1, $limit, $rev, $peg, $listing, $index);
$index = count($listing);
}
}
}
 
// For an expanded tree, give the last entry an "L" node to close the grouping
if ($treeview && $last_index != 0)
{
$listing[$last_index - 1]['node'] = 1; // l-node
}
 
return $listing;
}
 
function showDirFiles($svnrep, $subs, $level, $limit, $rev, $listing, $index, $treeview = true)
function showAllDirFiles($svnrep, $path, $rev, $peg, $listing, $index, $treeView = true)
{
global $rep, $passrev, $showchanged, $config, $lang;
global $config, $lang, $rep, $passrev, $peg, $passRevString;
 
$path = "";
// List each file in the current directory
$loop = 0;
$last_index = 0;
$accessToThisDir = $rep->hasReadAccess($path, false);
 
// Explicitly requested file as attachment
if (isset($_REQUEST['getfile']))
{
$base = basename($path);
// If using flat view and not at the root, create a '..' entry at the top.
if (!$treeView && count($subs) > 2)
{
$parentPath = $subs;
unset($parentPath[count($parentPath) - 2]);
$parentPath = implode('/', $parentPath);
 
header("Content-Type: application/octet-stream");
header("Content-Length: $size");
header("Content-Disposition: inline; filename=".urlencode($base));
if ($rep->hasReadAccess($parentPath, false))
{
$listvar = &$listing[$index];
$listvar['rowparity'] = $index % 2;
$listvar['path'] = str_replace('%2F', '/', rawurlencode($parentPath));
$listvar['filetype'] = 'dir';
$listvar['filename'] = '..';
$listvar['fileurl'] = urlForPath($parentPath, $passRevString);
$listvar['filelink'] = '<a href="'.$listvar['fileurl'].'">'.$listvar['filename'].'</a>';
$listvar['level'] = 0;
$listvar['node'] = 0; // t-node
$listvar['revision'] = $rev;
$listvar['revurl'] = $config->getURL($rep, $parentPath, 'revision').'rev='.$rev.'&amp;isdir=1';
global $vars;
$listvar['date'] = $vars['date'];
$listvar['age'] = datetimeFormatDuration(time() - strtotime($vars['date']), true, true);
$index++;
}
}
 
$svnrep->getFileContents($path, "", $rev);
$openDir = false;
$logList = $svnrep->getList($path, $rev, $peg);
 
exit;
}
if (!$logList)
{
return $listing;
}
 
if (!$treeview)
$level = $limit;
$downloadRevAndPeg = createRevAndPegString($rev, $peg ? $peg : $rev);
 
for ($n = 0; $n <= $level; $n++)
{
$path .= $subs[$n]."/";
}
foreach ($logList->entries as $entry)
{
$isDir = $entry->isdir;
 
$contents = $svnrep->dirContents($path, $rev);
$file = $entry->file;
$isDirString = ($isDir) ? 'isdir=1&amp;' : '';
 
// List each file in the current directory
$loop = 0;
$last_index = 0;
$openDir = false;
$fullaccess = $rep->hasReadAccess($path, false);
foreach($contents as $file)
{
$isDir = ($file{strlen($file) - 1} == "/"?1:0);
$access = false;
// Only list files/directories that are not designated as off-limits
$access = ($isDir) ? $rep->hasReadAccess($path.$file, false)
: $accessToThisDir;
 
if ($isDir)
{
if ($rep->hasReadAccess($path.$file, true))
{
$access = true;
$openDir = (!strcmp($subs[$level+1]."/", $file) || !strcmp($subs[$level+1], $file));
if (!$access)
{
continue;
}
 
if ($openDir)
$listing[$index]["filetype"] = "diropen";
else
$listing[$index]["filetype"] = "dir";
$listvar = &$listing[$index];
$listvar['rowparity'] = $index % 2;
 
if ($rep->isDownloadAllowed($path.$file))
{
$dlurl = $config->getURL($rep, $path.$file, "dl");
$listing[$index]["fileviewdllink"] = "<a href=\"${dlurl}rev=$passrev&amp;isdir=1\">${lang["TARBALL"]}</a>";
}
else
$listing[$index]["fileviewdllink"] = "&nbsp;";
}
}
else
{
if ($fullaccess)
{
$access = true;
if ($level != $limit)
{
// List directories only, skip all files
continue;
}
$listing[$index]["fileviewdllink"] = "&nbsp;";
$listing[$index]["filetype"] = strrchr($file, ".");
}
}
if ($isDir)
{
$listvar['filetype'] = 'dir';
$openDir = true;
}
else
{
$listvar['filetype'] = strtolower(strrchr($file, '.'));
$openDir = false;
}
 
if ($access)
{
$listing[$index]["rowparity"] = ($index % 2)?"L1":"L0";
if ($treeview)
$listing[$index]["compare_box"] = "<input type=\"checkbox\" name=\"compare[]\" value=\"".fileLink($path, $file, true)."@$passrev\" onclick=\"checkCB(this)\" />";
else
$listing[$index]["compare_box"] = "";
$listvar['isDir'] = $isDir;
$listvar['openDir'] = $openDir;
$listvar['path'] = str_replace('%2F', '/', rawurlencode($path.$file));
$tempelements = explode('/',$file);
 
if ($openDir)
$listing[$index]["filelink"] = "<b>".fileLink($path, $file)."</b>";
else
$listing[$index]["filelink"] = fileLink($path, $file);
if ($tempelements[count($tempelements)-1] === "")
{
$lastindexfile = count($tempelements)-1 - 1;
$listvar['node'] = $lastindexfile; // t-node
$listvar['level'] = ($treeView) ? $lastindexfile : 0;
$listvar['filename'] = escape($tempelements[$lastindexfile]);
$listvar['classname'] = '';
 
if ($isDir)
$listing[$index]["filelinkgetfile"] = "";
else
$listing[$index]["filelinkgetfile"] = fileLinkGetFile($path, $file);
for ($n = 0; $n < $lastindexfile; ++$n)
{
$listvar['last_i_node'][$n] = false;
$listvar['classname'] = $listvar['classname'].$tempelements[$n].'/';
}
 
// The history command doesn't return with a trailing slash. We need to remember here if the
// file is a directory or not!
$listvar['classname'] = $listvar['classname'].$tempelements[$lastindexfile];
$listvar['last_i_node'][$lastindexfile] = true;
}
else
{
$lastindexfile = count($tempelements)-1;
$listvar['node'] = $lastindexfile; // t-node
$listvar['level'] = ($treeView) ? $lastindexfile : 0;
$listvar['filename'] = escape($tempelements[$lastindexfile]);
$listvar['classname'] = '';
 
$listing[$index]["isDir"] = $isDir;
for ($n=0; $n < $lastindexfile; ++$n)
{
$listvar['last_i_node'][$n] = false;
$listvar['classname'] = $listvar['classname'].$tempelements[$n].'/';
}
 
if ($treeview)
$listing[$index]["level"] = $level;
else
$listing[$index]["level"] = 0;
$listvar['last_i_node'][$lastindexfile] = true;
}
 
$listing[$index]["node"] = 0; // t-node
if ($isDir)
{
$listvar['fileurl'] = urlForPath($path.$file, $passRevString);
}
else
{
$listvar['fileurl'] = urlForPath($path.$file, createDifferentRevAndPegString($passrev, $peg));
}
 
$fileurl = $config->getURL($rep, $path.$file, "log");
$listing[$index]["fileviewloglink"] = "<a href=\"${fileurl}rev=$passrev&amp;sc=$showchanged&amp;isdir=$isDir\">${lang["VIEWLOG"]}</a>";
$listvar['filelink'] = '<a href="'.$listvar['fileurl'].'">'.$listvar['filename'].'</a>';
 
$rssurl = $config->getURL($rep, $path.$file, "rss");
if ($rep->getHideRss())
{
$listing[$index]["rsslink"] = "<a href=\"${rssurl}rev=$passrev&amp;sc=$showchanged&amp;isdir=$isDir\">${lang["RSSFEED"]}</a>";
$listing[$index]["rssanchor"] = "<a href=\"${rssurl}rev=$passrev&amp;sc=$showchanged&amp;isdir=$isDir\">";
}
if ($isDir)
{
$listvar['logurl'] = $config->getURL($rep, $path.$file, 'log').$isDirString.$passRevString;
}
else
{
$listvar['logurl'] = $config->getURL($rep, $path.$file, 'log').$isDirString.createDifferentRevAndPegString($passrev, $peg);
}
 
$index++;
$loop++;
$last_index = $index;
if ($treeView)
{
$listvar['compare_box'] = '<input type="checkbox" name="compare[]" value="'.escape($path.$file).'@'.$passrev.'" onclick="enforceOnlyTwoChecked(this)" />';
}
 
if (($level != $limit) && ($isDir))
{
if (!strcmp($subs[$level + 1]."/", $file))
{
$listing = showDirFiles($svnrep, $subs, $level + 1, $limit, $rev, $listing, $index);
$index = count($listing);
}
}
if ($config->showLastModInListing())
{
$listvar['committime'] = $entry->committime;
$listvar['revision'] = $entry->rev;
$listvar['author'] = $entry->author;
$listvar['age'] = $entry->age;
$listvar['date'] = $entry->date;
$listvar['revurl'] = $config->getURL($rep, $path.$file, 'revision').$isDirString.createRevAndPegString($entry->rev, $peg ? $peg : $rev);
}
 
}
}
if ($rep->isDownloadAllowed($path.$file))
{
$downloadurl = $config->getURL($rep, $path.$file, 'dl').$isDirString.$downloadRevAndPeg;
 
if ($last_index != 0 && $treeview)
{
$listing[$last_index - 1]["node"] = 1; // l-node
}
if ($isDir)
{
$listvar['downloadurl'] = $downloadurl;
$listvar['downloadplainurl'] = '';
}
else
{
$listvar['downloadplainurl'] = $downloadurl;
$listvar['downloadurl'] = '';
}
}
else
{
$listvar['downloadplainurl'] = '';
$listvar['downloadurl'] = '';
}
 
return $listing;
if ($rep->isRssEnabled())
{
// RSS should always point to the latest revision, so don't include rev
$listvar['rssurl'] = $config->getURL($rep, $path.$file, 'rss').$isDirString.createRevAndPegString('', $peg);
}
 
$loop++;
$index++;
$last_index = $index;
}
 
return $listing;
}
 
function showTreeDir($svnrep, $path, $rev, $listing)
function showTreeDir($svnrep, $path, $rev, $peg, $listing)
{
global $vars, $config;
global $vars, $config;
 
$subs = explode("/", $path);
if ($config->showLoadAllRepos())
{
$vars['compare_box'] = ''; // Set blank once in case tree view is not enabled.
return showAllDirFiles($svnrep, $path, $rev, $peg, $listing, 0, $config->treeView);
}
 
// For directory, the last element in the subs is empty.
// For file, the last element in the subs is the file name.
// Therefore, it is always count($subs) - 2
$limit = count($subs) - 2;
$subs = explode('/', $path);
 
for ($n = 0; $n < $limit; $n++)
{
$vars["last_i_node"][$n] = FALSE;
}
// The last element in "$subs" is empty for directories, some file name for files, but ALWAYS
// exists as an additional element. Hence, "-2" is necessary.
//
// Additionally, level and limit are conceptually different things, first to e.g. start access
// checks FROM, latter to process UNTIL. So don't merge those values too easily, especially as
// both values needed to be different in some environments in the past for some unkown reason.
//
// https://github.com/websvnphp/websvn/issues/146#issuecomment-913353366
$limit = count($subs) - 2;
$level = $limit;
$level = $level <= 0 ? 0 : $level;
 
return showDirFiles($svnrep, $subs, 0, $limit, $rev, $listing, 0, $config->treeView);
for ($n = 0; $n < $limit; $n++)
{
$vars['last_i_node'][$n] = false;
}
 
$vars['compare_box'] = ''; // Set blank once in case tree view is not enabled.
return showDirFiles($svnrep, $subs, $level, $limit, $rev, $peg, $listing, 0, $config->treeView);
}
 
// Make sure that we have a repository
if (!isset($rep))
if (!$rep)
{
echo $lang["NOREP"];
exit;
renderTemplate404('directory','NOREP');
}
 
$svnrep = new SVNRepository($rep);
 
// Revision info to pass along chain
$passrev = $rev;
if (!empty($rev))
{
$info = $svnrep->getInfo($path, $rev, $peg);
 
// Get the directory contents of the given revision, or HEAD if not defined
$contents = $svnrep->dirContents($path, @$rev);
if ($info)
{
$path = $info->path;
$peg = (int)$info->rev;
}
}
 
// If there's no revision info, go to the lastest revision for this path
$history = $svnrep->getLog($path, "", "", false);
$history = $svnrep->getLog($path, 'HEAD', 1, false, 2, ($path == '/') ? '' : $peg);
 
if (!empty($history->entries[0]))
$youngest = $history->entries[0]->rev;
else
$youngest = -1;
if (!$history)
{
unset($vars['error']);
$history = $svnrep->getLog($path, '', '', false, 2, ($path == '/') ? '' : $peg);
 
if (!$history)
{
renderTemplate404('directory','NOPATH');
}
}
 
$youngest = ($history && isset($history->entries[0])) ? $history->entries[0]->rev : 0;
 
// Unless otherwise specified, we get the log details of the latest change
if (empty($rev))
$logrev = $youngest;
else
$logrev = $rev;
$lastChangedRev = ($passrev) ? $passrev : $youngest;
 
if ($logrev != $youngest)
if ($lastChangedRev != $youngest)
{
$logEntry = $svnrep->getLog($path, $logrev, $logrev, false);
$logEntry = $logEntry->entries[0];
$history = $svnrep->getLog($path, $lastChangedRev, 1, false, 2, $peg);
}
else
$logEntry = $history->entries[0];
 
$headlog = $svnrep->getLog("/", "", "", true, 1);
$headrev = $headlog->entries[0]->rev;
$logEntry = ($history && isset($history->entries[0])) ? $history->entries[0] : 0;
 
$headlog = $svnrep->getLog('/', '', '', true, 1);
$headrev = ($headlog && isset($headlog->entries[0])) ? $headlog->entries[0]->rev : 0;
 
// If we're not looking at a specific revision, get the HEAD revision number
// (the revision of the rest of the tree display)
 
if (empty($rev))
{
$rev = $headrev;
$rev = $headrev;
}
 
if ($path == "" || $path{0} != "/")
$ppath = "/".$path;
if ($path == '' || $path[0] != '/')
{
$ppath = '/'.$path;
}
else
$ppath = $path;
{
$ppath = $path;
}
 
$vars["repname"] = $rep->getDisplayName();
createPathLinks($rep, $ppath, $passrev, $peg);
$passRevString = createRevAndPegString($passrev, $peg);
$isDirString = 'isdir=1&amp;';
 
$dirurl = $config->getURL($rep, $path, "dir");
$logurl = $config->getURL($rep, $path, "log");
$rssurl = $config->getURL($rep, $path, "rss");
$dlurl = $config->getURL($rep, $path, "dl");
$compurl = $config->getURL($rep, "/", "comp");
$revurl = $config->getURL($rep, $path != '/' ? $path : '', 'dir');
$revurlSuffix = $path != '/' ? '#'.anchorForPath($path) : '';
 
if ($passrev != 0 && $passrev != $headrev && $youngest != -1)
$vars["goyoungestlink"] = "<a href=\"${dirurl}opt=dir&amp;sc=1\">${lang["GOYOUNGEST"]}</a>";
else
$vars["goyoungestlink"] = "";
if ($rev < $youngest)
{
if ($path == '/')
{
$vars['goyoungesturl'] = $config->getURL($rep, '', 'dir');
}
else
{
$vars['goyoungesturl'] = $config->getURL($rep, $path, 'dir').createRevAndPegString($youngest, $peg ? $peg: $rev).$revurlSuffix;
}
 
$bugtraq = new Bugtraq($rep, $svnrep, $ppath);
$vars['goyoungestlink'] = '<a href="'.$vars['goyoungesturl'].'"'.($youngest ? ' title="'.$lang['REV'].' '.$youngest.'"' : '').'>'.$lang['GOYOUNGEST'].'</a>';
 
$vars["action"] = "";
$vars["rev"] = $rev;
$vars["path"] = $ppath;
$vars["lastchangedrev"] = $logrev;
$vars["date"] = $logEntry->date;
$vars["author"] = $logEntry->author;
$vars["log"] = nl2br($bugtraq->replaceIDs(create_anchors($logEntry->msg)));
$history2 = $svnrep->getLog($path, $rev, $youngest, true, 2, $peg);
 
if (!$showchanged)
{
$vars["showchangeslink"] = "<a href=\"${dirurl}rev=$passrev&amp;sc=1\">${lang["SHOWCHANGED"]}</a>";
$vars["hidechangeslink"] = "";
if (isset($history2->entries[1]))
{
$nextRev = $history2->entries[1]->rev;
if ($nextRev != $youngest)
{
$vars['nextrev'] = $nextRev;
$vars['nextrevurl'] = $revurl.createRevAndPegString($nextRev, $peg).$revurlSuffix;
}
}
 
$vars["hidechanges"] = true;
$vars["showchanges"] = false;
unset($vars['error']);
}
else
 
if (isset($history->entries[1]))
{
$vars["showchangeslink"] = "";
$changes = $logEntry->mods;
$firstAdded = true;
$firstModded = true;
$firstDeleted = true;
$prevRev = $history->entries[1]->rev;
$prevPath = $history->entries[1]->path;
$vars['prevrev'] = $prevRev;
$vars['prevrevurl'] = $revurl.createRevAndPegString($prevRev, $peg).$revurlSuffix;
}
 
$vars["newfilesbr"] = "";
$vars["newfiles"] = "";
$vars["changedfilesbr"] = "";
$vars["changedfiles"] = "";
$vars["deletedfilesbr"] = "";
$vars["deletedfiles"] = "";
$bugtraq = new Bugtraq($rep, $svnrep, $ppath);
 
foreach ($changes as $file)
{
switch ($file->action)
{
case "A":
if (!$firstAdded) $vars["newfilesbr"] .= "<br />";
$firstAdded = false;
$vars["newfilesbr"] .= fileLink("", $file->path);
$vars["newfiles"] .= " ".fileLink("", $file->path);
break;
$vars['action'] = '';
$vars['rev'] = $rev;
$vars['peg'] = $peg;
$vars['path'] = str_replace('%2F', '/', rawurlencode($ppath));
$vars['safepath'] = escape($ppath);
$vars['lastchangedrev'] = $lastChangedRev;
 
case "M":
if (!$firstModded) $vars["changedfilesbr"] .= "<br />";
$firstModded = false;
$vars["changedfilesbr"] .= fileLink("", $file->path);
$vars["changedfiles"] .= " ".fileLink("", $file->path);
break;
if ($logEntry)
{
$vars['date'] = $logEntry->date;
$vars['age'] = datetimeFormatDuration(time() - strtotime($logEntry->date));
$vars['author'] = $logEntry->author;
$vars['log'] = nl2br($bugtraq->replaceIDs(create_anchors(xml_entities($logEntry->msg))));
}
 
case "D":
if (!$firstDeleted) $vars["deletedfilesbr"] .= "<br />";
$firstDeleted = false;
$vars["deletedfilesbr"] .= $file->path;
$vars["deletedfiles"] .= " ".$file->path;
break;
}
}
$vars['revurl'] = $config->getURL($rep, ($path == '/' ? '' : $path), 'revision').$isDirString.$passRevString;
$vars['revlink'] = '<a href="'.$vars['revurl'].'">'.$lang['LASTMOD'].'</a>';
 
$vars["hidechangeslink"] = "<a href=\"${dirurl}rev=$passrev&amp;sc=0\">${lang["HIDECHANGED"]}</a>";
if ($history && count($history->entries) > 1)
{
$vars['compareurl'] = $config->getURL($rep, '', 'comp').'compare[]='.rawurlencode($history->entries[1]->path).'@'.$history->entries[1]->rev. '&amp;compare[]='.rawurlencode($history->entries[0]->path).'@'.$history->entries[0]->rev;
$vars['comparelink'] = '<a href="'.$vars['compareurl'].'">'.$lang['DIFFPREV'].'</a>';
}
 
$vars["hidechanges"] = false;
$vars["showchanges"] = true;
$vars['logurl'] = $config->getURL($rep, $path, 'log').$isDirString.$passRevString;
$vars['loglink'] = '<a href="'.$vars['logurl'].'">'.$lang['VIEWLOG'].'</a>';
 
if ($rep->isRssEnabled())
{
$vars['rssurl'] = $config->getURL($rep, $path, 'rss').$isDirString.createRevAndPegString('', $peg);
$vars['rsslink'] = '<a href="'.$vars['rssurl'].'">'.$lang['RSSFEED'].'</a>';
}
 
createDirLinks($rep, $ppath, $passrev, $showchanged);
$vars["curdirloglink"] = "<a href=\"${logurl}rev=$passrev&amp;sc=$showchanged&amp;isdir=1\">${lang["VIEWLOG"]}</a>";
// Set up the tarball link
$subs = explode('/', $path);
$level = count($subs) - 2;
 
if ($rev != $headrev)
if ($rep->isDownloadAllowed($path) && !isset($vars['warning']))
{
$history = $svnrep->getLog($path, $rev, "", false);
$vars['downloadurl'] = $config->getURL($rep, $path, 'dl').$isDirString.$passRevString;
}
 
if (isset($history->entries[1]->rev))
$vars['compare_form'] = '<form method="get" action="'.$config->getURL($rep, '', 'comp').'" id="compare">';
 
if ($config->multiViews)
{
$vars["curdircomplink"] = "<a href=\"${compurl}compare[]=".
urlencode($history->entries[1]->path)."@".$history->entries[1]->rev.
"&amp;compare[]=".urlencode($history->entries[0]->path)."@".$history->entries[0]->rev.
"\">${lang["DIFFPREV"]}</a>";
$vars['compare_form'] .= '<input type="hidden" name="op" value="comp"/>';
}
else
{
$vars["curdircomplink"] = "";
}
 
if ($rep->getHideRss())
{
$vars["curdirrsslink"] = "<a href=\"${rssurl}rev=$passrev&amp;sc=$showchanged&amp;isdir=1\">${lang["RSSFEED"]}</a>";
$vars["curdirrsshref"] = "${rssurl}rev=$passrev&amp;sc=$showchanged&amp;isdir=1";
$vars["curdirrssanchor"] = "<a href=\"${rssurl}rev=$passrev&amp;sc=$showchanged&amp;isdir=1\">";
$vars['compare_form'] .= '<input type="hidden" name="repname" value="'.$repname.'" />';
}
 
// Set up the tarball link
$vars['compare_submit'] = '<input type="submit" value="'.$lang['COMPAREPATHS'].'" />';
$vars['compare_endform'] = '</form>';
 
$subs = explode("/", $path);
$level = count($subs) - 2;
if ($rep->isDownloadAllowed($path))
$vars["curdirdllink"] = "<a href=\"${dlurl}rev=$passrev&amp;isdir=1\">${lang["TARBALL"]}</a>";
else
$vars["curdirdllink"] = "";
$url = $config->getURL($rep, "/", "comp");
$vars['showlastmod'] = $config->showLastModInListing();
 
$vars["compare_form"] = "<form action=\"$url\" method=\"post\" name=\"compareform\">";
$vars["compare_submit"] = "<input name=\"comparesubmit\" type=\"submit\" value=\"${lang["COMPAREPATHS"]}\" />";
$vars["compare_endform"] = "<input type=\"hidden\" name=\"op\" value=\"comp\" /><input type=\"hidden\" name=\"sc\" value=\"$showchanged\" /></form>";
$vars['loadalldir'] = $config->showLoadAllRepos();
$listing = showTreeDir($svnrep, $path, $rev, $peg, array());
 
$listing = array();
$listing = showTreeDir($svnrep, $path, $rev, $listing);
if (!$rep->hasReadAccess($path))
{
$vars['error'] = $lang['NOACCESS'];
sendHeaderForbidden();
}
 
$vars["version"] = $version;
 
if (!$rep->hasReadAccess($path, true))
$vars["noaccess"] = true;
 
if (!$rep->hasReadAccess($path, false))
$vars["restricted"] = true;
 
parseTemplate($rep->getTemplatePath()."header.tmpl", $vars, $listing);
parseTemplate($rep->getTemplatePath()."directory.tmpl", $vars, $listing);
parseTemplate($rep->getTemplatePath()."footer.tmpl", $vars, $listing);
 
?>
$vars['restricted'] = !$rep->hasReadAccess($path, false);
renderTemplate('directory', $path);