jablonka.czprosek.czf

websvn

Subversion Repositories:
[/] [include/] [configclass.php] - Diff between revs 1 and 3

Show entire file Ignore whitespace

Rev 1 Rev 3
Line 91... Line 91...
   
return; return;
} }
   
// }}} // }}}
   
  // A Repository parent path configuration class
   
  class ParentPath {
  // {{{ Properties
   
  var $path;
  var $group;
  var $pattern;
  var $skipAlreadyAdded;
   
  // }}}
   
  // {{{ __construct($path, [$group, [$pattern, [$skipAlreadyAdded]]])
  function ParentPath($path, $group = null, $pattern = false, $skipAlreadyAdded = true) {
  $this->path = $path;
  $this->group = $group;
  $this->pattern = $pattern;
  $this->skipAlreadyAdded = $skipAlreadyAdded;
  }
  // }}}
   
  // {{{ findRepository($name)
  // look for a repository with $name
  function &findRepository($name) {
  global $config;
  if ($this->group != null) {
  $prefix = $this->group.'.';
  if (substr($name, 0, strlen($prefix)) == $prefix) {
  $name = substr($name, strlen($prefix));
  } else {
  $null = null;
  return $null;
  }
  }
  if ($handle = @opendir($this->path)) {
  // is there a directory named $name?
  $fullpath = $this->path.DIRECTORY_SEPARATOR.$name;
  if (is_dir($fullpath) && is_readable($fullpath)) {
  // And that contains a db directory (in an attempt to not include non svn repositories.
  $dbfullpath = $fullpath.DIRECTORY_SEPARATOR.'db';
  if (is_dir($dbfullpath) && is_readable($dbfullpath)) {
  // And matches the pattern if specified
  if ($this->pattern === false || preg_match($this->pattern, $name)) {
  $url = 'file:///'.$fullpath;
  $url = str_replace(DIRECTORY_SEPARATOR, '/', $url);
  if ($url{strlen($url) - 1} == "/") {
  $url = substr($url, 0, -1);
  }
   
  if (!in_array($url, $config->_excluded, true)) {
  $rep = new Repository($name, $name, $url, $this->group, null, null);
  return $rep;
  }
  }
  }
  }
  closedir($handle);
  }
  $null = null;
  return $null;
  }
  // }}}
   
  // {{{ getRepositories()
  // return all repositories in the parent path matching pattern
  function &getRepositories() {
  $repos = array();
  if ($handle = @opendir($this->path)) {
  // For each file...
  while (false !== ($name = readdir($handle))) {
  $fullpath = $this->path.DIRECTORY_SEPARATOR.$name;
  if ($name{0} != '.' && is_dir($fullpath) && is_readable($fullpath)) {
  // And that contains a db directory (in an attempt to not include non svn repositories.
  $dbfullpath = $fullpath.DIRECTORY_SEPARATOR.'db';
  if (is_dir($dbfullpath) && is_readable($dbfullpath)) {
  // And matches the pattern if specified
  if ($this->pattern === false || preg_match($this->pattern, $name)) {
  $url = 'file:///'.$fullpath;
  $url = str_replace(DIRECTORY_SEPARATOR, '/', $url);
  if ($url{strlen($url) - 1} == "/") {
  $url = substr($url, 0, -1);
  }
   
  $repos[] = new Repository($name, $name, $url, $this->group, null, null);
  }
  }
  }
  }
  closedir($handle);
  }
   
   
  // Sort the repositories into alphabetical order
  if (!empty($repos)) {
  usort($repos, "cmpReps");
  }
   
  return $repos;
  }
  // }}}
   
  // {{{ getSkipAlreadyAdded()
  // Return if we should skip already added repos for this parent path.
  function getSkipAlreadyAdded() {
  return $this->skipAlreadyAdded;
  }
  // }}}
  }
   
// A Repository configuration class // A Repository configuration class
   
class Repository { class Repository {
// {{{ Properties // {{{ Properties
   
var $name; var $name;
var $svnName; var $svnName;
var $path; var $path;
  var $subpath;
var $group; var $group;
var $username; var $username;
var $password; var $password;
   
// Local configuration options must start off unset // Local configuration options must start off unset
Line 123... Line 233...
   
// }}} // }}}
   
// {{{ __construct($name, $svnName, $path, [$group, [$username, [$password]]]) // {{{ __construct($name, $svnName, $path, [$group, [$username, [$password]]])
   
function Repository($name, $svnName, $path, $group = NULL, $username = NULL, $password = NULL) { function Repository($name, $svnName, $path, $group = NULL, $username = NULL, $password = NULL, $subpath = NULL) {
$this->name = $name; $this->name = $name;
$this->svnName = $svnName; $this->svnName = $svnName;
$this->path = $path; $this->path = $path;
  $this->subpath = $subpath;
$this->group = $group; $this->group = $group;
$this->username = $username; $this->username = $username;
$this->password = $password; $this->password = $password;
} }
   
Line 451... Line 562...
// {{{ Properties // {{{ Properties
   
// Tool path locations // Tool path locations
   
var $svnlook = "svnlook"; var $svnlook = "svnlook";
  var $_commandPath = "";
  var $_configPath = "/tmp";
var $svn = "svn --non-interactive --config-dir /tmp"; var $svn = "svn --non-interactive --config-dir /tmp";
var $svn_noparams = "svn --config-dir /tmp"; var $svn_noparams = "svn --config-dir /tmp";
var $diff = "diff"; var $diff = "diff";
var $enscript ="enscript -q"; var $enscript ="enscript -q";
var $sed = "sed"; var $sed = "sed";
var $gzip = "gzip"; var $gzip = "gzip";
var $tar = "tar"; var $tar = "tar";
var $touch = "touch"; var $zip = "zip";
   
  // different modes for file and folder download
   
  var $defaultFileDlMode = "plain";
  var $defaultFolderDlMode = "gzip";
   
  var $validFileDlModes = array( 'gzip', 'zip', 'plain' );
  var $validFolderDlModes = array( 'gzip', 'zip' );
   
// Other configuration items // Other configuration items
   
var $treeView = true; var $treeView = true;
var $flatIndex = true; var $flatIndex = true;
var $openTree = false; var $openTree = false;
  var $alphabetic = false;
var $showLastMod = true; var $showLastMod = true;
  var $showAgeInsteadOfDate = true;
var $_showRepositorySelectionForm = true; var $_showRepositorySelectionForm = true;
var $serverIsWindows = false; var $serverIsWindows = false;
var $multiViews = false; var $multiViews = false;
var $useEnscript = false; var $useEnscript = false;
var $useGeshi = false; var $useGeshi = false;
  var $inlineMimeTypes = array();
var $allowDownload = false; var $allowDownload = false;
var $tarballTmpDir = 'temp'; var $tarballTmpDir = 'temp';
var $minDownloadLevel = 0; var $minDownloadLevel = 0;
var $allowedExceptions = array(); var $allowedExceptions = array();
var $disallowedExceptions = array(); var $disallowedExceptions = array();
var $rss = true; var $rss = true;
var $spaces = 8; var $spaces = 8;
var $bugtraq = false; var $bugtraq = false;
var $auth = ""; var $auth = "";
   
var $templatePath = "./templates/Standard/"; var $templatePath = "./templates/calm/";
   
var $ignoreSvnMimeTypes = false; var $ignoreSvnMimeTypes = false;
var $ignoreWebSVNContentTypes = false; var $ignoreWebSVNContentTypes = false;
   
  var $subversionVersion = "";
var $subversionMajorVersion = ""; var $subversionMajorVersion = "";
var $subversionMinorVersion = ""; var $subversionMinorVersion = "";
   
// Default character encodings // Default character encodings
var $inputEnc = ""; // Encoding of output returned from command line var $inputEnc = ""; // Encoding of output returned from command line
var $contentEnc = ""; // Encoding of repository content var $contentEnc = ""; // Encoding of repository content
var $outputEnc = "UTF-8"; // Encoding of web page. Now forced to UTF-8 var $outputEnc = "UTF-8"; // Encoding of web page. Now forced to UTF-8
   
var $defaultLanguage = 'en'; var $defaultLanguage = 'en';
  var $ignoreAcceptedLanguages = false;
   
var $quote = "'"; var $quote = "'";
var $pathSeparator = ":"; var $pathSeparator = ":";
   
var $_repositories = array(); var $_repositories = array();
   
  var $_parentPaths = array(); // parent paths to load
   
  var $_parentPathsLoaded = false;
   
  var $_excluded = array();
   
// }}} // }}}
   
// {{{ __construct() // {{{ __construct()
   
Line 522... Line 654...
} }
   
$svnName = substr($url, strrpos($url, "/") + 1); $svnName = substr($url, strrpos($url, "/") + 1);
$this->_repositories[] = new Repository($name, $svnName, $url, $group, $username, $password); $this->_repositories[] = new Repository($name, $svnName, $url, $group, $username, $password);
} }
   
  function addRepositorySubpath($name, $url, $subpath, $group = NULL, $username = NULL, $password = NULL) {
  $url = str_replace(DIRECTORY_SEPARATOR, '/', $url);
  $subpath = str_replace(DIRECTORY_SEPARATOR, '/', $subpath);
   
  if ($url{strlen($url) - 1} == '/') {
  $url = substr($url, 0, -1);
  }
   
  $svnName = substr($url, strrpos($url, '/') + 1);
  $this->_repositories[] = new Repository($name, $svnName, $url, $group, $username, $password, $subpath);
  }
   
   
function getRepositories() { function getRepositories() {
  // lazily load parent paths
  if (!$this->_parentPathsLoaded) {
  $this->_parentPathsLoaded = true;
  foreach ($this->_parentPaths as $parentPath) {
  $parentRepos = $parentPath->getRepositories();
  foreach ($parentRepos as $repo) {
  if (!$parentPath->getSkipAlreadyAdded()) {
  $this->_repositories[] = $repo;
  } else {
  // we have to check if we already have a repo with the same svn name
  $duplicate = false;
  if (!empty($this->_repositories)) {
  foreach ($this->_repositories as $knownRepos) {
  if ($knownRepos->svnName == $repo->svnName && $knownRepos->subpath == $repo->subpath) {
  $duplicate = true;
  break;
  }
  }
  }
   
  if (!$duplicate && !in_array($repo->path, $this->_excluded, true)) {
  $this->_repositories[] = $repo;
  }
  }
  }
  }
  }
   
return $this->_repositories; return $this->_repositories;
} }
   
function &findRepository($name) { function &findRepository($name) {
  // first look in the "normal repositories"
foreach ($this->_repositories as $index => $rep) { foreach ($this->_repositories as $index => $rep) {
if (strcmp($rep->getDisplayName(), $name) == 0) { if (strcmp($rep->getDisplayName(), $name) == 0) {
$repref =& $this->_repositories[$index]; $repref =& $this->_repositories[$index];
return $repref; return $repref;
  }
  }
   
  // now if the parent repos have not already been loaded
  // check them
  if (!$this->_parentPathsLoaded) {
  foreach ($this->_parentPaths as $parentPath) {
  $repref =& $parentPath->findRepository($name);
  if ($repref != null) {
  return $repref;
  }
} }
} }
   
print "ERROR: Unable to find repository '".htmlentities($name, ENT_QUOTES, 'UTF-8')."'"; print "ERROR: Unable to find repository '".htmlentities($name, ENT_QUOTES, 'UTF-8')."'";
exit; exit;
Line 601... Line 786...
} }
   
function getUseEnscript() { function getUseEnscript() {
return $this->useEnscript; return $this->useEnscript;
} }
   
  // }}}
   
  // {{{ GeSHi
   
// useGeshi // useGeshi
// //
// Use GeSHi to colourise listings // Use GeSHi to colourise listings
function useGeshi() { function useGeshi() {
$this->useGeshi = true; $this->useGeshi = true;
} }
   
function getUseGeshi() { function getUseGeshi() {
return $this->useGeshi; return $this->useGeshi;
  }
   
  // }}}
   
  // {{{ Inline MIME Types
   
  // inlineMimeTypes
  //
  // Specify MIME types to display inline in WebSVN pages
  function addInlineMimeType($type) {
  if (!in_array($type, $this->inlineMimeTypes)) {
  $this->inlineMimeTypes[] = $type;
  }
  }
   
  function getInlineMimeTypes() {
  return $this->inlineMimeTypes;
} }
   
// }}} // }}}
   
// {{{ RSS // {{{ RSS
Line 742... Line 948...
   
// }}} // }}}
   
// {{{ getUrlParts // {{{ getUrlParts
// //
// Get the Url and Parametes to a path name based on the current config // Get the URL and parameters for a path name based on the current config
   
function getUrlParts($rep, $path, $op) { function getUrlParts($rep, $path, $op) {
$params = array(); $params = array();
   
if ($this->multiViews) { if ($this->multiViews) {
$url = $_SERVER["SCRIPT_NAME"]; $url = $_SERVER["SCRIPT_NAME"];
// Remove the .php if (preg_match('|\.php$|i', $url)) {
if (eregi(".php$", $url)) { // remove the .php extension
// Remove the .php  
$url = substr($url, 0, -4); $url = substr($url, 0, -4);
} }
   
if ($path && $path{0} != "/") $path = "/".$path; if ($path && $path{0} != "/") {
  $path = "/".$path;
  }
   
if ($op == 'index') { if ($op == 'index') {
$url .= '/'; $url .= '/';
} else if (is_object($rep)) { } else if (is_object($rep)) {
$url .= "/".$rep->getDisplayName().str_replace('%2F', '/', rawurlencode($path)); $url .= "/".$rep->getDisplayName().str_replace('%2F', '/', rawurlencode($path));
   
if ($op != "dir" && $op != "file") { if ($op != "dir" && $op != "file") {
$params['op'] = $op; $params['op'] = $op;
} }
} }
   
return array($url, $params);  
   
} else { } else {
switch ($op) { switch ($op) {
case "index": case "index":
$fname = "."; $url = ".";
break; break;
   
case "dir": case "dir":
$fname = "listing.php"; $url = "listing.php";
break; break;
   
case "revision": case "revision":
$fname = "revision.php"; $url = "revision.php";
break; break;
   
case "file": case "file":
$fname = "filedetails.php"; $url = "filedetails.php";
break; break;
   
case "log": case "log":
$fname = "log.php"; $url = "log.php";
break; break;
   
case "diff": case "diff":
$fname = "diff.php"; $url = "diff.php";
break; break;
   
case "blame": case "blame":
$fname = "blame.php"; $url = "blame.php";
break; break;
   
case "form": case "form":
$fname = "form.php"; $url = "form.php";
break; break;
   
case "rss": case "rss":
$fname = "rss.php"; $url = "rss.php";
break; break;
   
case "dl": case "dl":
$fname = "dl.php"; $url = "dl.php";
break; break;
   
case "comp": case "comp":
$fname = "comp.php"; $url = "comp.php";
break; break;
} }
   
if ($rep === -1) { if ($rep !== -1 && $op != 'index') {
$params['path'] = $path;  
} else if ($op != 'index') {  
$params['repname'] = $rep->getDisplayName(); $params['repname'] = $rep->getDisplayName();
  }
  if (!empty($path)) {
$params['path'] = $path; $params['path'] = $path;
} }
   
return array($fname, $params);  
} }
   
  return array($url, $params);
} }
   
// }}} // }}}
   
// {{{ Paths and Commands // {{{ Paths and Commands
Line 845... Line 1050...
$lastchar = substr($path, -1, 1); $lastchar = substr($path, -1, 1);
$isDir = ($lastchar == DIRECTORY_SEPARATOR || $lastchar == '/' || $lastchar == '\\'); $isDir = ($lastchar == DIRECTORY_SEPARATOR || $lastchar == '/' || $lastchar == '\\');
   
if (!$isDir) $path .= DIRECTORY_SEPARATOR; if (!$isDir) $path .= DIRECTORY_SEPARATOR;
   
if (($this->serverIsWindows && !file_exists($path.$name.'.exe')) || (!$this->serverIsWindows && !file_exists($path.$name))) { if (($this->serverIsWindows && !file_exists($path.$name.'.exe')) || (!$this->serverIsWindows && !file_exists($path.$name))) {
echo "Unable to find '$name' tool at location '$path$name'"; echo "Unable to find '$name' tool at location '$path$name'";
exit; exit;
} }
   
// On a windows machine we need to put spaces around the entire command // On a windows machine we need to put spaces around the entire command
Line 861... Line 1066...
} }
} }
   
// Append parameters // Append parameters
if ($params != '') $var .= ' '.$params; if ($params != '') $var .= ' '.$params;
  }
   
  function setConfigPath($path) {
  $this->_configPath = $path;
  $this->updateSVNCommands();
} }
   
// setSVNCommandPath // setSVNCommandPath
// //
// Define the location of the svn and svnlook commands // Define the location of the svn and svnlook commands
   
function setSVNCommandPath($path) { function setSVNCommandPath($path) {
$this->setPath($this->svn, $path, "svn", "--non-interactive --config-dir /tmp"); $this->_commandPath = $path;
$this->setPath($this->svn_noparams, $path, "svn", " --config-dir /tmp"); $this->updateSVNCommands();
$this->setPath($this->svnlook, $path, "svnlook"); }
   
  function updateSVNCommands() {
  $this->setPath($this->svn, $this->_commandPath, "svn", "--non-interactive --config-dir ".$this->_configPath);
  $this->setPath($this->svn_noparams, $this->_commandPath, "svn", " --config-dir ".$this->_configPath);
  $this->setPath($this->svnlook, $this->_commandPath, "svnlook");
} }
   
function getSvnCommand() { function getSvnCommand() {
return $this->svn; return $this->svn;
} }
Line 943... Line 1158...
$this->setPath($this->gzip, $path, "gzip"); $this->setPath($this->gzip, $path, "gzip");
} }
   
function getGzipCommand() { function getGzipCommand() {
return $this->gzip; return $this->gzip;
  }
   
  // setZipPath
  //
  // Define the location of the zip command
  function setZipPath($path) {
  $this->setPath($this->zip, $path, "zip");
  }
   
  function getZipPath() {
  return $this->zip;
  }
   
  // setDefaultFileDlMode
  //
  // Define the default file download mode - one of [gzip, zip, plain]
  function setDefaultFileDlMode($dlmode) {
  if (in_array($dlmode, $this->validFileDlModes)) {
  $this->defaultFileDlMode = $dlmode;
  } else {
  echo 'Setting default file download mode to an invalid value "'.$dlmode.'"';
  exit;
  }
  }
   
  function getDefaultFileDlMode() {
  return $this->defaultFileDlMode;
  }
   
  // setDefaultFolderDlMode
  //
  // Define the default folder download mode - one of [gzip, zip]
  function setDefaultFolderDlMode($dlmode) {
  if (in_array($dlmode, $this->validFolderDlModes)) {
  $this->defaultFolderDlMode = $dlmode;
  } else {
  echo 'Setting default file download mode to an invalid value "'.$dlmode.'"';
  exit;
  }
  }
   
  function getDefaultFolderDlMode() {
  return $this->defaultFolderDlMode;
} }
   
// Templates // Templates
   
function setTemplatePath($path, $myrep = 0) { function setTemplatePath($path, $myrep = 0) {
Line 972... Line 1230...
// {{{ parentPath // {{{ parentPath
// //
// Automatically set up the repositories based on a parent path // Automatically set up the repositories based on a parent path
   
function parentPath($path, $group = NULL, $pattern = false, $skipAlreadyAdded = true) { function parentPath($path, $group = NULL, $pattern = false, $skipAlreadyAdded = true) {
if ($handle = @opendir($path)) { $this->_parentPaths[] = new ParentPath($path, $group, $pattern, $skipAlreadyAdded);
// For each file... }
while (false !== ($file = readdir($handle))) {  
// That's also a non hidden directory  
if ($file{0} != '.' && is_dir($path.DIRECTORY_SEPARATOR.$file) && is_readable($path.DIRECTORY_SEPARATOR.$file)) {  
// And that contains a db directory (in an attempt to not include  
// non svn repositories.  
   
if (is_dir($path.DIRECTORY_SEPARATOR.$file.DIRECTORY_SEPARATOR."db") && is_readable($path.DIRECTORY_SEPARATOR.$file.DIRECTORY_SEPARATOR."db")) { function addExcludedPath($path) {
// And matches the pattern if specified $url = 'file:///'.$path;
if ($pattern === false || preg_match($pattern, $file)) { $url = str_replace(DIRECTORY_SEPARATOR, '/', $url);
$name = 'file:///'.$path.DIRECTORY_SEPARATOR.$file; if ($url{strlen($url) - 1} == '/') {
$add = true; $url = substr($url, 0, -1);
// And has not already been added if specified  
if ($skipAlreadyAdded) {  
$url = str_replace(DIRECTORY_SEPARATOR, '/', $name);  
if ($url{strlen($url) - 1} == '/') $url = substr($url, 0, -1);  
$url = substr($url, strrpos($url, '/') + 1);  
foreach ($this->getRepositories() as $rep) {  
if ($rep->svnName == $url) {  
$add = false;  
break;  
}  
}  
}  
if ($add) {  
// We add the repository to the list  
$this->addRepository($file, $name, $group);  
}  
}  
}  
}  
}  
closedir($handle);  
}  
   
// Sort the repositories into alphabetical order  
   
if (!empty($this->_repositories)) {  
usort($this->_repositories, "cmpReps");  
} }
  $this->_excluded[] = $url;
} }
   
// }}} // }}}
   
// {{{ Encoding functions // {{{ Encoding functions
Line 1052... Line 1279...
$this->defaultLanguage = $language; $this->defaultLanguage = $language;
} }
   
function getDefaultLanguage() { function getDefaultLanguage() {
return $this->defaultLanguage; return $this->defaultLanguage;
  }
   
  function ignoreUserAcceptedLanguages() {
  $this->ignoreAcceptedLanguages = true;
  }
   
  function useAcceptedLanguages() {
  return !$this->ignoreAcceptedLanguages;
} }
   
// {{{ Tab expansion functions // {{{ Tab expansion functions
   
function expandTabsBy($sp, $myrep = 0) { function expandTabsBy($sp, $myrep = 0) {
Line 1143... Line 1378...
return $this->flatIndex; return $this->flatIndex;
} }
   
function getOpenTree() { function getOpenTree() {
return $this->openTree; return $this->openTree;
  }
   
  function setAlphabeticOrder($flag) {
  $this->alphabetic = $flag;
  }
   
  function isAlphabeticOrder() {
  return $this->alphabetic;
} }
   
function showLastModInListing() { function showLastModInListing() {
return $this->showLastMod; return $this->showLastMod;
} }
   
function setShowLastModInListing($show) { function setShowLastModInListing($show) {
$this->showLastMod = $show; $this->showLastMod = $show;
  }
   
  function showAgeInsteadOfDate() {
  return $this->showAgeInsteadOfDate;
  }
   
  function setShowAgeInsteadOfDate($show) {
  $this->showAgeInsteadOfDate = $show;
} }
   
function showRepositorySelectionForm() { function showRepositorySelectionForm() {
return $this->_showRepositorySelectionForm; return $this->_showRepositorySelectionForm;
} }
   
function setShowRepositorySelectionForm($show) { function setShowRepositorySelectionForm($show) {
$this->_showRepositorySelectionForm = $show; $this->_showRepositorySelectionForm = $show;
} }
   
// setSubversionMajorVersion // Methods for storing version information for the command-line svn tool
//  
// Set subversion major version function setSubversionVersion($subversionVersion) {
  $this->subversionVersion = $subversionVersion;
  }
   
  function getSubversionVersion() {
  return $this->subversionVersion;
  }
   
function setSubversionMajorVersion($subversionMajorVersion) { function setSubversionMajorVersion($subversionMajorVersion) {
$this->subversionMajorVersion = $subversionMajorVersion; $this->subversionMajorVersion = $subversionMajorVersion;
} }
   
function getSubversionMajorVersion() { function getSubversionMajorVersion() {
return $this->subversionMajorVersion; return $this->subversionMajorVersion;
} }
   
// setSubversionMinorVersion  
//  
// Set subversion minor version  
   
function setSubversionMinorVersion($subversionMinorVersion) { function setSubversionMinorVersion($subversionMinorVersion) {
$this->subversionMinorVersion = $subversionMinorVersion; $this->subversionMinorVersion = $subversionMinorVersion;
} }
   

Powered by WebSVN 2.2.1