Line 1... |
Line 1... |
1 |
<?php |
1 |
<?php |
2 |
# vim:et:ts=3:sts=3:sw=3:fdm=marker: |
- |
|
3 |
|
- |
|
4 |
// WebSVN - Subversion repository viewing via the web using PHP |
2 |
// WebSVN - Subversion repository viewing via the web using PHP |
5 |
// Copyright © 2004-2006 Tim Armes, Matt Sicker |
3 |
// Copyright (C) 2004-2006 Tim Armes |
6 |
// |
4 |
// |
7 |
// This program is free software; you can redistribute it and/or modify |
5 |
// 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 |
6 |
// 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 |
7 |
// the Free Software Foundation; either version 2 of the License, or |
10 |
// (at your option) any later version. |
8 |
// (at your option) any later version. |
11 |
// |
9 |
// |
12 |
// This program is distributed in the hope that it will be useful, |
10 |
// This program is distributed in the hope that it will be useful, |
13 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
// GNU General Public License for more details. |
13 |
// GNU General Public License for more details. |
16 |
// |
14 |
// |
17 |
// You should have received a copy of the GNU General Public License |
15 |
// You should have received a copy of the GNU General Public License |
18 |
// along with this program; if not, write to the Free Software |
16 |
// along with this program; if not, write to the Free Software |
19 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
// |
18 |
// |
21 |
// -- |
19 |
// -- |
22 |
// |
20 |
// |
23 |
// log.php |
21 |
// log.php |
24 |
// |
22 |
// |
25 |
// Show the logs for the given path |
23 |
// Show the logs for the given path |
26 |
|
24 |
|
27 |
require_once("include/setup.inc"); |
25 |
require_once 'include/setup.php'; |
28 |
require_once("include/svnlook.inc"); |
26 |
require_once 'include/svnlook.php'; |
29 |
require_once("include/utils.inc"); |
27 |
require_once 'include/utils.php'; |
30 |
require_once("include/template.inc"); |
28 |
require_once 'include/template.php'; |
31 |
require_once("include/bugtraq.inc"); |
29 |
require_once 'include/bugtraq.php'; |
32 |
|
30 |
|
33 |
$page = (int)@$_REQUEST["page"]; |
31 |
$page = (int)@$_REQUEST['page']; |
34 |
$all = (@$_REQUEST["all"] == 1)?1:0; |
32 |
$all = @$_REQUEST['all'] == 1; |
35 |
$isDir = (@$_REQUEST["isdir"] == 1)?1:0; |
33 |
$isDir = @$_REQUEST['isdir'] == 1 || $path == '' || $path == '/'; |
- |
|
34 |
|
- |
|
35 |
// Make sure that we have a repository |
- |
|
36 |
if (!$rep) |
- |
|
37 |
{ |
- |
|
38 |
renderTemplate404('log','NOREP'); |
- |
|
39 |
} |
- |
|
40 |
|
- |
|
41 |
if (isset($_REQUEST['showchanges'])) |
- |
|
42 |
{ |
36 |
$dosearch = (@$_REQUEST["logsearch"] == 1)?1:0; |
43 |
$showchanges = @$_REQUEST['showchanges'] == 1; |
- |
|
44 |
} |
- |
|
45 |
else |
- |
|
46 |
{ |
- |
|
47 |
$showchanges = $rep->logsShowChanges(); |
- |
|
48 |
} |
- |
|
49 |
|
37 |
$search = trim(@$_REQUEST["search"]); |
50 |
$search = trim((string) @$_REQUEST['search']); |
- |
|
51 |
$dosearch = strlen($search) > 0; |
- |
|
52 |
|
38 |
$words = preg_split('#\s+#', $search); |
53 |
$words = preg_split('#\s+#', $search); |
39 |
$fromRev = (int)@$_REQUEST["fr"]; |
54 |
$fromRev = (int)@$_REQUEST['fr']; |
40 |
$startrev = strtoupper(trim(@$_REQUEST["sr"])); |
55 |
$startrev = strtoupper(trim((string) @$_REQUEST['sr'])); |
41 |
$endrev = strtoupper(trim(@$_REQUEST["er"])); |
56 |
$endrev = strtoupper(trim((string) @$_REQUEST['er'])); |
42 |
$max = @$_REQUEST["max"]; |
57 |
$max = isset($_REQUEST['max']) ? (int)$_REQUEST['max'] : false; |
43 |
|
58 |
|
44 |
// Max number of results to find at a time |
59 |
// Max number of results to find at a time |
45 |
$numSearchResults = 15; |
60 |
$numSearchResults = 20; |
46 |
|
61 |
|
47 |
if ($search == "") |
62 |
if ($search == '') |
- |
|
63 |
{ |
48 |
$dosearch = false; |
64 |
$dosearch = false; |
- |
|
65 |
} |
49 |
|
66 |
|
50 |
// removeAccents |
67 |
// removeAccents |
51 |
// |
68 |
// |
52 |
// Remove all the accents from a string. This function doesn't seem |
69 |
// Remove all the accents from a string. This function doesn't seem |
53 |
// ideal, but expecting everyone to install 'unac' seems a little |
70 |
// ideal, but expecting everyone to install 'unac' seems a little |
54 |
// excessive as well... |
71 |
// excessive as well... |
55 |
|
72 |
|
56 |
function removeAccents($string) |
73 |
function removeAccents($string) |
57 |
{ |
74 |
{ |
58 |
return strtr($string, |
75 |
$string = htmlentities($string, ENT_QUOTES, 'ISO-8859-1'); |
59 |
"ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ", |
76 |
$string = preg_replace('/&([A-Za-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron);/', '$1', $string); |
60 |
"AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn"); |
77 |
return $string; |
61 |
} |
78 |
} |
62 |
|
79 |
|
63 |
// Normalise the search words |
80 |
// Normalise the search words |
64 |
foreach ($words as $index => $word) |
81 |
foreach ($words as $index => $word) |
65 |
{ |
82 |
{ |
66 |
$words[$index] = strtolower(removeAccents($word)); |
83 |
$words[$index] = strtolower(removeAccents($word)); |
67 |
|
84 |
|
68 |
// Remove empty string introduced by multiple spaces |
85 |
// Remove empty string introduced by multiple spaces |
69 |
if (empty($words[$index])) |
86 |
if (empty($words[$index])) |
70 |
unset($words[$index]); |
87 |
unset($words[$index]); |
71 |
} |
88 |
} |
72 |
|
89 |
|
73 |
if (empty($page)) $page = 1; |
90 |
if (empty($page)) |
- |
|
91 |
{ |
- |
|
92 |
$page = 1; |
- |
|
93 |
} |
74 |
|
94 |
|
75 |
// If searching, display all the results |
95 |
// If searching, display all the results |
76 |
$all = (bool) $dosearch; |
96 |
if ($dosearch) |
- |
|
97 |
{ |
- |
|
98 |
$all = true; |
- |
|
99 |
} |
77 |
|
100 |
|
78 |
$maxperpage = 20; |
101 |
$maxperpage = 20; |
79 |
|
102 |
|
80 |
// Make sure that we have a repository |
103 |
$svnrep = new SVNRepository($rep); |
- |
|
104 |
|
- |
|
105 |
$history = $svnrep->getLog($path, 'HEAD', '', false, 1, ($path == '/') ? '' : $peg); |
- |
|
106 |
|
81 |
if (!isset($rep)) |
107 |
if (!$history) |
82 |
{ |
108 |
{ |
83 |
echo $lang["NOREP"]; |
109 |
unset($vars['error']); |
- |
|
110 |
$history = $svnrep->getLog($path, '', '', false, 1, ($path == '/') ? '' : $peg); |
- |
|
111 |
|
84 |
exit; |
112 |
if (!$history) |
- |
|
113 |
{ |
- |
|
114 |
renderTemplate404('log','NOPATH'); |
- |
|
115 |
} |
85 |
} |
116 |
} |
86 |
|
117 |
|
87 |
$svnrep = new SVNRepository($rep); |
118 |
$youngest = ($history && isset($history->entries[0])) ? $history->entries[0]->rev : 0; |
88 |
|
119 |
|
- |
|
120 |
if (empty($startrev)) |
- |
|
121 |
{ |
- |
|
122 |
//$startrev = ($rev) ? $rev : 'HEAD'; |
89 |
$passrev = $rev; |
123 |
$startrev = $rev; |
- |
|
124 |
} |
- |
|
125 |
else if ($startrev != 'HEAD' && $startrev != 'BASE' && $startrev != 'PREV' && $startrev != 'COMMITTED') |
- |
|
126 |
{ |
- |
|
127 |
$startrev = (int)$startrev; |
- |
|
128 |
} |
- |
|
129 |
|
- |
|
130 |
if (empty($endrev)) |
- |
|
131 |
{ |
- |
|
132 |
$endrev = 1; |
- |
|
133 |
} |
- |
|
134 |
else if ($endrev != 'HEAD' && $endrev != 'BASE' && $endrev != 'PREV' && $endrev != 'COMMITTED') |
- |
|
135 |
{ |
- |
|
136 |
$endrev = (int)$endrev; |
- |
|
137 |
} |
90 |
|
138 |
|
91 |
// If there's no revision info, go to the lastest revision for this path |
- |
|
92 |
$history = $svnrep->getLog($path, "", "", true); |
139 |
if (empty($rev)) |
- |
|
140 |
{ |
93 |
$youngest = $history->entries[0]->rev; |
141 |
$rev = $youngest; |
- |
|
142 |
} |
94 |
|
143 |
|
95 |
if (empty($rev)) |
144 |
if (empty($startrev)) |
- |
|
145 |
{ |
96 |
$rev = $youngest; |
146 |
$startrev = $rev; |
- |
|
147 |
} |
97 |
|
148 |
|
98 |
// make sure path is prefixed by a / |
149 |
// make sure path is prefixed by a / |
99 |
$ppath = $path; |
150 |
$ppath = $path; |
100 |
if ($path == "" || $path{0} != "/") |
- |
|
101 |
$ppath = "/".$path; |
- |
|
102 |
|
151 |
|
- |
|
152 |
if ($path == '' || $path[0] != '/') |
- |
|
153 |
{ |
- |
|
154 |
$ppath = '/'.$path; |
- |
|
155 |
} |
- |
|
156 |
|
103 |
$vars["action"] = $lang["LOG"]; |
157 |
$vars['action'] = $lang['LOG']; |
104 |
$vars["repname"] = $rep->getDisplayName(); |
158 |
$vars['rev'] = $rev; |
105 |
$vars["rev"] = $rev; |
159 |
$vars['peg'] = $peg; |
- |
|
160 |
$vars['path'] = str_replace('%2F', '/', rawurlencode($ppath)); |
106 |
$vars["path"] = $ppath; |
161 |
$vars['safepath'] = escape($ppath); |
- |
|
162 |
|
- |
|
163 |
if ($history && isset($history->entries[0])) |
- |
|
164 |
{ |
- |
|
165 |
$vars['log'] = xml_entities($history->entries[0]->msg); |
- |
|
166 |
$vars['date'] = $history->entries[0]->date; |
- |
|
167 |
$vars['age'] = datetimeFormatDuration(time() - strtotime($history->entries[0]->date)); |
- |
|
168 |
$vars['author'] = $history->entries[0]->author; |
- |
|
169 |
} |
- |
|
170 |
|
- |
|
171 |
if ($max === false) |
- |
|
172 |
{ |
- |
|
173 |
$max = ($dosearch) ? 0 : 40; |
- |
|
174 |
} |
- |
|
175 |
else if ($max < 0) |
- |
|
176 |
{ |
- |
|
177 |
$max = 40; |
- |
|
178 |
} |
- |
|
179 |
|
- |
|
180 |
// TODO: If the rev is less than the head, get the path (may have been renamed!) |
- |
|
181 |
// Will probably need to call `svn info`, parse XML output, and substring a path |
107 |
|
182 |
|
108 |
createDirLinks($rep, $ppath, $passrev, $showchanged); |
183 |
createPathLinks($rep, $ppath, $passrev, $peg); |
- |
|
184 |
$passRevString = createRevAndPegString($rev, $peg); |
- |
|
185 |
$isDirString = ($isDir) ? 'isdir=1&' : ''; |
- |
|
186 |
|
- |
|
187 |
unset($queryParams['repname']); |
- |
|
188 |
unset($queryParams['path']); |
- |
|
189 |
|
- |
|
190 |
// Toggle 'showchanges' param for link to switch from the current behavior |
- |
|
191 |
if ($showchanges == $rep->logsShowChanges()) |
- |
|
192 |
{ |
- |
|
193 |
$queryParams['showchanges'] = (int)!$showchanges; |
- |
|
194 |
} |
- |
|
195 |
else |
- |
|
196 |
{ |
- |
|
197 |
unset($queryParams['showchanges']); |
- |
|
198 |
} |
109 |
|
199 |
|
110 |
$logurl = $config->getURL($rep, $path, "log"); |
200 |
$vars['changesurl'] = $config->getURL($rep, $path, 'log').buildQuery($queryParams); |
- |
|
201 |
$vars['changeslink'] = '<a href="'.$vars['changesurl'].'">'.$lang[($showchanges ? 'HIDECHANGED' : 'SHOWCHANGED')].'</a>'; |
- |
|
202 |
$vars['showchanges'] = $showchanges; |
111 |
|
203 |
|
- |
|
204 |
// Revert 'showchanges' param to propagate the current behavior |
112 |
if ($rev != $youngest) |
205 |
if ($showchanges == $rep->logsShowChanges()) |
- |
|
206 |
{ |
113 |
$vars["goyoungestlink"] = "<a href=\"${logurl}sc=1\">${lang["GOYOUNGEST"]}</a>"; |
207 |
unset($queryParams['showchanges']); |
- |
|
208 |
} |
114 |
else |
209 |
else |
- |
|
210 |
{ |
- |
|
211 |
$queryParams['showchanges'] = (int)$showchanges; |
- |
|
212 |
} |
- |
|
213 |
|
- |
|
214 |
$vars['revurl'] = $config->getURL($rep, $path, 'revision').$isDirString.$passRevString; |
- |
|
215 |
|
- |
|
216 |
if ($isDir) |
- |
|
217 |
{ |
- |
|
218 |
$vars['directoryurl'] = $config->getURL($rep, $path, 'dir').$passRevString.'#'.anchorForPath($path); |
- |
|
219 |
$vars['directorylink'] = '<a href="'.$vars['directoryurl'].'">'.$lang['LISTING'].'</a>'; |
- |
|
220 |
} |
- |
|
221 |
else |
- |
|
222 |
{ |
- |
|
223 |
$vars['filedetailurl'] = $config->getURL($rep, $path, 'file').$passRevString; |
- |
|
224 |
$vars['filedetaillink'] = '<a href="'.$vars['filedetailurl'].'">'.$lang['FILEDETAIL'].'</a>'; |
- |
|
225 |
|
- |
|
226 |
$vars['blameurl'] = $config->getURL($rep, $path, 'blame').$passRevString; |
- |
|
227 |
$vars['blamelink'] = '<a href="'.$vars['blameurl'].'">'.$lang['BLAME'].'</a>'; |
- |
|
228 |
|
- |
|
229 |
$vars['diffurl'] = $config->getURL($rep, $path, 'diff').$passRevString; |
- |
|
230 |
$vars['difflink'] = '<a href="'.$vars['diffurl'].'">'.$lang['DIFFPREV'].'</a>'; |
- |
|
231 |
} |
- |
|
232 |
|
- |
|
233 |
if ($rep->isRssEnabled()) |
- |
|
234 |
{ |
- |
|
235 |
$vars['rssurl'] = $config->getURL($rep, $path, 'rss').$isDirString.createRevAndPegString('', $peg); |
- |
|
236 |
$vars['rsslink'] = '<a href="'.$vars['rssurl'].'">'.$lang['RSSFEED'].'</a>'; |
- |
|
237 |
} |
- |
|
238 |
|
115 |
$vars["goyoungestlink"] = ""; |
239 |
if ($rev != $youngest) |
- |
|
240 |
{ |
- |
|
241 |
if ($path == '/') |
- |
|
242 |
{ |
- |
|
243 |
$vars['goyoungesturl'] = $config->getURL($rep, '', 'log').$isDirString; |
- |
|
244 |
} |
- |
|
245 |
else |
- |
|
246 |
{ |
- |
|
247 |
$vars['goyoungesturl'] = $config->getURL($rep, $path, 'log').$isDirString.'peg='.($peg ? $peg : $rev); |
- |
|
248 |
} |
- |
|
249 |
|
- |
|
250 |
$vars['goyoungestlink'] = '<a href="'.$vars['goyoungesturl'].'"'.($youngest ? ' title="'.$lang['REV'].' '.$youngest.'"' : '').'>'.$lang['GOYOUNGEST'].'</a>'; |
- |
|
251 |
} |
116 |
|
252 |
|
117 |
// We get the bugtraq variable just once based on the HEAD |
253 |
// We get the bugtraq variable just once based on the HEAD |
118 |
$bugtraq = new Bugtraq($rep, $svnrep, $ppath); |
254 |
$bugtraq = new Bugtraq($rep, $svnrep, $ppath); |
119 |
|
255 |
|
- |
|
256 |
$vars['logsearch_moreresultslink'] = ''; |
- |
|
257 |
$vars['pagelinks'] = ''; |
- |
|
258 |
$vars['showalllink'] = ''; |
- |
|
259 |
|
- |
|
260 |
if ($history) |
- |
|
261 |
{ |
120 |
if ($startrev != "HEAD") $startrev = (int)$startrev; |
262 |
$history = $svnrep->getLog($path, $startrev, $endrev, true, $max, $peg); |
- |
|
263 |
|
121 |
if (empty($startrev)) $startrev = $rev; |
264 |
if (empty($history)) |
- |
|
265 |
{ |
122 |
if (empty($endrev)) $endrev = 1; |
266 |
unset($vars['error']); |
- |
|
267 |
$vars['warning'] = 'Revision '.$startrev.' of this resource does not exist.'; |
- |
|
268 |
} |
- |
|
269 |
} |
123 |
|
270 |
|
124 |
if (empty($_REQUEST["max"])) |
271 |
if (!empty($history)) |
125 |
{ |
272 |
{ |
- |
|
273 |
// Get the number of separate revisions |
- |
|
274 |
$revisions = count($history->entries); |
- |
|
275 |
|
- |
|
276 |
if ($all) |
- |
|
277 |
{ |
- |
|
278 |
$firstrevindex = 0; |
- |
|
279 |
$lastrevindex = $revisions - 1; |
- |
|
280 |
$pages = 1; |
- |
|
281 |
} |
- |
|
282 |
else |
- |
|
283 |
{ |
- |
|
284 |
// Calculate the number of pages |
- |
|
285 |
$pages = floor($revisions / $maxperpage); |
- |
|
286 |
if (($revisions % $maxperpage) > 0) $pages++; |
- |
|
287 |
|
- |
|
288 |
if ($page > $pages) $page = $pages; |
- |
|
289 |
|
- |
|
290 |
// Work out where to start and stop |
- |
|
291 |
$firstrevindex = ($page - 1) * $maxperpage; |
- |
|
292 |
$lastrevindex = min($firstrevindex + $maxperpage - 1, $revisions - 1); |
- |
|
293 |
} |
- |
|
294 |
|
- |
|
295 |
$frev = isset($history->entries[0]) ? $history->entries[0]->rev : false; |
- |
|
296 |
$brev = isset($history->entries[$firstrevindex]) ? $history->entries[$firstrevindex]->rev : false; |
- |
|
297 |
$erev = isset($history->entries[$lastrevindex]) ? $history->entries[$lastrevindex]->rev : false; |
- |
|
298 |
|
- |
|
299 |
$entries = array(); |
- |
|
300 |
|
- |
|
301 |
if ($brev && $erev) |
- |
|
302 |
{ |
- |
|
303 |
$history = $svnrep->getLog($path, $brev, $erev, false, 0, $peg, true); |
- |
|
304 |
if ($history) |
- |
|
305 |
{ |
- |
|
306 |
$entries = $history->entries; |
- |
|
307 |
} |
- |
|
308 |
} |
- |
|
309 |
|
- |
|
310 |
$row = 0; |
- |
|
311 |
$index = 0; |
- |
|
312 |
$found = false; |
- |
|
313 |
|
- |
|
314 |
foreach ($entries as $revision) |
- |
|
315 |
{ |
- |
|
316 |
// Assume a good match |
- |
|
317 |
$match = true; |
- |
|
318 |
$thisrev = $revision->rev; |
- |
|
319 |
|
- |
|
320 |
// Check the log for the search words, if searching |
- |
|
321 |
if ($dosearch) |
- |
|
322 |
{ |
- |
|
323 |
if ((empty($fromRev) || $fromRev > $thisrev)) |
- |
|
324 |
{ |
- |
|
325 |
// Turn all the HTML entities into real characters. |
- |
|
326 |
|
- |
|
327 |
// Make sure that each word in the search in also in the log |
- |
|
328 |
foreach ($words as $word) |
- |
|
329 |
{ |
- |
|
330 |
if (strpos(strtolower(removeAccents($revision->msg)), $word) === false && strpos(strtolower(removeAccents($revision->author)), $word) === false) |
- |
|
331 |
{ |
- |
|
332 |
$match = false; |
- |
|
333 |
break; |
- |
|
334 |
} |
- |
|
335 |
} |
- |
|
336 |
|
- |
|
337 |
if ($match) |
- |
|
338 |
{ |
- |
|
339 |
$numSearchResults--; |
- |
|
340 |
$found = true; |
- |
|
341 |
} |
- |
|
342 |
} |
- |
|
343 |
else |
- |
|
344 |
{ |
- |
|
345 |
$match = false; |
- |
|
346 |
} |
- |
|
347 |
} |
- |
|
348 |
|
- |
|
349 |
$thisRevString = createRevAndPegString($thisrev, ($peg ? $peg : $thisrev)); |
- |
|
350 |
|
- |
|
351 |
if ($match) |
- |
|
352 |
{ |
- |
|
353 |
// Add the trailing slash if we need to (svnlook history doesn't return trailing slashes!) |
- |
|
354 |
$rpath = $revision->path; |
- |
|
355 |
|
- |
|
356 |
if (empty($rpath)) |
- |
|
357 |
{ |
- |
|
358 |
$rpath = '/'; |
- |
|
359 |
} |
- |
|
360 |
else if ($isDir && $rpath[strlen($rpath) - 1] != '/') |
- |
|
361 |
{ |
- |
|
362 |
$rpath .= '/'; |
- |
|
363 |
} |
- |
|
364 |
|
- |
|
365 |
$precisePath = $revision->precisePath; |
126 |
if (empty($_REQUEST["logsearch"])) |
366 |
if (empty($precisePath)) |
- |
|
367 |
{ |
- |
|
368 |
$precisePath = '/'; |
- |
|
369 |
} |
- |
|
370 |
else if ($isDir && $precisePath[strlen($precisePath) - 1] != '/') |
- |
|
371 |
{ |
- |
|
372 |
$precisePath .= '/'; |
- |
|
373 |
} |
- |
|
374 |
|
- |
|
375 |
// Find the parent path (or the whole path if it's already a directory) |
- |
|
376 |
$pos = strrpos($rpath, '/'); |
- |
|
377 |
$parent = substr($rpath, 0, $pos + 1); |
- |
|
378 |
|
- |
|
379 |
$compareValue = (($isDir) ? $parent : $rpath).'@'.$thisrev; |
- |
|
380 |
|
- |
|
381 |
$listvar = &$listing[$index]; |
- |
|
382 |
$listvar['compare_box'] = '<input type="checkbox" name="compare[]" value="'.$compareValue.'" onclick="enforceOnlyTwoChecked(this)" />'; |
- |
|
383 |
$url = $config->getURL($rep, $rpath, 'revision').$thisRevString; |
- |
|
384 |
$listvar['revlink'] = '<a href="'.$url.'">'.$thisrev.'</a>'; |
- |
|
385 |
|
- |
|
386 |
$url = $config->getURL($rep, $precisePath, ($isDir ? 'dir' : 'file')).$thisRevString; |
- |
|
387 |
|
- |
|
388 |
$listvar['revpathlink'] = '<a href="'.$url.'">'.escape($precisePath).'</a>'; |
- |
|
389 |
$listvar['revpath'] = escape($precisePath); |
- |
|
390 |
$listvar['revauthor'] = $revision->author; |
- |
|
391 |
$listvar['revdate'] = $revision->date; |
- |
|
392 |
$listvar['revage'] = $revision->age; |
- |
|
393 |
$listvar['revlog'] = nl2br($bugtraq->replaceIDs(create_anchors(xml_entities($revision->msg)))); |
- |
|
394 |
$listvar['rowparity'] = $row; |
- |
|
395 |
$listvar['compareurl'] = $config->getURL($rep, '', 'comp').'compare[]='.urlencode($rpath).'@'.($thisrev - 1).'&compare[]='.urlencode($rpath).'@'.$thisrev; |
- |
|
396 |
|
- |
|
397 |
if ($showchanges) |
- |
|
398 |
{ |
- |
|
399 |
// Aggregate added/deleted/modified paths for display in table |
- |
|
400 |
$modpaths = array(); |
- |
|
401 |
|
- |
|
402 |
foreach ($revision->mods as $mod) |
- |
|
403 |
{ |
- |
|
404 |
$modpaths[$mod->action][] = $mod->path; |
- |
|
405 |
} |
- |
|
406 |
|
- |
|
407 |
ksort($modpaths); |
- |
|
408 |
|
- |
|
409 |
foreach ($modpaths as $action => $paths) |
- |
|
410 |
{ |
- |
|
411 |
sort($paths); |
- |
|
412 |
$modpaths[$action] = $paths; |
- |
|
413 |
} |
- |
|
414 |
|
- |
|
415 |
$listvar['revadded'] = (isset($modpaths['A'])) ? implode('<br/>', escape($modpaths['A'])) : ''; |
- |
|
416 |
$listvar['revdeleted'] = (isset($modpaths['D'])) ? implode('<br/>', escape($modpaths['D'])) : ''; |
- |
|
417 |
$listvar['revmodified'] = (isset($modpaths['M'])) ? implode('<br/>', escape($modpaths['M'])) : ''; |
- |
|
418 |
} |
- |
|
419 |
|
- |
|
420 |
$row = 1 - $row; |
- |
|
421 |
$index++; |
- |
|
422 |
} |
- |
|
423 |
|
- |
|
424 |
// If we've reached the search limit, stop here... |
- |
|
425 |
if (!$numSearchResults) |
- |
|
426 |
{ |
- |
|
427 |
$url = $config->getURL($rep, $path, 'log').$isDirString.$thisRevString; |
- |
|
428 |
$vars['logsearch_moreresultslink'] = '<a href="'.$url.'&search='.$search.'&fr='.$thisrev.'">'.$lang['MORERESULTS'].'</a>'; |
- |
|
429 |
break; |
- |
|
430 |
} |
- |
|
431 |
} |
- |
|
432 |
|
- |
|
433 |
$vars['logsearch_resultsfound'] = true; |
- |
|
434 |
|
- |
|
435 |
if ($dosearch && !$found) |
- |
|
436 |
{ |
127 |
$max = 30; |
437 |
if ($fromRev == 0) |
- |
|
438 |
{ |
- |
|
439 |
$vars['logsearch_nomatches'] = true; |
- |
|
440 |
$vars['logsearch_resultsfound'] = false; |
- |
|
441 |
} |
128 |
else |
442 |
else |
- |
|
443 |
{ |
- |
|
444 |
$vars['logsearch_nomorematches'] = true; |
- |
|
445 |
} |
- |
|
446 |
} |
- |
|
447 |
else if ($dosearch && $numSearchResults > 0) |
- |
|
448 |
{ |
- |
|
449 |
$vars['logsearch_nomorematches'] = true; |
- |
|
450 |
} |
- |
|
451 |
|
- |
|
452 |
// Work out the paging options, create links to pages of results |
- |
|
453 |
if ($pages > 1) |
- |
|
454 |
{ |
- |
|
455 |
$prev = $page - 1; |
- |
|
456 |
$next = $page + 1; |
- |
|
457 |
|
- |
|
458 |
unset($queryParams['page']); |
- |
|
459 |
$logurl = $config->getURL($rep, $path, 'log').buildQuery($queryParams); |
- |
|
460 |
|
129 |
$max = 0; |
461 |
if ($page > 1) |
- |
|
462 |
{ |
- |
|
463 |
$vars['pagelinks'] .= '<a href="'.$logurl.(!$peg && $frev && $prev != 1 ? '&peg='.$frev : '').'&page='.$prev.'">←'.$lang['PREV'].'</a>'; |
- |
|
464 |
} |
- |
|
465 |
else |
- |
|
466 |
{ |
- |
|
467 |
$vars['pagelinks'] .= '<span>←'.$lang['PREV'].'</span>'; |
- |
|
468 |
} |
- |
|
469 |
|
- |
|
470 |
for ($p = 1; $p <= $pages; $p++) |
- |
|
471 |
{ |
- |
|
472 |
if ($p != $page) |
- |
|
473 |
{ |
- |
|
474 |
$vars['pagelinks'] .= '<a href="'.$logurl.(!$peg && $frev && $p != 1 ? '&peg='.$frev : '').'&page='.$p.'">'.$p.'</a>'; |
- |
|
475 |
} |
- |
|
476 |
else |
- |
|
477 |
{ |
- |
|
478 |
$vars['pagelinks'] .= '<span id="curpage">'.$p.'</span>'; |
- |
|
479 |
} |
- |
|
480 |
} |
- |
|
481 |
|
- |
|
482 |
if ($page < $pages) |
- |
|
483 |
{ |
- |
|
484 |
$vars['pagelinks'] .= '<a href="'.$logurl.(!$peg && $frev ? '&peg='.$frev : '').'&page='.$next.'">'.$lang['NEXT'].'→</a>'; |
- |
|
485 |
} |
- |
|
486 |
else |
- |
|
487 |
{ |
- |
|
488 |
$vars['pagelinks'] .= '<span>'.$lang['NEXT'].'→</span>'; |
- |
|
489 |
} |
- |
|
490 |
|
- |
|
491 |
$vars['showalllink'] = '<a href="'.$logurl.'&all=1">'.$lang['SHOWALL'].'</a>'; |
- |
|
492 |
} |
- |
|
493 |
} |
- |
|
494 |
|
- |
|
495 |
// Create form elements for filtering and searching log messages |
- |
|
496 |
if ($config->multiViews) |
- |
|
497 |
{ |
- |
|
498 |
$hidden = '<input type="hidden" name="op" value="log" />'; |
- |
|
499 |
} |
- |
|
500 |
else |
- |
|
501 |
{ |
- |
|
502 |
$hidden = '<input type="hidden" name="repname" value="'.$repname.'" />'; |
- |
|
503 |
$hidden .= '<input type="hidden" name="path" value="'.$path.'" />'; |
- |
|
504 |
} |
- |
|
505 |
|
- |
|
506 |
if ($isDir) |
- |
|
507 |
{ |
- |
|
508 |
$hidden .= '<input type="hidden" name="isdir" value="'.$isDir.'" />'; |
- |
|
509 |
} |
- |
|
510 |
|
- |
|
511 |
if ($peg) |
- |
|
512 |
{ |
- |
|
513 |
$hidden .= '<input type="hidden" name="peg" value="'.$peg.'" />'; |
- |
|
514 |
} |
- |
|
515 |
|
- |
|
516 |
if ($showchanges != $rep->logsShowChanges()) |
- |
|
517 |
{ |
- |
|
518 |
$hidden .= '<input type="hidden" name="showchanges" value="'.$showchanges.'" />'; |
- |
|
519 |
} |
- |
|
520 |
|
- |
|
521 |
$vars['logsearch_form'] = '<form method="get" action="'.$config->getURL($rep, $path, 'log').'" id="search">'.$hidden; |
- |
|
522 |
$vars['logsearch_startbox'] = '<input name="sr" size="5" value="'.$startrev.'" />'; |
- |
|
523 |
$vars['logsearch_endbox'] = '<input name="er" size="5" value="'.$endrev.'" />'; |
- |
|
524 |
$vars['logsearch_maxbox'] = '<input name="max" size="5" value="'.($max == 0 ? 40 : $max).'" />'; |
- |
|
525 |
$vars['logsearch_inputbox'] = '<input name="search" value="'.escape($search).'" />'; |
- |
|
526 |
$vars['logsearch_showall'] = '<input type="checkbox" name="all" value="1"'.($all ? ' checked="checked"' : '').' />'; |
- |
|
527 |
$vars['logsearch_submit'] = '<input type="submit" value="'.$lang['GO'].'" />'; |
- |
|
528 |
$vars['logsearch_endform'] = '</form>'; |
- |
|
529 |
|
- |
|
530 |
// If a filter is in place, produce a link to clear all filter parameters |
- |
|
531 |
if ($page !== 1 || $all || $dosearch || $fromRev || $startrev !== $rev || $endrev !== 1 || $max !== 40) |
- |
|
532 |
{ |
- |
|
533 |
$url = $config->getURL($rep, $path, 'log').$isDirString.$passRevString; |
- |
|
534 |
$vars['logsearch_clearloglink'] = '<a href="'.$url.'">'.$lang['CLEARLOG'].'</a>'; |
- |
|
535 |
} |
- |
|
536 |
|
- |
|
537 |
// Create form elements for comparing selected revisions |
- |
|
538 |
$vars['compare_form'] = '<form method="get" action="'.$config->getURL($rep, '', 'comp').'" id="compare">'; |
- |
|
539 |
|
- |
|
540 |
if ($config->multiViews) |
- |
|
541 |
{ |
- |
|
542 |
$vars['compare_form'] .= '<input type="hidden" name="op" value="comp" />'; |
130 |
} |
543 |
} |
131 |
else |
544 |
else |
132 |
{ |
545 |
{ |
133 |
$max = (int)$max; |
- |
|
134 |
if ($max < 0) $max = 30; |
546 |
$vars['compare_form'] .= '<input type="hidden" name="repname" value="'.$repname.'" />'; |
135 |
} |
547 |
} |
136 |
|
548 |
|
137 |
$history = $svnrep->getLog($path, $startrev, $endrev, true, $max); |
549 |
$vars['compare_submit'] = '<input type="submit" value="'.$lang['COMPAREREVS'].'" />'; |
138 |
$vars["logsearch_moreresultslink"] = ""; |
- |
|
139 |
$vars["pagelinks"] = ""; |
550 |
$vars['compare_endform'] = '</form>'; |
140 |
$vars["showalllink"] = ""; |
- |
|
141 |
$listing = array(); |
- |
|
142 |
|
551 |
|
143 |
if (!empty($history)) |
552 |
if (!$rep->hasReadAccess($path, false)) |
144 |
{ |
553 |
{ |
145 |
// Get the number of separate revisions |
- |
|
146 |
$revisions = count($history->entries); |
- |
|
147 |
|
- |
|
148 |
if ($all) |
- |
|
149 |
{ |
- |
|
150 |
$firstrevindex = 0; |
- |
|
151 |
$lastrevindex = $revisions - 1; |
- |
|
152 |
$pages = 1; |
- |
|
153 |
} |
- |
|
154 |
else |
- |
|
155 |
{ |
- |
|
156 |
// Calculate the number of pages |
- |
|
157 |
$pages = floor($revisions / $maxperpage); |
- |
|
158 |
if (($revisions % $maxperpage) > 0) $pages++; |
- |
|
159 |
|
- |
|
160 |
if ($page > $pages) $page = $pages; |
- |
|
161 |
|
- |
|
162 |
// Word out where to start and stop |
- |
|
163 |
$firstrevindex = ($page - 1) * $maxperpage; |
- |
|
164 |
$lastrevindex = $firstrevindex + $maxperpage - 1; |
- |
|
165 |
if ($lastrevindex > $revisions - 1) $lastrevindex = $revisions - 1; |
- |
|
166 |
} |
- |
|
167 |
|
- |
|
168 |
$history = $svnrep->getLog($path, $history->entries[$firstrevindex ]->rev, $history->entries[$lastrevindex]->rev, false, 0); |
- |
|
169 |
|
- |
|
170 |
$row = 0; |
- |
|
171 |
$index = 0; |
- |
|
172 |
$listing = array(); |
- |
|
173 |
$found = false; |
- |
|
174 |
|
- |
|
175 |
foreach ($history->entries as $r) |
- |
|
176 |
{ |
- |
|
177 |
// Assume a good match |
- |
|
178 |
$match = true; |
- |
|
179 |
$thisrev = $r->rev; |
- |
|
180 |
|
- |
|
181 |
// Check the log for the search words, if searching |
- |
|
182 |
if ($dosearch) |
- |
|
183 |
{ |
- |
|
184 |
if ((empty($fromRev) || $fromRev > $thisrev)) |
- |
|
185 |
{ |
- |
|
186 |
// Turn all the HTML entities into real characters. |
- |
|
187 |
|
- |
|
188 |
// Make sure that each word in the search in also in the log |
- |
|
189 |
foreach($words as $word) |
- |
|
190 |
{ |
- |
|
191 |
if (strpos(strtolower(removeAccents($r->msg)), $word) === false) |
- |
|
192 |
{ |
- |
|
193 |
$match = false; |
- |
|
194 |
break; |
- |
|
195 |
} |
- |
|
196 |
} |
- |
|
197 |
|
- |
|
198 |
if ($match) |
- |
|
199 |
{ |
- |
|
200 |
$numSearchResults--; |
- |
|
201 |
$found = true; |
- |
|
202 |
} |
- |
|
203 |
} |
- |
|
204 |
else |
- |
|
205 |
$match = false; |
- |
|
206 |
} |
- |
|
207 |
|
- |
|
208 |
if ($match) |
- |
|
209 |
{ |
- |
|
210 |
// Add the trailing slash if we need to (svnlook history doesn't return trailing slashes!) |
- |
|
211 |
$rpath = $r->path; |
- |
|
212 |
|
- |
|
213 |
if (empty($rpath)) |
- |
|
214 |
$rpath = "/"; |
- |
|
215 |
else if ($isDir && $rpath{strlen($rpath) - 1} != "/") |
- |
|
216 |
$rpath .= "/"; |
- |
|
217 |
|
- |
|
218 |
// Find the parent path (or the whole path if it's already a directory) |
- |
|
219 |
$pos = strrpos($rpath, "/"); |
- |
|
220 |
$parent = substr($rpath, 0, $pos + 1); |
- |
|
221 |
|
- |
|
222 |
$url = $config->getURL($rep, $parent, "dir"); |
- |
|
223 |
$listing[$index]["revlink"] = "<a href=\"${url}rev=$thisrev&sc=1\">$thisrev</a>"; |
- |
|
224 |
|
- |
|
225 |
if ($isDir) |
- |
|
226 |
{ |
- |
|
227 |
$listing[$index]["compare_box"] = "<input type=\"checkbox\" name=\"compare[]\" value=\"$parent@$thisrev\" onclick=\"checkCB(this)\" />"; |
- |
|
228 |
$url = $config->getURL($rep, $rpath, "dir"); |
- |
|
229 |
$listing[$index]["revpathlink"] = "<a href=\"${url}rev=$thisrev&sc=$showchanged\">$rpath</a>"; |
- |
|
230 |
} |
- |
|
231 |
else |
- |
|
232 |
{ |
- |
|
233 |
$listing[$index]["compare_box"] = "<input type=\"checkbox\" name=\"compare[]\" value=\"$rpath@$thisrev\" onclick=\"checkCB(this)\" />"; |
- |
|
234 |
$url = $config->getURL($rep, $rpath, "file"); |
- |
|
235 |
$listing[$index]["revpathlink"] = "<a href=\"${url}rev=$thisrev&sc=$showchanged\">$rpath</a>"; |
- |
|
236 |
} |
- |
|
237 |
|
- |
|
238 |
$listing[$index]["revauthor"] = $r->author; |
- |
|
239 |
$listing[$index]["revage"] = $r->age; |
- |
|
240 |
$listing[$index]["revlog"] = nl2br($bugtraq->replaceIDs(create_anchors($r->msg))); |
- |
|
241 |
$listing[$index]["rowparity"] = "$row"; |
- |
|
242 |
|
- |
|
243 |
$row = 1 - $row; |
- |
|
244 |
$index++; |
- |
|
245 |
} |
- |
|
246 |
|
- |
|
247 |
// If we've reached the search limit, stop here... |
- |
|
248 |
if (!$numSearchResults) |
- |
|
249 |
{ |
- |
|
250 |
$url = $config->getURL($rep, $path, "log"); |
- |
|
251 |
$vars["logsearch_moreresultslink"] = "<a href=\"${url}rev=$rev&sc=$showchanged&isdir=$isDir&logsearch=1&search=$search&fr=$thisrev\">${lang["MORERESULTS"]}</a>"; |
- |
|
252 |
break; |
- |
|
253 |
} |
- |
|
254 |
} |
- |
|
255 |
|
- |
|
256 |
$vars["logsearch_resultsfound"] = true; |
554 |
$vars['error'] = $lang['NOACCESS']; |
257 |
|
- |
|
258 |
if ($dosearch && !$found) |
- |
|
259 |
{ |
- |
|
260 |
if ($fromRev == 0) |
- |
|
261 |
{ |
- |
|
262 |
$vars["logsearch_nomatches"] = true; |
- |
|
263 |
$vars["logsearch_resultsfound"] = false; |
- |
|
264 |
} |
- |
|
265 |
else |
- |
|
266 |
$vars["logsearch_nomorematches"] = true; |
- |
|
267 |
} |
- |
|
268 |
else if ($dosearch && $numSearchResults > 0) |
- |
|
269 |
{ |
- |
|
270 |
$vars["logsearch_nomorematches"] = true; |
- |
|
271 |
} |
- |
|
272 |
|
- |
|
273 |
// Work out the paging options |
- |
|
274 |
|
- |
|
275 |
if ($pages > 1) |
- |
|
276 |
{ |
- |
|
277 |
$prev = $page - 1; |
- |
|
278 |
$next = $page + 1; |
- |
|
279 |
echo "<p><center>"; |
- |
|
280 |
|
- |
|
281 |
if ($page > 1) $vars["pagelinks"] .= "<a href=\"${logurl}rev=$rev&sr=$startrev&er=$endrev&sc=$showchanged&max=$max&page=$prev\">< ${lang["PREV"]}</a> "; |
- |
|
282 |
for ($p = 1; $p <= $pages; $p++) |
- |
|
283 |
{ |
- |
|
284 |
if ($p != $page) |
- |
|
285 |
$vars["pagelinks"].= "<a href=\"${logurl}rev=$rev&sr=$startrev&er=$endrev&sc=$showchanged&max=$max&page=$p\">$p</a> "; |
- |
|
286 |
else |
- |
|
287 |
$vars["pagelinks"] .= "<b>$p </b>"; |
- |
|
288 |
} |
- |
|
289 |
if ($page < $pages) $vars["pagelinks"] .=" <a href=\"${logurl}rev=$rev&sr=$startrev&er=$endrev&sc=$showchanged&max=$max&page=$next\">${lang["NEXT"]} ></a>"; |
- |
|
290 |
|
- |
|
291 |
$vars["showalllink"] = "<a href=\"${logurl}rev=$rev&sr=$startrev&er=$endrev&sc=$showchanged&all=1&max=$max\">${lang["SHOWALL"]}</a>"; |
- |
|
292 |
echo "</center>"; |
555 |
sendHeaderForbidden(); |
293 |
} |
- |
|
294 |
} |
556 |
} |
295 |
|
- |
|
296 |
// Create the project change combo box |
- |
|
297 |
|
- |
|
298 |
$url = $config->getURL($rep, $path, "log"); |
- |
|
299 |
# XXX: forms don't have the name attribute, but _everything_ has the id attribute, |
- |
|
300 |
# so what you're trying to do (if anything?) should be done via that ~J |
- |
|
301 |
$vars["logsearch_form"] = "<form action=\"$url\" method=\"post\" name=\"logsearchform\">"; |
- |
|
302 |
|
- |
|
303 |
$vars["logsearch_startbox"] = "<input name=\"sr\" size=\"5\" value=\"$startrev\" />"; |
- |
|
304 |
$vars["logsearch_endbox" ] = "<input name=\"er\" size=\"5\" value=\"$endrev\" />"; |
- |
|
305 |
$vars["logsearch_maxbox" ] = "<input name=\"max\" size=\"5\" value=\"".($max==0?"":$max)."\" />"; |
- |
|
306 |
$vars["logsearch_inputbox"] = "<input name=\"search\" value=\"$search\" />"; |
- |
|
307 |
|
- |
|
308 |
$vars["logsearch_submit"] = "<input type=\"submit\" value=\"${lang["GO"]}\" />"; |
- |
|
309 |
$vars["logsearch_endform"] = "<input type=\"hidden\" name=\"logsearch\" value=\"1\" />". |
- |
|
310 |
"<input type=\"hidden\" name=\"op\" value=\"log\" />". |
- |
|
311 |
"<input type=\"hidden\" name=\"rev\" value=\"$rev\" />". |
- |
|
312 |
"<input type=\"hidden\" name=\"sc\" value=\"$showchanged\" />". |
- |
|
313 |
"<input type=\"hidden\" name=\"isdir\" value=\"$isDir\" />". |
- |
|
314 |
"</form>"; |
- |
|
315 |
|
- |
|
316 |
$url = $config->getURL($rep, $path, "log"); |
- |
|
317 |
$vars["logsearch_clearloglink"] = "<a href=\"${url}rev=$rev&sc=$showchanged&isdir=$isDir\">${lang["CLEARLOG"]}</a>"; |
- |
|
318 |
|
- |
|
319 |
$url = $config->getURL($rep, "/", "comp"); |
- |
|
320 |
$vars["compare_form"] = "<form action=\"$url\" method=\"post\" name=\"compareform\">"; |
- |
|
321 |
$vars["compare_submit"] = "<input name=\"comparesubmit\" type=\"submit\" value=\"${lang["COMPAREREVS"]}\" />"; |
- |
|
322 |
$vars["compare_endform"] = "<input type=\"hidden\" name=\"op\" value=\"comp\" /><input type=\"hidden\" name=\"sc\" value=\"$showchanged\" /></form>"; |
- |
|
323 |
|
- |
|
324 |
$vars["version"] = $version; |
- |
|
325 |
|
- |
|
326 |
if (!$rep->hasReadAccess($path, false)) |
- |
|
327 |
$vars["noaccess"] = true; |
- |
|
328 |
|
- |
|
329 |
parseTemplate($rep->getTemplatePath()."header.tmpl", $vars, $listing); |
- |
|
330 |
parseTemplate($rep->getTemplatePath()."log.tmpl", $vars, $listing); |
- |
|
331 |
parseTemplate($rep->getTemplatePath()."footer.tmpl", $vars, $listing); |
- |
|
332 |
|
557 |
|
333 |
?> |
558 |
renderTemplate('log'); |