Пример #1
0
 /**
  * Read data from file
  *
  * @param  int     Specific revision. 0 = youngest
  * @param  bool    Disable memory-based cache
  * @return string  contents
  * @throws IOException
  */
 public function getContents($revision = 0, $noCache = false)
 {
     if (!$this->rep) {
         return null;
     }
     if (SVN::$apcEnabled && !$noCache) {
         $cKey = $this->rep->getCacheKey($this->getPath() . '-CONTENTS', $this->getRevision());
         # try load cache
         if (($dat = apc_fetch($cKey)) !== false) {
             #print 'cache hit';
             return $dat;
         }
         # load data
         $dat = $this->rep->look('cat', $this->getPath(), $revision ? "-r {$revision}" : '');
         # schedule cache write
         SVN::scheduleCacheWrite($cKey, $dat);
         return $dat;
     } else {
         return $this->rep->look('cat', $this->getPath(), $revision ? "-r {$revision}" : '');
     }
 }
Пример #2
0
//
// diff.php
//
// Show the differences between 2 revisions of a file.
//
require_once 'include/setup.php';
require_once 'include/svnlook.php';
require_once 'include/utils.php';
require_once 'include/template.php';
require_once 'include/diff_inc.php';
$vars['action'] = $lang['DIFF'];
$all = @$_REQUEST['all'] == 1;
$ignoreWhitespace = @$_REQUEST['ignorews'] == 1;
// Make sure that we have a repository
if ($rep) {
    $svnrep = new SVNRepository($rep);
    // If there's no revision info, go to the lastest revision for this path
    $history = $svnrep->getLog($path, '', '', true, 2, $peg);
    $youngest = $history ? $history->entries[0]->rev : 0;
    if (empty($rev)) {
        $rev = $youngest;
    }
    $history = $svnrep->getLog($path, $rev, '', false, 2, $peg);
    if ($path[0] != '/') {
        $ppath = '/' . $path;
    } else {
        $ppath = $path;
    }
    $prevrev = @$history->entries[1]->rev;
    $vars['path'] = htmlentities($ppath, ENT_QUOTES, 'UTF-8');
    $vars['rev1'] = $rev;
Пример #3
0
            break;
        case 'diff':
            $file = 'diff.php';
            break;
        case 'blame':
            $file = 'blame.php';
            break;
        case 'rss':
            $file = 'rss.php';
            break;
        case 'dl':
            $file = 'dl.php';
            break;
        case 'comp':
            $file = 'comp.php';
            break;
        default:
            $svnrep = new SVNRepository($rep);
            if ($svnrep->isFile($path, $rev)) {
                $file = 'filedetails.php';
            } else {
                $file = 'listing.php';
            }
            break;
    }
    // Now include the file that handles it
    include $locwebsvnreal . '/' . $file;
} else {
    print '<p>MultiViews must be configured in include/config.php in order to use this file.</p>';
    exit;
}
Пример #4
0
require_once 'include/template.php';
function checkRevision($rev)
{
    if (is_numeric($rev) && (int) $rev > 0) {
        return $rev;
    }
    $rev = strtoupper($rev);
    if ($rev == 'HEAD' || $rev == 'PREV' || $rev == 'COMMITTED') {
        return $rev;
    } else {
        return 'HEAD';
    }
}
// Make sure that we have a repository
if ($rep) {
    $svnrep = new SVNRepository($rep);
    // Retrieve the request information
    $path1 = @$_REQUEST['compare'][0];
    $path2 = @$_REQUEST['compare'][1];
    $rev1 = (int) @$_REQUEST['compare_rev'][0];
    $rev2 = (int) @$_REQUEST['compare_rev'][1];
    $manualorder = @$_REQUEST['manualorder'] == 1;
    $ignoreWhitespace = @$_REQUEST['ignorews'] == 1;
    // Some page links put the revision with the path...
    if (strpos($path1, '@')) {
        list($path1, $rev1) = explode('@', $path1);
    } else {
        if (strpos($path1, '@') === 0) {
            // Something went wrong. The path is missing.
            $rev1 = substr($path1, 1);
            $path1 = '/';
Пример #5
0
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// --
//
// revision.php
//
// Show the details for a given revision
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';
// Make sure that we have a repository
if ($rep) {
    $svnrep = new SVNRepository($rep);
    $ppath = $path == '' || $path[0] != '/' ? '/' . $path : $path;
    createPathLinks($rep, $ppath, $rev, $peg);
    $passRevString = createRevAndPegString($rev, $peg);
    // Find the youngest revision containing changes for the given path
    $history = $svnrep->getLog($path, 'HEAD', '', false, 2, $path == '/' ? '' : $peg);
    if (!$history) {
        unset($vars['error']);
        $history = $svnrep->getLog($path, '', '', false, 2, $path == '/' ? '' : $peg);
    }
    $youngest = $history ? $history->entries[0]->rev : 0;
    $vars['youngestrev'] = $youngest;
    // TODO The "youngest" rev is often incorrect when both path and rev are specified.
    // If a path was last modified at rev M and the URL contains rev N, it uses rev N.
    // Unless otherwise specified, we get the log details of the latest change
    $lastChangedRev = $rev ? $rev : $youngest;
Пример #6
0
        }
        $handle->close();
        @rmdir($dir);
        return true;
    }
    return false;
}
// Make sure that downloading the specified file/directory is permitted
if (!$rep->isDownloadAllowed($path)) {
    header('HTTP/1.x 403 Forbidden', true, 403);
    error_log('Unable to download resource at path: ' . $path);
    print 'Unable to download resource at path: ' . $path;
    exit;
}
if ($rep) {
    $svnrep = new SVNRepository($rep);
    // Fetch information about a revision (if unspecified, the latest) for this path
    if (empty($rev)) {
        $history = $svnrep->getLog($path, 'HEAD', '', true, 1, $peg);
    } else {
        if ($rev == $peg) {
            $history = $svnrep->getLog($path, '', 1, true, 1, $peg);
        } else {
            $history = $svnrep->getLog($path, $rev, $rev - 1, true, 1, $peg);
        }
    }
    $logEntry = $history ? $history->entries[0] : null;
    if (empty($rev)) {
        $rev = $logEntry->rev;
    }
    // Create a temporary filename to be used for a directory to archive a download.
Пример #7
0
// 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
//
// --
//
// filedetails.php
//
// Simply lists the contents of a file
require_once 'include/setup.php';
require_once 'include/svnlook.php';
require_once 'include/utils.php';
require_once 'include/template.php';
// Make sure that we have a repository
if ($rep) {
    $svnrep = new SVNRepository($rep);
    if ($path[0] != '/') {
        $ppath = '/' . $path;
    } else {
        $ppath = $path;
    }
    $useMime = false;
    // If there's no revision info, go to the lastest revision for this path
    $history = $svnrep->getLog($path, '', '', false, 2, $peg);
    $youngest = $history && isset($history->entries[0]) ? $history->entries[0]->rev : false;
    if (empty($rev)) {
        $rev = $youngest;
    } else {
        if ($rev > $youngest) {
            $vars['warning'] = 'Revision ' . $rev . ' of this resource does not exist.';
        }
Пример #8
0
    $ppath = $path;
}
if (!$rep) {
    header('HTTP/1.x 404 Not Found', true, 404);
    print 'Unable to access resource at path: ' . $path;
    exit;
}
// Make sure that the user has full access to the specified directory
if (!$rep->hasReadAccess($path, false)) {
    header('HTTP/1.x 403 Forbidden', true, 403);
    print 'Unable to access resource at path: ' . $path;
    exit;
}
header('Content-Type: application/xml; charset=utf-8');
// If there's no revision info, go to the lastest revision for this path
$svnrep = new SVNRepository($rep);
$history = $svnrep->getLog($path, $rev, '', false, $max, $peg);
if ($rep->isRssCachingEnabled()) {
    // Filename for storing a cached RSS feed for this particular path/revision
    $cache = $locwebsvnreal . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . strtr($rep->getDisplayName() . $path, ':/\\?', '____') . ($peg ? '@' . $peg : '') . ($rev ? '_r' . $rev : '') . 'm' . $max . ($quiet ? 'q' : '') . '.rss.xml';
    // If a recent-enough cached version exists, use it and avoid the work below
    if (file_exists($cache) && filemtime($cache) >= $history->curEntry->committime) {
        readfile($cache);
        exit;
    }
}
// Generate RSS 2.0 feed
$rss = '<?xml version="1.0" encoding="utf-8"?>';
$rss .= '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel>';
$rss .= '<title>' . htmlspecialchars($rep->getDisplayName() . ($path ? ' - ' . $path : '')) . '</title>';
$rss .= '<description>' . htmlspecialchars($lang['RSSFEEDTITLE'] . ' - ' . $repname) . '</description>';
Пример #9
0
    global $vars, $config;
    $subs = explode('/', $path);
    // 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;
    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, 0, $limit, $rev, $listing, 0, $config->treeView);
}
// Make sure that we have a repository
if ($rep) {
    $svnrep = new SVNRepository($rep);
    $history = $svnrep->getLog($path, 'HEAD', '', false, 2, $path == '/' ? '' : $peg);
    if (!$history) {
        unset($vars['error']);
        $history = $svnrep->getLog($path, '', '', false, 2, $path == '/' ? '' : $peg);
    }
    $youngest = $history && isset($history->entries[0]) ? $history->entries[0]->rev : 0;
    // Unless otherwise specified, we get the log details of the latest change
    $lastChangedRev = $passrev ? $passrev : $youngest;
    if ($lastChangedRev != $youngest) {
        $history = $svnrep->getLog($path, $lastChangedRev, '', false, 2, $peg);
    }
    $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
Пример #10
0
    // Remove empty string introduced by multiple spaces
    if (empty($words[$index])) {
        unset($words[$index]);
    }
}
if (empty($page)) {
    $page = 1;
}
// If searching, display all the results
if ($dosearch) {
    $all = true;
}
$maxperpage = 20;
// Make sure that we have a repository
if ($rep) {
    $svnrep = new SVNRepository($rep);
    $history = $svnrep->getLog($path, 'HEAD', '', false, 1, $path == '/' ? '' : $peg);
    if (!$history) {
        unset($vars['error']);
        $history = $svnrep->getLog($path, '', '', false, 1, $path == '/' ? '' : $peg);
    }
    $youngest = $history && isset($history->entries[0]) ? $history->entries[0]->rev : 0;
    if (empty($startrev)) {
        //$startrev = ($rev) ? $rev : 'HEAD';
        $startrev = $rev;
    } else {
        if ($startrev != 'HEAD' && $startrev != 'BASE' && $startrev != 'PREV' && $startrev != 'COMMITTED') {
            $startrev = (int) $startrev;
        }
    }
    if (empty($endrev)) {
Пример #11
0
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// --
//
// blame.php
//
// Show the blame information of a file.
//
require_once 'include/setup.php';
require_once 'include/svnlook.php';
require_once 'include/utils.php';
require_once 'include/template.php';
$vars['action'] = $lang['BLAME'];
// Make sure that we have a repository
if ($rep) {
    $svnrep = new SVNRepository($rep);
    // If there's no revision info, go to the lastest revision for this path
    $history = $svnrep->getLog($path, '', '', false, 2, $peg);
    $youngest = $history ? $history->entries[0]->rev : 0;
    if (empty($rev)) {
        $rev = $youngest;
    } else {
        $history = $svnrep->getLog($path, $rev, '', false, 2, $peg);
    }
    if ($path[0] != '/') {
        $ppath = '/' . $path;
    } else {
        $ppath = $path;
    }
    // Find the parent path (or the whole path if it's already a directory)
    $pos = strrpos($ppath, '/');