1 | 1 | simandl | <?php |
2 | | | // WebSVN - Subversion repository viewing via the web using PHP |
3 | | | // Copyright (C) 2004-2006 Tim Armes |
4 | | | // |
5 | | | // This program is free software; you can redistribute it and/or modify |
6 | | | // it under the terms of the GNU General Public License as published by |
7 | | | // the Free Software Foundation; either version 2 of the License, or |
8 | | | // (at your option) any later version. |
9 | | | // |
10 | | | // This program is distributed in the hope that it will be useful, |
11 | | | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | | | // GNU General Public License for more details. |
14 | | | // |
15 | | | // You should have received a copy of the GNU General Public License |
16 | | | // along with this program; if not, write to the Free Software |
17 | | | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | | | // |
19 | | | // -- |
20 | | | // |
21 | | | // wsvn.php |
22 | | | // |
23 | | | // Glue for MultiViews |
24 | | | |
25 | | | // --- CONFIGURE THIS VARIABLE --- |
26 | | | |
27 | | | // Location of websvn directory via HTTP |
28 | | | // |
29 | 3 | simandl | // e.g. For "http://www.example.com/websvn" use "/websvn" |
30 | 1 | simandl | // |
31 | | | // Note that wsvn.php need not be in the /websvn directory (and normally isn't). |
32 | | | // If you want to use the root server directory, just use a blank string (''). |
33 | | | //$locwebsvnhttp = "/websvn"; |
34 | | | $locwebsvnhttp = ''; |
35 | | | |
36 | 3 | simandl | // Physical location of websvn directory. Change this if your wsvn.php is not in |
37 | | | // the same folder as the rest of the distribution |
38 | 1 | simandl | $locwebsvnreal = dirname(__FILE__); |
39 | | | |
40 | | | // --- DON'T CHANGE BELOW HERE --- |
41 | | | |
42 | | | chdir($locwebsvnreal); |
43 | | | |
44 | 3 | simandl | // Tell files that we are using multiviews if they are unable to access $config. |
45 | 1 | simandl | if (!defined('WSVN_MULTIVIEWS')) { |
46 | | | define('WSVN_MULTIVIEWS', 1); |
47 | | | } |
48 | | | |
49 | | | ini_set("include_path", $locwebsvnreal); |
50 | | | |
51 | | | require_once("include/setup.php"); |
52 | | | require_once("include/svnlook.php"); |
53 | | | |
54 | | | if (!isset($_REQUEST["sc"])) { |
55 | | | $_REQUEST["sc"] = 1; |
56 | | | } |
57 | | | |
58 | | | if ($config->multiViews) { |
59 | | | // If this is a form handling request, deal with it |
60 | | | if (@$_REQUEST["op"] == "form") { |
61 | | | include("$locwebsvnreal/form.php"); |
62 | | | exit; |
63 | | | } |
64 | | | |
65 | | | $origPathInfo = isset($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : ''; |
66 | | | $pathInfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; |
67 | | | $path = trim(empty($pathInfo) ? $origPathInfo : $pathInfo); |
68 | | | |
69 | | | // Remove initial slash |
70 | | | $path = substr($path, 1); |
71 | | | if (empty($path)) { |
72 | | | include("$locwebsvnreal/index.php"); |
73 | | | exit; |
74 | | | } |
75 | | | |
76 | | | // Split the path into repository and path elements |
77 | | | // Note: we have to cope with the repository name |
78 | | | // having a slash in it |
79 | | | |
80 | | | $pos = strpos($path, '/'); |
81 | | | if ($pos === false) { |
82 | | | $pos = strlen($path); |
83 | | | } |
84 | | | $name = substr($path, 0, $pos); |
85 | | | |
86 | 3 | simandl | $rep =& $config->findRepository($name); |
87 | | | if ($rep != null) { |
88 | | | $path = substr($path, $pos); |
89 | | | if ($path == '') { |
90 | | | $path = '/'; |
91 | 1 | simandl | } |
92 | 3 | simandl | } else { |
93 | 1 | simandl | include("$locwebsvnreal/index.php"); |
94 | | | exit; |
95 | | | } |
96 | | | |
97 | | | createProjectSelectionForm(); |
98 | | | createRevisionSelectionForm(); |
99 | | | $vars["allowdownload"] = $rep->getAllowDownload(); |
100 | 3 | simandl | $vars["repname"] = htmlentities($rep->getDisplayName(), ENT_QUOTES, 'UTF-8'); |
101 | 1 | simandl | |
102 | | | // find the operation type |
103 | | | $op = @$_REQUEST["op"]; |
104 | | | switch ($op) { |
105 | | | case "dir": |
106 | | | $file = "listing.php"; |
107 | | | break; |
108 | | | case "revision": |
109 | | | $file = "revision.php"; |
110 | | | break; |
111 | | | case "file": |
112 | | | $file = "filedetails.php"; |
113 | | | break; |
114 | | | case "log": |
115 | | | $file = "log.php"; |
116 | | | break; |
117 | | | case "diff": |
118 | | | $file = "diff.php"; |
119 | | | break; |
120 | | | case "blame": |
121 | | | $file = "blame.php"; |
122 | | | break; |
123 | | | case "rss": |
124 | | | $file = "rss.php"; |
125 | | | break; |
126 | | | case "dl": |
127 | | | $file = "dl.php"; |
128 | | | break; |
129 | | | case "comp": |
130 | | | $file = "comp.php"; |
131 | | | break; |
132 | | | default: |
133 | 3 | simandl | $svnrep = new SVNRepository($rep); |
134 | | | if ($svnrep->isFile($path, $rev)) { |
135 | 1 | simandl | $file = "filedetails.php"; |
136 | 3 | simandl | } else { |
137 | | | $file = "listing.php"; |
138 | 1 | simandl | } |
139 | | | break; |
140 | | | } |
141 | | | |
142 | | | // Now include the file that handles it |
143 | | | include("$locwebsvnreal/$file"); |
144 | | | |
145 | | | } else { |
146 | | | print "<p>MultiViews must be configured in config.php in order to use this file"; |
147 | | | exit; |
148 | | | } |