1<?php 2/** 3 * Repos Style log reader (c) 2007-2009 Staffan Olsson reposstyle.com 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18// === Print svn log --xml to response === 19 20// Set the URL to the stylesheet, must be same host or absolute path from root 21$xslt = '/repos-style/view/log.xsl'; 22 23// URL or path to repository, no trailing slash 24// (note that the log viewer may bypass access control) 25$repo = '@@Repository@@'; 26// For SVNParentPath and svn 1.5+, set $repo to parent and this to true 27$isParent = false; 28 29// limit log length for performance reasons (users should run svn client for more entries) 30$limit = 20; 31 32// svn executable, command name in PATH or absolute path 33$svn = 'svn'; 34 35// === configuration done, get parameters === 36 37isset($_REQUEST['target']) or die("Parameter 'target' is required"); 38$target = $_REQUEST['target']; 39 40// === validate and run svn === 41if (strstr($repo,'@@')) die('The log script must be configured with a root URL'); 42is_numeric($limit) or die('The log script must be configured with a numeric limit'); 43 44if ($isParent) { 45 isset($_REQUEST['base']) && strlen($_REQUEST['base'])>0 46 or die("Parameter 'base' (Subversion 1.5 or later) required for SVNParentPath"); 47 $repo = $repo.'/'.$_REQUEST['base']; 48} 49 50$url = $repo . $target; 51 52// command line, injection safe, svn must be in path, assumes utf-8 shell 53$cmd = $svn.' log --xml --verbose --incremental --non-interactive'; 54$cmd .= ' --limit '.escapeshellarg($limit); 55$cmd .= ' '.escapeshellarg($url); 56$cmd .= ' 2>&1'; 57 58header('Content-Type: text/xml'); 59echo('<?xml version="1.0"?> 60<?xml-stylesheet type="text/xsl" href="'.$xslt.'"?> 61<log limit="'.$limit.'"> 62'); 63passthru($cmd); 64echo('</log> 65'); 66?> 67