Rev Author Line No. Line
4988 kaklik 1 <?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 // multiviews.php
22 //
23 // Glue for MultiViews
24 chdir($locwebsvnreal);
25  
26 // Tell files that we are using multiviews if they are unable to access $config.
27 if (!defined('WSVN_MULTIVIEWS')) {
28 define('WSVN_MULTIVIEWS', 1);
29 }
30  
31 require_once 'include/setup.php';
32 require_once 'include/svnlook.php';
33  
34 if (!isset($_REQUEST['sc'])) {
35 $_REQUEST['sc'] = 1;
36 }
37  
38 if (!$config->multiViews) {
39 $vars['error'] = 'MultiViews must be enabled in <code>include/config.php</code> in order to use <code>browse.php</code>. See <a href="'.$locwebsvnhttp.'/doc/install.html#multiviews">the install docs</a> for details, or use <a href="'.$locwebsvnhttp.'">this path</a> instead.';
40 include $locwebsvnreal.'/index.php';
41 exit;
42 }
43  
44 $op = @$_REQUEST['op'];
45 // This means the user wants to browse another project, so we switch to it and exit.
46 if ($op == 'rep') {
47 $rep =& $config->findRepository(@$_REQUEST['repname']);
48 if ($rep != null) {
49 header('Location: '.$config->getURL($rep, '', 'dir'));
50 } else {
51 include $locwebsvnreal.'/index.php';
52 }
53 exit;
54 }
55  
56 $origPathInfo = isset($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : '';
57 $pathInfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';
58 $path = trim(empty($pathInfo) ? $origPathInfo : $pathInfo);
59  
60 // Remove initial slash
61 $path = substr($path, 1);
62 if (empty($path)) {
63 include $locwebsvnreal.'/index.php';
64 exit;
65 }
66  
67 // Split the path into repository and path elements
68 // Note: we have to cope with the repository name having a slash in it
69  
70 $pos = strpos($path, '/');
71 if ($pos === false) {
72 $pos = strlen($path);
73 }
74 $name = substr($path, 0, $pos);
75  
76 $rep =& $config->findRepository($name);
77 if ($rep != null && is_object($rep)) {
78 $path = substr($path, $pos);
79 if ($path == '') {
80 $path = '/';
81 }
82 $repname = $name;
83 } else {
84 include $locwebsvnreal.'/index.php';
85 exit;
86 }
87  
88 createProjectSelectionForm();
89 createRevisionSelectionForm();
90  
91 $vars['repurl'] = $config->getURL($rep, '', 'dir');
92 $vars['clientrooturl'] = $rep->clientRootURL;
93 $vars['allowdownload'] = $rep->getAllowDownload();
94 $vars['repname'] = escape($rep->getDisplayName());
95  
96 // find the operation type
97 switch ($op) {
98 case 'dir':
99 $file = 'listing.php';
100 break;
101 case 'revision':
102 $file = 'revision.php';
103 break;
104 case 'file':
105 $file = 'filedetails.php';
106 break;
107 case 'log':
108 $file = 'log.php';
109 break;
110 case 'diff':
111 $file = 'diff.php';
112 break;
113 case 'blame':
114 $file = 'blame.php';
115 break;
116 case 'rss':
117 $file = 'rss.php';
118 break;
119 case 'dl':
120 $file = 'dl.php';
121 break;
122 case 'comp':
123 $file = 'comp.php';
124 break;
125 case 'search':
126 $file = 'search.php';
127 break;
128 default:
129 $svnrep = new SVNRepository($rep);
130 if ($svnrep->isFile($path, $rev, $peg)) {
131 $file = 'filedetails.php';
132 } else {
133 $file = 'listing.php';
134 }
135 break;
136 }
137  
138 // Now include the file that handles it
139 include $locwebsvnreal.'/'.$file;