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