websvn |
Subversion Repositories: |
Rev 1 | Rev 3 | |
---|---|---|
Line 166... | Line 166... | |
|
| |
switch ($name) { |
switch ($name) { | |
case "ENTRY": |
case "ENTRY": | |
if ($debugxml) print "Ending new list entry\n"; |
if ($debugxml) print "Ending new list entry\n"; | |
if ($curList->curEntry->isdir) { |
if ($curList->curEntry->isdir) { | |
$curList->curEntry->file .= '/'; |
$curList->curEntry->file .= '/'; | |
} |
} | |
$curList->entries[] = $curList->curEntry; |
$curList->entries[] = $curList->curEntry; | |
$curList->curEntry = null; |
$curList->curEntry = null; | |
break; |
break; | |
} |
} | |
Line 201... | Line 201... | |
case "DATE": |
case "DATE": | |
if ($debugxml) print "Date: $data\n"; |
if ($debugxml) print "Date: $data\n"; | |
$data = trim($data); |
$data = trim($data); | |
if (empty($data)) return; |
if (empty($data)) return; | |
|
| |
$y = 0; | ||
$mo = 0; | ||
$d = 0; | ||
$h = 0; | ||
$m = 0; | ||
$s = 0; | ||
sscanf($data, "%d-%d-%dT%d:%d:%d.", $y, $mo, $d, $h, $m, $s); |
sscanf($data, "%d-%d-%dT%d:%d:%d.", $y, $mo, $d, $h, $m, $s); | |
|
| |
$mo = substr("00".$mo, -2); |
$mo = substr("00".$mo, -2); | |
$d = substr("00".$d, -2); |
$d = substr("00".$d, -2); | |
$h = substr("00".$h, -2); |
$h = substr("00".$h, -2); | |
$m = substr("00".$m, -2); |
$m = substr("00".$m, -2); | |
$s = substr("00".$s, -2); |
$s = substr("00".$s, -2); | |
|
| |
$curList->curEntry->date = "$y-$mo-$d $h:$m:$s GMT"; |
$committime = strtotime("$y-$mo-$d $h:$m:$s GMT"); | |
| ||
$curList->curEntry->date = strftime('%Y-%m-%d %H:%M:%S', $committime); | ||
|
| |
$committime = strtotime($curList->curEntry->date); |
||
$curList->curEntry->committime = $committime; |
$curList->curEntry->committime = $committime; | |
$curtime = time(); |
$curtime = time(); | |
|
| |
// Get the number of seconds since the commit |
// Get the number of seconds since the commit | |
$agesecs = $curtime - $committime; |
$agesecs = $curtime - $committime; | |
Line 333... | Line 340... | |
case "DATE": |
case "DATE": | |
if ($debugxml) print "Date: $data\n"; |
if ($debugxml) print "Date: $data\n"; | |
$data = trim($data); |
$data = trim($data); | |
if (empty($data)) return; |
if (empty($data)) return; | |
|
| |
$y = 0; | ||
$mo = 0; | ||
$d = 0; | ||
$h = 0; | ||
$m = 0; | ||
$s = 0; | ||
sscanf($data, "%d-%d-%dT%d:%d:%d.", $y, $mo, $d, $h, $m, $s); |
sscanf($data, "%d-%d-%dT%d:%d:%d.", $y, $mo, $d, $h, $m, $s); | |
|
| |
$mo = substr("00".$mo, -2); |
$mo = substr("00".$mo, -2); | |
$d = substr("00".$d, -2); |
$d = substr("00".$d, -2); | |
$h = substr("00".$h, -2); |
$h = substr("00".$h, -2); | |
$m = substr("00".$m, -2); |
$m = substr("00".$m, -2); | |
$s = substr("00".$s, -2); |
$s = substr("00".$s, -2); | |
|
| |
$curLog->curEntry->date = "$y-$mo-$d $h:$m:$s GMT"; |
$committime = strtotime("$y-$mo-$d $h:$m:$s GMT"); | |
| ||
$curLog->curEntry->date = strftime('%Y-%m-%d %H:%M:%S', $committime); | ||
|
| |
$committime = strtotime($curLog->curEntry->date); |
||
$curLog->curEntry->committime = $committime; |
$curLog->curEntry->committime = $committime; | |
$curtime = time(); |
$curtime = time(); | |
|
| |
// Get the number of seconds since the commit |
// Get the number of seconds since the commit | |
$agesecs = $curtime - $committime; |
$agesecs = $curtime - $committime; | |
Line 407... | Line 421... | |
function _topLevel($entry) { |
function _topLevel($entry) { | |
// To be at top level, there must be one space before the entry |
// To be at top level, there must be one space before the entry | |
return (strlen($entry) > 1 && $entry{0} == " " && $entry{1} != " "); |
return (strlen($entry) > 1 && $entry{0} == " " && $entry{1} != " "); | |
} |
} | |
|
| |
// Function to sort two given directory entries. Directories go at the top |
// Function to sort two given directory entries. | |
// Directories go at the top if config option alphabetic is not set | ||
|
| |
function _listSort($e1, $e2) { |
function _listSort($e1, $e2) { | |
$isDir1 = $e1->file{strlen($e1->file) - 1} == "/"; |
global $config; | |
$isDir2 = $e2->file{strlen($e2->file) - 1} == "/"; |
||
|
| |
if ($isDir1 && !$isDir2) return -1; |
if (!$config->isAlphabeticOrder()) { | |
if ($isDir2 && !$isDir1) return 1; |
$isDir1 = $e1->file{strlen($e1->file) - 1} == "/"; | |
$isDir2 = $e2->file{strlen($e2->file) - 1} == "/"; | ||
| ||
if ($isDir1 && !$isDir2) return -1; | ||
if ($isDir2 && !$isDir1) return 1; | ||
} | ||
|
| |
return strnatcasecmp($e1->file, $e2->file); |
return strnatcasecmp($e1->file, $e2->file); | |
} |
} | |
|
| |
// }}} |
// }}} | |
Line 436... | Line 455... | |
for ($i = 0; $i < count($parts); $i++) { |
for ($i = 0; $i < count($parts); $i++) { | |
if ( function_exists("mb_detect_encoding") && function_exists("mb_convert_encoding")) { |
if ( function_exists("mb_detect_encoding") && function_exists("mb_convert_encoding")) { | |
$parts[$i] = mb_convert_encoding($parts[$i], "UTF-8", mb_detect_encoding($parts[$i])); |
$parts[$i] = mb_convert_encoding($parts[$i], "UTF-8", mb_detect_encoding($parts[$i])); | |
} |
} | |
|
| |
$parts[$i] = rawurlencode($parts[$i]); |
// do not urlencode the 'svn+ssh://' part! | |
if ($i != 0 || $parts[$i] != 'svn+ssh:') { | ||
$parts[$i] = rawurlencode($parts[$i]); | ||
} | ||
} |
} | |
|
| |
$uri = implode('/', $parts); |
$uri = implode('/', $parts); | |
|
| |
// Quick hack. Subversion seems to have a bug surrounding the use of %3A instead of : |
// Quick hack. Subversion seems to have a bug surrounding the use of %3A instead of : | |
|
| |
$uri = str_replace("%3A" ,":", $uri); |
$uri = str_replace("%3A" ,":", $uri); | |
|
| |
// Correct for Window share names |
// Correct for Window share names | |
if ( $config->serverIsWindows==true ) { |
if ($config->serverIsWindows) { | |
if (substr($uri, 0,2) == "//") { |
if (substr($uri, 0,2) == "//") { | |
$uri = "\\".substr($uri, 2, strlen($uri)); |
$uri = "\\".substr($uri, 2, strlen($uri)); | |
} |
} | |
|
| |
if (substr($uri, 0,10)=="file://///" ) { |
if (substr($uri, 0,10)=="file://///" ) { | |
Line 465... | Line 487... | |
|
| |
// The SVNRepository class |
// The SVNRepository class | |
|
| |
class SVNRepository { |
class SVNRepository { | |
var $repConfig; |
var $repConfig; | |
var $geshi = null; | ||
|
| |
function SVNRepository($repConfig) { |
function SVNRepository($repConfig) { | |
$this->repConfig = $repConfig; |
$this->repConfig = $repConfig; | |
} |
} | |
|
| |
Line 527... | Line 550... | |
// |
// | |
// Dump the content of a file to the given filename |
// Dump the content of a file to the given filename | |
|
| |
function getFileContents($path, $filename, $rev = 0, $pipe = "", $perLineHighlighting = false) { |
function getFileContents($path, $filename, $rev = 0, $pipe = "", $perLineHighlighting = false) { | |
global $config, $extEnscript; |
global $config, $extEnscript; | |
| ||
$highlighted = false; | ||
|
| |
// If there's no filename, we'll just deliver the contents as it is to the user |
// If there's no filename, we'll just deliver the contents as it is to the user | |
if ($filename == "") { |
if ($filename == "") { | |
$path = encodepath($this->repConfig->path.$path); |
$path = encodepath($this->getSvnpath($path)); | |
passthru(quoteCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path).' -r '.$rev.' '.$pipe)); |
passthruCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' '.$pipe); | |
return; |
return $highlighted; | |
} |
} | |
|
| |
// Get the file contents info |
// Get the file contents info | |
|
| |
$ext = strrchr($path, "."); |
$ext = strrchr($path, "."); | |
$l = @$extEnscript[$ext]; |
$l = @$extEnscript[$ext]; | |
|
| |
if ($l == "php") { |
if ($l == "php") { | |
// Output the file to the filename |
// Output the file to the filename | |
$path = encodepath($this->repConfig->path.$path); |
$path = encodepath($this->getSvnpath($path)); | |
$cmd = quoteCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path).' -r '.$rev.' > '.quote($filename)); |
$cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' > '.quote($filename); | |
@exec($cmd); |
$retcode = 0; | |
execCommand($cmd, $retcode); | ||
if ($retcode != 0) { | ||
print'Unable to call svn command "'.$config->svn.'"'; | ||
exit(0); | ||
} | ||
|
| |
// Get the file as a string (memory hogging, but we have no other options) |
// Get the file as a string (memory hogging, but we have no other options) | |
$content = highlight_file($filename, true); |
$content = highlight_file($filename, true); | |
|
| |
// Destroy the previous version, and replace it with the highlighted version |
// Destroy the previous version, and replace it with the highlighted version | |
$f = fopen($filename, "w"); |
$f = fopen($filename, "w"); | |
if ($f) { |
if ($f) { | |
$highlighted = true; | ||
// The highlight file function doesn't deal with line endings very nicely at all. We'll have to do it |
// The highlight file function doesn't deal with line endings very nicely at all. We'll have to do it | |
// by hand. |
// by hand. | |
|
| |
// Remove the first line generated by highlight() |
// Remove the first line generated by highlight() | |
$pos = strpos($content, "\n"); |
$pos = strpos($content, "\n"); | |
Line 563... | Line 594... | |
|
| |
$content = explode("<br />", $content); |
$content = explode("<br />", $content); | |
|
| |
if ($perLineHighlighting) { |
if ($perLineHighlighting) { | |
// If we need each line independently highlighted (e.g. for diff or blame) |
// If we need each line independently highlighted (e.g. for diff or blame) | |
// hen we'll need to filter the output of the highlighter |
// then we'll need to filter the output of the highlighter | |
// to make sure tags like <font>, <i> or <b> don't span lines |
// to make sure tags like <font>, <i> or <b> don't span lines | |
|
| |
// $attributes is used to remember what highlighting attributes |
// $attributes is used to remember what highlighting attributes | |
// are in effect from one line to the next |
// are in effect from one line to the next | |
$attributes = array(); // start with no attributes in effect |
$attributes = array(); // start with no attributes in effect | |
|
| |
foreach ($content as $line) { |
foreach ($content as $line) { | |
fputs($f, $this->highlightLine(rtrim($line),$attributes)."\n"); |
fputs($f, $this->highlightLine(rtrim($line), $attributes)."\n"); | |
} |
} | |
} else { |
} else { | |
foreach ($content as $line) { |
foreach ($content as $line) { | |
fputs($f, rtrim($line)."\n"); |
fputs($f, rtrim($line)."\n"); | |
} |
} | |
Line 583... | Line 614... | |
|
| |
fclose($f); |
fclose($f); | |
} |
} | |
|
| |
} else { |
} else { | |
if ($l !== null && $config->useGeshi) { |
$tempname = $filename; | |
$this->applyGeshi($path, $filename, $rev, $l); |
if ($perLineHighlighting) { | |
$tempname = tempnam('temp', ''); | ||
} | ||
$highlighted = true; | ||
if ($config->useGeshi && $geshiLang = $this->highlightLanguageUsingGeshi($ext)) { | ||
$this->applyGeshi($path, $tempname, $rev, $geshiLang); | ||
|
| |
} else if ($config->useEnscript) { |
} else if ($config->useEnscript) { | |
// Get the files, feed it through enscript, then remove the enscript headers using sed |
// Get the files, feed it through enscript, then remove the enscript headers using sed | |
// |
// | |
// Note that the sec command returns only the part of the file between <PRE> and </PRE>. |
// Note that the sec command returns only the part of the file between <PRE> and </PRE>. | |
// It's complicated because it's designed not to return those lines themselves. |
// It's complicated because it's designed not to return those lines themselves. | |
|
| |
$path = encodepath($this->repConfig->path.$path); |
$path = encodepath($this->getSvnpath($path)); | |
$cmd = quoteCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path).' -r '.$rev.' | '. |
$cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' | '. | |
$config->enscript." --language=html ". |
$config->enscript." --language=html ". | |
($l ? "--color --pretty-print=$l" : "")." -o - | ". |
($l ? "--color --pretty-print=$l" : "")." -o - | ". | |
$config->sed." -n ".$config->quote."1,/^<PRE.$/!{/^<\\/PRE.$/,/^<PRE.$/!p;}".$config->quote." > $filename"); |
$config->sed." -n ".$config->quote."1,/^<PRE.$/!{/^<\\/PRE.$/,/^<PRE.$/!p;}".$config->quote." > $tempname"; | |
@exec($cmd); |
$retcode = 0; | |
execCommand($cmd, $retcode); | ||
if ($retcode != 0) { | ||
print'Unable to call svn command "'.$config->svn.'"'; | ||
if ($tempname != $filename) { | ||
@unlink($tempname); | ||
} | ||
exit(0); | ||
} | ||
|
| |
} else { |
} else { | |
$path = encodepath(str_replace(DIRECTORY_SEPARATOR, "/", $this->repConfig->path.$path)); |
$highlighted = false; | |
$cmd = quoteCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path).' -r '.$rev.' > '.quote($filename)); |
$path = encodepath(str_replace(DIRECTORY_SEPARATOR, "/", $this->getSvnpath($path))); | |
@exec($cmd); |
$cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' > '.quote($filename); | |
$retcode = 0; | ||
execCommand($cmd, $retcode); | ||
if ($retcode != 0) { | ||
print'Unable to call svn command "'.$config->svn.'"'; | ||
if ($tempname != $filename) { | ||
@unlink($tempname); | ||
} | ||
exit(0); | ||
} | ||
} | ||
| ||
if ($highlighted && $perLineHighlighting) { | ||
// If we need each line independently highlighted (e.g. for diff or blame) | ||
// then we'll need to filter the output of the highlighter | ||
// to make sure tags like <font>, <i> or <b> don't span lines | ||
| ||
$dst = fopen($filename, 'w'); | ||
if ($dst) { | ||
$content = file_get_contents($tempname); | ||
$content = explode('<br />', $content); | ||
| ||
// $attributes is used to remember what highlighting attributes | ||
// are in effect from one line to the next | ||
$attributes = array(); // start with no attributes in effect | ||
| ||
foreach ($content as $line) { | ||
fputs($dst, $this->highlightLine(trim($line), $attributes)."\n"); | ||
} | ||
fclose($dst); | ||
} | ||
} | ||
if ($tempname != $filename) { | ||
@unlink($tempname); | ||
} |
} | |
} |
} | |
return $highlighted; | ||
} | ||
| ||
// }}} | ||
| ||
// {{{ highlightLanguageUsingGeshi | ||
// | ||
// check if geshi can highlight the given extension and return the language | ||
| ||
function highlightLanguageUsingGeshi($ext) { | ||
global $extGeshi; | ||
if (substr($ext, 0, 1) == '.') $ext = substr($ext, 1); | ||
| ||
foreach ($extGeshi as $lang => $extensions) { | ||
if (in_array($ext, $extensions)) { | ||
if ($this->geshi === null) { | ||
require_once 'lib/geshi.php'; | ||
$this->geshi = new GeSHi(); | ||
} else { | ||
$this->geshi->error = false; | ||
} | ||
$this->geshi->set_language($lang); | ||
if ($this->geshi->error() === false) { | ||
return $lang; | ||
} | ||
} | ||
} | ||
return ''; | ||
| ||
| ||
} |
} | |
|
| |
// }}} |
// }}} | |
|
| |
// {{{ applyGeshi |
// {{{ applyGeshi | |
// |
// | |
// perform syntax highlighting using geshi |
// perform syntax highlighting using geshi | |
|
| |
function applyGeshi($path, $filename, $rev = 0, $l, $return = false) { |
function applyGeshi($path, $filename, $rev, $lang, $return = false) { | |
global $config; |
global $config; | |
|
| |
// Output the file to the filename |
// Output the file to the filename | |
$path = encodepath($this->repConfig->path.$path); |
$path = encodepath($this->getSvnpath($path)); | |
$cmd = quoteCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path).' -r '.$rev.' > '.quote($filename)); |
$cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' > '.quote($filename); | |
@exec($cmd); |
$retcode = 0; | |
execCommand($cmd, $retcode); | ||
if ($retcode != 0) { | ||
print'Unable to call svn command "'.$config->svn.'"'; | ||
exit(0); | ||
} | ||
|
| |
$source = file_get_contents($filename); |
$source = file_get_contents($filename); | |
require_once 'lib/geshi.php'; |
if ($this->geshi === null) { | |
$geshi = new GeSHi($source, $l); |
require_once 'lib/geshi.php'; | |
$this->geshi = new GeSHi(); | ||
} | ||
$this->geshi->set_source($source); | ||
$this->geshi->set_language($lang); | ||
$this->geshi->set_header_type(GESHI_HEADER_DIV); | ||
$this->geshi->set_overall_class('geshi'); | ||
$this->geshi->set_tab_width($this->repConfig->getExpandTabsBy()); | ||
| ||
if ($return) { |
if ($return) { | |
return $geshi->parse_code(); |
return $this->geshi->parse_code(); | |
} else { |
} else { | |
$code = $geshi->parse_code(); |
||
$code = preg_replace("/^<pre.*?>/", '', $code); |
||
$code = preg_replace("/<\/pre>$/", '', $code); |
||
$f = @fopen($filename, 'w'); |
$f = @fopen($filename, 'w'); | |
fwrite($f, $code); |
fwrite($f, $this->geshi->parse_code()); | |
fclose($f); |
fclose($f); | |
} |
} | |
} |
} | |
|
| |
// }}} |
// }}} | |
Line 657... | Line 774... | |
// Deal with php highlighting internally |
// Deal with php highlighting internally | |
if ($l == "php") { |
if ($l == "php") { | |
$tmp = tempnam("temp", "wsvn"); |
$tmp = tempnam("temp", "wsvn"); | |
|
| |
// Output the file to a temporary file |
// Output the file to a temporary file | |
$path = encodepath($this->repConfig->path.$path); |
$path = encodepath($this->getSvnpath($path)); | |
$cmd = quoteCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path).' -r '.$rev.' > '.$tmp); |
$cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' > '.$tmp; | |
@exec($cmd); |
$retcode = 0; | |
execCommand($cmd, $retcode); | ||
if ($retcode != 0) { | ||
print'Unable to call svn command "'.$config->svn.'"'; | ||
@unlink($tmp); | ||
exit(0); | ||
} | ||
$tmpStr = file_get_contents($tmp); |
$tmpStr = file_get_contents($tmp); | |
$tmpStr = str_replace(array("\r\n"), array("\n"), $tmpStr); |
$tmpStr = str_replace(array("\r\n"), array("\n"), $tmpStr); | |
highlight_string($tmpStr); |
highlight_string($tmpStr); | |
@unlink($tmp); |
@unlink($tmp); | |
} else if ($l !== null && $config->useGeshi) { |
} else if ($config->useGeshi && $geshiLang = $this->highlightLanguageUsingGeshi($ext)) { | |
$tmp = tempnam("temp", "wsvn"); |
$tmp = tempnam("temp", "wsvn"); | |
print $this->applyGeshi($path, $tmp, $rev, $l, true); |
print toOutputEncoding($this->applyGeshi($path, $tmp, $rev, $geshiLang, true), $this->repConfig->getContentEncoding()); | |
unlink($tmp); |
@unlink($tmp); | |
} else { |
} else { | |
if ($config->useEnscript) { |
if ($config->useEnscript) { | |
$path = encodepath($this->repConfig->path.$path); |
$path = encodepath($this->getSvnpath($path)); | |
$cmd = quoteCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path).' -r '.$rev.' | '. |
$cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' | '. | |
$config->enscript." --language=html ". |
$config->enscript." --language=html ". | |
($l ? "--color --pretty-print=$l" : "")." -o - | ". |
($l ? "--color --pretty-print=$l" : "")." -o - | ". | |
$config->sed." -n ".$config->quote."/^<PRE.$/,/^<\\/PRE.$/p".$config->quote |
$config->sed." -n ".$config->quote."/^<PRE.$/,/^<\\/PRE.$/p".$config->quote; | |
); |
||
} else { |
} else { | |
$path = encodepath($this->repConfig->path.$path); |
$path = encodepath($this->getSvnpath($path)); | |
$cmd = quoteCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path).' -r '.$rev); |
$cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev); | |
$pre = true; |
$pre = true; | |
} |
} | |
|
| |
if ($result = popen($cmd, "r")) { |
if ($result = popenCommand($cmd, "r")) { | |
if ($pre) echo "<PRE>"; |
if ($pre) echo "<pre>"; | |
|
| |
$contentEncoding = $this->repConfig->getContentEncoding(); | ||
while (!feof($result)) { |
while (!feof($result)) { | |
$line = fgets($result, 1024); |
$line = fgets($result, 1024); | |
if ($pre) $line = replaceEntities($line, $this->repConfig); |
if ($pre) $line = replaceEntities($line, $this->repConfig); | |
else $line = toOutputEncoding($line, $contentEncoding); | ||
|
| |
print hardspace($line); |
print hardspace($line); | |
} |
} | |
|
| |
if ($pre) echo "</PRE>"; |
if ($pre) echo "</pre>"; | |
|
| |
pclose($result); |
pclose($result); | |
} |
} | |
} |
} | |
} |
} | |
Line 708... | Line 832... | |
// Dump the blame content of a file to the given filename |
// Dump the blame content of a file to the given filename | |
|
| |
function getBlameDetails($path, $filename, $rev = 0) { |
function getBlameDetails($path, $filename, $rev = 0) { | |
global $config; |
global $config; | |
|
| |
$path = encodepath($this->repConfig->path.$path); |
$path = encodepath($this->getSvnpath($path)); | |
$cmd = quoteCommand($config->svn." blame ".$this->repConfig->svnParams().quote($path).' -r '.$rev.' > '.quote($filename)); |
$cmd = $config->svn." blame ".$this->repConfig->svnParams().quote($path.'@'.$rev).' > '.quote($filename); | |
|
| |
@exec($cmd); |
$retcode = 0; | |
execCommand($cmd, $retcode); | ||
if ($retcode != 0) { | ||
print'Unable to call svn command "'.$config->svn.'"'; | ||
exit(0); | ||
} | ||
} |
} | |
|
| |
// }}} |
// }}} | |
|
| |
// {{{ getProperty |
// {{{ getProperty | |
|
| |
function getProperty($path, $property, $rev = 0) { |
function getProperty($path, $property, $rev = 0) { | |
global $config; |
global $config; | |
|
| |
$path = encodepath($this->repConfig->path.$path); |
$path = encodepath($this->getSvnpath($path)); | |
|
| |
if ($rev > 0) { |
if ($rev > 0) { | |
$rev = ' -r '.$rev; |
$rev = '@'.$rev; | |
} else { |
} else { | |
$rev = ''; |
$rev = ''; | |
} |
} | |
|
| |
$ret = runCommand($config->svn." propget $property ".$this->repConfig->svnParams().quote($path).$rev, true); |
$ret = runCommand($config->svn." propget $property ".$this->repConfig->svnParams().quote($path.$rev), true); | |
|
| |
// Remove the surplus newline |
// Remove the surplus newline | |
if (count($ret)) { |
if (count($ret)) { | |
unset($ret[count($ret) - 1]); |
unset($ret[count($ret) - 1]); | |
} |
} | |
Line 748... | Line 877... | |
// Exports the directory to the given location |
// Exports the directory to the given location | |
|
| |
function exportDirectory($path, $filename, $rev = 0) { |
function exportDirectory($path, $filename, $rev = 0) { | |
global $config; |
global $config; | |
|
| |
$path = encodepath($this->repConfig->path.$path); |
$path = encodepath($this->getSvnpath($path)); | |
$cmd = quoteCommand($config->svn." export ".$this->repConfig->svnParams().quote($path).' -r '.$rev.' '.quote($filename)); |
$cmd = $config->svn." export ".$this->repConfig->svnParams().quote($path.'@'.$rev).' '.quote($filename); | |
|
| |
@exec($cmd); |
$retcode = 0; | |
execCommand($cmd, $retcode); | ||
if ($retcode != 0) { | ||
print'Unable to call svn command "'.$config->svn.'"'; | ||
exit(0); | ||
} | ||
} |
} | |
|
| |
// }}} |
// }}} | |
|
| |
// {{{ getList |
// {{{ getList | |
Line 778... | Line 912... | |
$curList = new SVNList; |
$curList = new SVNList; | |
$curList->entries = array(); |
$curList->entries = array(); | |
$curList->path = $path; |
$curList->path = $path; | |
|
| |
// Get the list info |
// Get the list info | |
$path = encodepath($this->repConfig->path.$path); |
$path = encodepath($this->getSvnpath($path)); | |
|
| |
if ($rev == 0) { |
if ($rev == 0) { | |
$headlog = $this->getLog("/", "", "", true, 1); |
$headlog = $this->getLog("/", "", "", true, 1); | |
if (is_string($headlog)) { | ||
echo $headlog; | ||
exit; | ||
} | ||
if (isset($headlog->entries[0])) $rev = $headlog->entries[0]->rev; |
if (isset($headlog->entries[0])) $rev = $headlog->entries[0]->rev; | |
} |
} | |
$revStr = "-r $rev"; |
||
|
| |
$cmd = quoteCommand($config->svn." list --xml $revStr ".$this->repConfig->svnParams().quote($path)); |
$cmd = quoteCommand($config->svn.' list --xml '.$this->repConfig->svnParams().quote($path.'@'.$rev)); | |
|
| |
$descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')); |
$descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')); | |
|
| |
$resource = proc_open($cmd, $descriptorspec, $pipes); |
$resource = proc_open($cmd, $descriptorspec, $pipes); | |
$error = ""; |
||
|
| |
if (!is_resource($resource)) { |
if (!is_resource($resource)) { | |
echo "<p>".$lang['BADCMD'].": <code>".$cmd."</code></p>"; |
echo "<p>".$lang['BADCMD'].": <code>".$cmd."</code></p>"; | |
exit; |
exit; | |
} |
} | |
Line 803... | Line 939... | |
$handle = $pipes[1]; |
$handle = $pipes[1]; | |
$firstline = true; |
$firstline = true; | |
while (!feof($handle)) { |
while (!feof($handle)) { | |
$line = fgets($handle); |
$line = fgets($handle); | |
if (!xml_parse($xml_parser, $line, feof($handle))) { |
if (!xml_parse($xml_parser, $line, feof($handle))) { | |
if (xml_get_error_code($xml_parser) != 5) { |
$errorMsg = sprintf("XML error: %s (%d) at line %d column %d byte %d\ncmd: %s", | |
// errors can contain sensitive info! don't echo this ~J |
||
error_log(sprintf("XML error: %s (%d) at line %d column %d byte %d\ncmd: %s", |
||
xml_error_string(xml_get_error_code($xml_parser)), |
xml_error_string(xml_get_error_code($xml_parser)), | |
xml_get_error_code($xml_parser), |
xml_get_error_code($xml_parser), | |
xml_get_current_line_number($xml_parser), |
xml_get_current_line_number($xml_parser), | |
xml_get_current_column_number($xml_parser), |
xml_get_current_column_number($xml_parser), | |
xml_get_current_byte_index($xml_parser), |
xml_get_current_byte_index($xml_parser), | |
$cmd)); |
$cmd); | |
if (xml_get_error_code($xml_parser) != 5) { | ||
// errors can contain sensitive info! don't echo this ~J | ||
error_log($errorMsg); | ||
exit; |
exit; | |
} else { |
} else { | |
$vars["error"] = $lang["UNKNOWNREVISION"]; |
break; | |
return 0; |
||
} |
} | |
} |
} | |
} |
} | |
|
| |
$error = ''; | ||
while (!feof($pipes[2])) { |
while (!feof($pipes[2])) { | |
$error .= fgets($pipes[2]); |
$error .= fgets($pipes[2]); | |
} |
} | |
|
| |
$error = toOutputEncoding(trim($error)); |
$error = toOutputEncoding(trim($error)); | |
Line 833... | Line 970... | |
fclose($pipes[2]); |
fclose($pipes[2]); | |
|
| |
proc_close($resource); |
proc_close($resource); | |
|
| |
if (!empty($error)) { |
if (!empty($error)) { | |
echo "<p>".$lang['BADCMD'].": <code>".$cmd."</code></p><p>".nl2br($error)."</p>"; |
echo '<p>'.$lang['BADCMD'].': <code>'.$cmd.'</code></p><p>'.nl2br($error).'</p>'; | |
exit; |
exit; | |
} |
} | |
|
| |
xml_parser_free($xml_parser); |
xml_parser_free($xml_parser); | |
|
| |
// Sort the entries into alphabetical order with the directories at the top of the list |
// Sort the entries into alphabetical order | |
usort($curList->entries, "_listSort"); |
usort($curList->entries, "_listSort"); | |
|
| |
return $curList; |
return $curList; | |
} |
} | |
|
| |
Line 881... | Line 1018... | |
if (($config->subversionMajorVersion > 1 || $config->subversionMinorVersion >=2) && $limit != 0) { |
if (($config->subversionMajorVersion > 1 || $config->subversionMinorVersion >=2) && $limit != 0) { | |
$revStr .= " --limit $limit"; |
$revStr .= " --limit $limit"; | |
} |
} | |
|
| |
// Get the log info |
// Get the log info | |
$path = encodepath($this->repConfig->path.$path); |
$path = encodepath($this->getSvnpath($path)); | |
$info = "--verbose"; |
$info = "--verbose"; | |
if ($quiet) $info = "--quiet"; |
if ($quiet) $info = "--quiet"; | |
|
| |
$cmd = quoteCommand($config->svn." log --xml $info $revStr ".$this->repConfig->svnParams().quote($path)); |
$pegRev = ''; | |
if ($brev) { | ||
$pegRev = '@'.$brev; | ||
} | ||
$cmd = quoteCommand($config->svn." log --xml $info $revStr ".$this->repConfig->svnParams().quote($path.$pegRev)); | ||
|
| |
$descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')); |
$descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')); | |
|
| |
$resource = proc_open($cmd, $descriptorspec, $pipes); |
$resource = proc_open($cmd, $descriptorspec, $pipes); | |
$error = ""; |
||
|
| |
if (!is_resource($resource)) { |
if (!is_resource($resource)) { | |
echo "<p>".$lang['BADCMD'].": <code>".$cmd."</code></p>"; |
echo "<p>".$lang['BADCMD'].": <code>".$cmd."</code></p>"; | |
exit; |
exit; | |
} |
} | |
Line 902... | Line 1042... | |
$handle = $pipes[1]; |
$handle = $pipes[1]; | |
$firstline = true; |
$firstline = true; | |
while (!feof($handle)) { |
while (!feof($handle)) { | |
$line = fgets($handle); |
$line = fgets($handle); | |
if (!xml_parse($xml_parser, $line, feof($handle))) { |
if (!xml_parse($xml_parser, $line, feof($handle))) { | |
if (xml_get_error_code($xml_parser) != 5) { |
$errorMsg = sprintf("XML error: %s (%d) at line %d column %d byte %d\ncmd: %s", | |
// errors can contain sensitive info! don't echo this ~J |
||
error_log(sprintf("XML error: %s (%d) at line %d column %d byte %d\ncmd: %s", |
||
xml_error_string(xml_get_error_code($xml_parser)), |
xml_error_string(xml_get_error_code($xml_parser)), | |
xml_get_error_code($xml_parser), |
xml_get_error_code($xml_parser), | |
xml_get_current_line_number($xml_parser), |
xml_get_current_line_number($xml_parser), | |
xml_get_current_column_number($xml_parser), |
xml_get_current_column_number($xml_parser), | |
xml_get_current_byte_index($xml_parser), |
xml_get_current_byte_index($xml_parser), | |
$cmd)); |
$cmd); | |
if (xml_get_error_code($xml_parser) != 5) { | ||
// errors can contain sensitive info! don't echo this ~J | ||
error_log($errorMsg); | ||
exit; |
exit; | |
} else { |
} else { | |
$vars["error"] = $lang["UNKNOWNREVISION"]; |
break; | |
return 0; |
||
} |
} | |
} |
} | |
} |
} | |
|
| |
$error = ''; | ||
while (!feof($pipes[2])) { |
while (!feof($pipes[2])) { | |
$error .= fgets($pipes[2]); |
$error .= fgets($pipes[2]); | |
} |
} | |
|
| |
$error = toOutputEncoding(trim($error)); |
$error = toOutputEncoding(trim($error)); | |
Line 932... | Line 1073... | |
fclose($pipes[2]); |
fclose($pipes[2]); | |
|
| |
proc_close($resource); |
proc_close($resource); | |
|
| |
if (!empty($error)) { |
if (!empty($error)) { | |
echo "<p>".$lang['BADCMD'].": <code>".$cmd."</code></p><p>".nl2br($error)."</p>"; |
return '<p>'.$lang['BADCMD'].': <code>'.$cmd.'</code></p><p>'.nl2br($error).'</p>'; | |
exit; |
||
} |
} | |
|
| |
xml_parser_free($xml_parser); |
xml_parser_free($xml_parser); | |
|
| |
foreach ($curLog->entries as $entryKey => $entry) { |
foreach ($curLog->entries as $entryKey => $entry) { | |
Line 965... | Line 1105... | |
$curLog->entries[$entryKey]->age = ''; |
$curLog->entries[$entryKey]->age = ''; | |
} |
} | |
} |
} | |
|
| |
return $curLog; |
return $curLog; | |
} | ||
| ||
// }}} | ||
| ||
function isFile($path, $rev = 0) { | ||
global $config; | ||
| ||
$path = encodepath($this->getSvnpath($path)); | ||
if ($rev != 0) { | ||
$rev = '@'.$rev; | ||
} else { | ||
$rev = ''; | ||
} | ||
$cmd = $config->svn." info --xml ".$this->repConfig->svnParams().quote($path.$rev); | ||
$output = runCommand($cmd, true); | ||
| ||
return strpos(implode(' ', $output), 'kind="file"') !== false; | ||
} | ||
| ||
// {{{ getSvnpath | ||
| ||
function getSvnpath( $path ) { | ||
if ($this->repConfig->subpath === null) { | ||
return $this->repConfig->path.$path; | ||
} else { | ||
$path = preg_replace('|^/?'.$this->repConfig->subpath.'|', '', $path); | ||
return $this->repConfig->path.'/'.$this->repConfig->subpath.$path; | ||
} | ||
} |
} | |
|
| |
// }}} |
// }}} | |
|
| |
} |
} | |
|
| |
// {{{ initSvnVersion |
// {{{ initSvnVersion | |
|
| |
function initSvnVersion(&$major, &$minor) { |
function initSvnVersion() { | |
global $config; |
global $config; | |
|
| |
$ret = runCommand($config->svn_noparams." --version", false); |
$ret = runCommand($config->svn_noparams." --version", false); | |
|
| |
if (preg_match("~([0-9]?)\.([0-9]?)\.([0-9]?)~",$ret[0],$matches)) { |
if (preg_match("~([0-9]?)\.([0-9]?)\.([0-9]?)~",$ret[0],$matches)) { | |
$major = $matches[1]; |
$config->setSubversionVersion($matches[0]); | |
$minor = $matches[2]; |
$config->setSubversionMajorVersion($matches[1]); | |
$config->setSubversionMinorVersion($matches[2]); | ||
} |
} | |
|
||
$config->setSubversionMajorVersion($major); |
||
$config->setSubversionMinorVersion($minor); |
||
} |
} | |
|
| |
// }}} |
// }}} | |
|
|