Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +----------------------------------------------------------------------+
4
// | PHP version 5                                                        |
5
// +----------------------------------------------------------------------+
6
// | Copyright (c) 2004, Clay Loveless                                    |
7
// | All rights reserved.                                                 |
8
// +----------------------------------------------------------------------+
9
// | This LICENSE is in the BSD license style.                            |
10
// | http://www.opensource.org/licenses/bsd-license.php                   |
11
// |                                                                      |
12
// | Redistribution and use in source and binary forms, with or without   |
13
// | modification, are permitted provided that the following conditions   |
14
// | are met:                                                             |
15
// |                                                                      |
16
// |  * Redistributions of source code must retain the above copyright    |
17
// |    notice, this list of conditions and the following disclaimer.     |
18
// |                                                                      |
19
// |  * Redistributions in binary form must reproduce the above           |
20
// |    copyright notice, this list of conditions and the following       |
21
// |    disclaimer in the documentation and/or other materials provided   |
22
// |    with the distribution.                                            |
23
// |                                                                      |
24
// |  * Neither the name of Clay Loveless nor the names of contributors   |
25
// |    may be used to endorse or promote products derived from this      |
26
// |    software without specific prior written permission.               |
27
// |                                                                      |
28
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  |
29
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT    |
30
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    |
31
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE      |
32
// | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,  |
33
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
34
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;     |
35
// | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER     |
36
// | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT   |
37
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN    |
38
// | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE      |
39
// | POSSIBILITY OF SUCH DAMAGE.                                          |
40
// +----------------------------------------------------------------------+
41
// | Author: Clay Loveless <clay@killersoft.com>                          |
42
// +----------------------------------------------------------------------+
43
//
44
// $Id: example1.php 286753 2009-08-03 19:37:03Z mrook $
45
//
46
 
47
/*
48
    In this example, we'll get a list of files in a repository, and
49
    link to their contents.
50
*/
51
 
52
error_reporting(E_ALL);
53
ini_set('display_errors', 'on');
54
 
55
require_once 'VersionControl/SVN.php';
56
 
57
// Setup our error stack
58
$svnstack = &PEAR_ErrorStack::singleton('VersionControl_SVN');
59
 
60
// Default options
61
$base_url = 'svn://svn.killersoft.com/repos/VersionControl_SVN/trunk';
62
$base_add = isset($_GET['base_add']) ? '/'.$_GET['base_add'] : '';
63
$cmd = isset($_GET['cmd']) ? $_GET['cmd'] : 'list';
64
$options = array(
65
    'target'  => $base_url.$base_add
66
);
67
 
68
// Create svn object with subcommands we'll want
69
$svn = VersionControl_SVN::factory(array('list', 'cat'), $options);
70
 
71
 
72
// A quickie sample of browsing a Subversion repository
73
if ($cmd == 'cat') {
74
    $file = $_GET['file'];
75
    $options['target'] = $base_url.$base_add.'/'.$file;
76
    $svn->cat->setOptions($options);
77
    $source = $svn->cat->run();
78
    if (substr($file, -4) == '.php') {
79
        highlight_string($source);
80
    } else {
81
        echo "<pre>$source</pre>\n";
82
    }
83
 
84
} else {
85
    $list = $svn->list->run();
86
    $list_array = explode("\n", $list);
87
    foreach ($list_array as $item) {
88
        if (substr($item, -1) == '/') {
89
            $new_base = substr($item, 0, -1);
90
            echo "<a href=\"example1.php?cmd=list&base_add={$base_add}/{$new_base}\">$item</a><br />\n";
91
        } else {
92
            echo "<a href=\"example1.php?cmd=cat&file={$item}&base_add={$base_add}\">$item</a><br />\n";
93
        }
94
    }
95
}
96
 
97
// Check for errors
98
if (count($errs = $svnstack->getErrors())) {
99
    echo "<pre>\n";
100
    print_r($errs);
101
    echo "</pre>\n";
102
}
103
?>