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 | | | // revision.php |
22 | | | // |
23 | | | // Show the details for a given revision |
24 | | | |
25 | | | require_once('include/setup.php'); |
26 | | | require_once('include/svnlook.php'); |
27 | | | require_once('include/utils.php'); |
28 | | | require_once('include/template.php'); |
29 | | | require_once('include/bugtraq.php'); |
30 | | | |
31 | | | // Make sure that we have a repository |
32 | | | if (!isset($rep)) { |
33 | | | echo $lang['NOREP']; |
34 | | | exit; |
35 | | | } |
36 | | | |
37 | | | $svnrep = new SVNRepository($rep); |
38 | | | |
39 | | | // Revision info to pass along chain |
40 | | | $passrev = $rev; |
41 | | | |
42 | | | // If there's no revision info, go to the lastest revision for this path |
43 | | | $history = $svnrep->getLog($path, '', '', false); |
44 | 3 | simandl | if (is_string($history)) { |
45 | | | echo $history; |
46 | | | exit; |
47 | | | } |
48 | 1 | simandl | |
49 | | | if (!empty($history->entries[0])) { |
50 | | | $youngest = $history->entries[0]->rev; |
51 | | | } else { |
52 | | | $youngest = -1; |
53 | | | } |
54 | | | |
55 | | | // Unless otherwise specified, we get the log details of the latest change |
56 | | | if (empty($rev)) { |
57 | | | $logrev = $youngest; |
58 | | | } else { |
59 | | | $logrev = $rev; |
60 | | | } |
61 | | | |
62 | | | if ($logrev != $youngest) { |
63 | | | $logEntry = $svnrep->getLog($path, $logrev, $logrev, false); |
64 | 3 | simandl | if (is_string($logEntry)) { |
65 | | | echo $logEntry; |
66 | | | exit; |
67 | | | } |
68 | | | $logEntry = $logEntry ? $logEntry->entries[0] : false; |
69 | 1 | simandl | } else { |
70 | | | $logEntry = isset($history->entries[0]) ? $history->entries[0]: false; |
71 | | | } |
72 | | | |
73 | | | $headlog = $svnrep->getLog('/', '', '', true, 1); |
74 | 3 | simandl | if (is_string($headlog)) { |
75 | | | echo $headlog; |
76 | | | exit; |
77 | | | } |
78 | 1 | simandl | $headrev = isset($headlog->entries[0]) ? $headlog->entries[0]->rev: 0; |
79 | | | |
80 | | | // If we're not looking at a specific revision, get the HEAD revision number |
81 | | | // (the revision of the rest of the tree display) |
82 | | | |
83 | | | if (empty($rev)) { |
84 | | | $rev = $headrev; |
85 | | | } |
86 | | | |
87 | | | if ($path == '' || $path{0} != '/') { |
88 | | | $ppath = '/'.$path; |
89 | | | } else { |
90 | | | $ppath = $path; |
91 | | | } |
92 | | | |
93 | | | $vars['repname'] = $rep->getDisplayName(); |
94 | | | |
95 | | | if ($passrev != 0 && $passrev != $headrev && $youngest != -1) { |
96 | | | $vars['goyoungestlink'] = '<a href="'.$config->getURL($rep, $path, 'revision').'opt=dir">'.$lang['GOYOUNGEST'].'</a>'; |
97 | | | } else { |
98 | | | $vars['goyoungestlink'] = ''; |
99 | | | } |
100 | | | |
101 | | | $vars['listingurl'] = $config->getURL($rep, $path, 'dir').'rev='.$passrev; |
102 | | | |
103 | | | $bugtraq = new Bugtraq($rep, $svnrep, $ppath); |
104 | | | |
105 | | | $vars['action'] = ''; |
106 | | | $vars['rev'] = $rev; |
107 | | | $vars['path'] = htmlentities($ppath, ENT_QUOTES, 'UTF-8'); |
108 | | | $vars['lastchangedrev'] = $logrev; |
109 | | | $vars['date'] = $logEntry ? $logEntry->date: ''; |
110 | | | $vars['author'] = $logEntry ? $logEntry->author: ''; |
111 | | | $vars['log'] = $logEntry ? nl2br($bugtraq->replaceIDs(create_anchors($logEntry->msg))): ''; |
112 | | | |
113 | 3 | simandl | $changes = $logEntry ? $logEntry->mods : array(); |
114 | 1 | simandl | if (!is_array($changes)) { |
115 | | | $changes = array(); |
116 | | | } |
117 | | | usort($changes, 'SVNLogEntry_compare'); |
118 | | | |
119 | | | $row = 0; |
120 | | | $listing = array(); |
121 | | | |
122 | | | foreach ($changes as $file) { |
123 | | | $listing[] = array( |
124 | | | 'file' => $file->path, |
125 | | | 'added' => $file->action == 'A', |
126 | | | 'modified' => $file->action == 'M', |
127 | | | 'deleted' => $file->action == 'D', |
128 | | | 'detailurl' => $config->getURL($rep, $file->path, 'file').'rev='.$passrev, |
129 | | | 'logurl' => $config->getURL($rep, $file->path, 'log').'rev='.$passrev.'&isdir=0', |
130 | | | 'diffurl' => $config->getURL($rep, $file->path, 'diff').'rev='.$passrev, |
131 | | | 'blameurl' => $config->getURL($rep, $file->path, 'blame').'rev='.$passrev, |
132 | | | 'rowparity' => $row, |
133 | | | ); |
134 | | | |
135 | | | $row = 1 - $row; |
136 | | | } |
137 | | | |
138 | | | createDirLinks($rep, $ppath, $passrev); |
139 | | | |
140 | | | $logurl = $config->getURL($rep, $path, 'log'); |
141 | | | $vars['logurl'] = $logurl.'rev='.$passrev.'&isdir=1'; |
142 | | | |
143 | | | $vars['indexurl'] = $config->getURL($rep, '', 'index'); |
144 | | | $vars['repurl'] = $config->getURL($rep, '', 'dir'); |
145 | | | |
146 | | | if ($rev != $headrev) { |
147 | 3 | simandl | $history = $svnrep->getLog($ppath, $rev, '', false); |
148 | | | if (is_string($history)) { |
149 | | | echo $history; |
150 | | | exit; |
151 | | | } |
152 | 1 | simandl | } |
153 | | | |
154 | | | if (isset($history->entries[1]->rev)) { |
155 | | | $compurl = $config->getURL($rep, '/', 'comp'); |
156 | | | $vars['curdircomplink'] = '<a href="'.$compurl.'compare[]='.urlencode($history->entries[1]->path).'@'.$history->entries[1]->rev. '&compare[]='.urlencode($history->entries[0]->path).'@'.$history->entries[0]->rev. '">'.$lang['DIFFPREV'].'</a>'; |
157 | | | $vars['compareurl'] = $compurl.'compare[]='.urlencode($history->entries[1]->path).'@'.$history->entries[1]->rev. '&compare[]='.urlencode($history->entries[0]->path).'@'.$history->entries[0]->rev; |
158 | | | } else { |
159 | | | $vars['curdircomplink'] = ''; |
160 | | | $vars['compareurl'] = ''; |
161 | | | } |
162 | | | |
163 | | | if ($rep->getHideRss()) { |
164 | | | $rssurl = $config->getURL($rep, $path, 'rss'); |
165 | | | // $vars["curdirrsslink"] = "<a href=\"${rssurl}rev=$passrev&isdir=1\">${lang["RSSFEED"]}</a>"; |
166 | | | // $vars["curdirrsshref"] = "${rssurl}rev=$passrev&isdir=1"; |
167 | | | // $vars["curdirrssanchor"] = "<a href=\"${rssurl}rev=$passrev&isdir=1\">"; |
168 | | | $vars['rssurl'] = $rssurl.'isdir=1'; |
169 | | | } |
170 | | | |
171 | | | $vars['version'] = $version; |
172 | | | |
173 | | | $vars['noaccess'] = !$rep->hasReadAccess($path, true); |
174 | | | |
175 | | | $vars['restricted'] = !$rep->hasReadAccess($path, false); |
176 | | | |
177 | | | parseTemplate($rep->getTemplatePath()."header.tmpl", $vars, $listing); |
178 | | | parseTemplate($rep->getTemplatePath()."revision.tmpl", $vars, $listing); |
179 | | | parseTemplate($rep->getTemplatePath()."footer.tmpl", $vars, $listing); |