]> src.bluestatic.org Git - viewsvn.git/blob - diff.php
Sanitize the browse.php message
[viewsvn.git] / diff.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # ViewSVN [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
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
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 $fetchtemplates = array(
23 'diff_line',
24 'diff_hunk',
25 'diff_file',
26 'diff',
27 'file_change'
28 );
29
30 require_once('./global.php');
31
32 $navbar = $viewsvn->paths->construct_breadcrumb($path, false);
33
34 // ###################################################################
35
36 $link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path);
37
38 // ###################################################################
39
40 $revs = $viewsvn->paths->fetch_rev_num(true);
41 $high = $revs['high'];
42 $low = $revs['low'];
43
44 if ($high == 'HEAD')
45 {
46 $high = $viewsvn->svn->common->fetch_head_rev($path);
47 }
48
49 if ($low == 0)
50 {
51 $low = $viewsvn->svn->common->fetch_prev_rev($path, $high);
52 }
53
54 // ###################################################################
55
56 $show['fullchangeset'] = ($viewsvn->paths->is_root_path($path) ? false : true);
57 if ($show['fullchangeset'])
58 {
59 $link['changeset'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $high, $high - 1), $repos . '/');
60 }
61
62 $log = $viewsvn->svn->common->fetch_log($path, $high);
63
64 $log['message_clean'] = nl2br(htmlspecialchars($log['message']));
65
66 $files = $viewsvn->svn->common->construct_file_changes($log['files'], $repos, $high);
67
68 // ###################################################################
69
70 $diff = new SVNDiff($repos, $relpath, $low, $high);
71
72 $isdir = (bool)$viewsvn->svn->common->isdir($path);
73
74 $changes = '';
75
76 foreach ($diff->fetch() AS $filename => $file)
77 {
78 $hunktpl = '';
79
80 foreach ($file AS $hunk)
81 {
82 $lines = '';
83 foreach ($hunk AS $key => $line)
84 {
85 $show['hunk'] = false;
86 if ($key == 'hunk' AND isset($line['old']))
87 {
88 $filepath = ($isdir ? $path . $filename : $path);
89 $rlow = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $low), $filepath);
90 $rhigh = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $high), $filepath);
91 $show['hunk'] = true;
92 }
93 else
94 {
95 if ($line['act'] == '+')
96 {
97 $class = 'diff_add';
98 }
99 else if ($line['act'] == '-')
100 {
101 $class = 'diff_del';
102 }
103 else
104 {
105 $class = 'diff_norm';
106 }
107
108 $line['line_clean'] = $viewsvn->svn->format($line['line']);
109 }
110
111 eval('$lines .= "' . $template->fetch('diff_line') . '";');
112 }
113 eval('$hunktpl .= "' . $template->fetch('diff_hunk') . '";');
114 }
115
116 eval('$changes .= "' . $template->fetch('diff_file') . '";');
117 }
118
119 // ###################################################################
120
121 //echo('$template->flush("' . $template->fetch('diff') . '");');
122 eval('$template->flush("' . $template->fetch('diff') . '");');
123
124 /*=====================================================================*\
125 || ###################################################################
126 || # $HeadURL$
127 || # $Id$
128 || ###################################################################
129 \*=====================================================================*/
130 ?>