| Line 1... |
Line 1... |
| 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 |
// rss.php |
23 |
// rss.php |
| 24 |
// |
24 |
// |
| 25 |
// Creates an rss feed for the given repository number |
25 |
// Creates an rss feed for the given repository number |
| 26 |
|
26 |
|
| 27 |
include("include/feedcreator.class.php"); |
27 |
include("include/feedcreator.class.php"); |
| 28 |
|
28 |
|
| 29 |
require_once("include/setup.inc"); |
29 |
require_once("include/setup.inc"); |
| 30 |
require_once("include/svnlook.inc"); |
30 |
require_once("include/svnlook.inc"); |
| 31 |
require_once("include/utils.inc"); |
31 |
require_once("include/utils.inc"); |
| 32 |
require_once("include/template.inc"); |
32 |
require_once("include/template.inc"); |
| 33 |
|
33 |
|
| 34 |
$isDir = (@$_REQUEST["isdir"] == 1)?1:0; |
34 |
$isDir = (@$_REQUEST["isdir"] == 1)?1:0; |
| 35 |
|
35 |
|
| 36 |
$maxmessages = 20; |
36 |
$maxmessages = 20; |
| 37 |
|
37 |
|
| 38 |
// Find the base URL name |
38 |
// Find the base URL name |
| 39 |
if ($config->multiViews) |
39 |
if ($config->multiViews) |
| 40 |
{ |
40 |
{ |
| 41 |
$baseurl = ""; |
41 |
$baseurl = ""; |
| 42 |
} |
42 |
} |
| 43 |
else |
43 |
else |
| 44 |
{ |
44 |
{ |
| 45 |
$baseurl = dirname($_SERVER["PHP_SELF"]); |
45 |
$baseurl = dirname($_SERVER["PHP_SELF"]); |
| 46 |
if ($baseurl != "" && $baseurl != DIRECTORY_SEPARATOR && $baseurl != "\\" && $baseurl != "/" ) |
46 |
if ($baseurl != "" && $baseurl != DIRECTORY_SEPARATOR && $baseurl != "\\" && $baseurl != "/" ) |
| 47 |
$baseurl .= "/"; |
47 |
$baseurl .= "/"; |
| 48 |
else |
48 |
else |
| 49 |
$baseurl = "/"; |
49 |
$baseurl = "/"; |
| 50 |
} |
50 |
} |
| 51 |
|
51 |
|
| 52 |
$svnrep = new SVNRepository($rep); |
52 |
$svnrep = new SVNRepository($rep); |
| 53 |
|
53 |
|
| 54 |
if ($path == "" || $path{0} != "/") |
54 |
if ($path == "" || $path{0} != "/") |
| 55 |
$ppath = "/".$path; |
55 |
$ppath = "/".$path; |
| 56 |
else |
56 |
else |
| 57 |
$ppath = $path; |
57 |
$ppath = $path; |
| 58 |
|
58 |
|
| 59 |
// Make sure that the user has full access to the specified directory |
59 |
// Make sure that the user has full access to the specified directory |
| 60 |
if (!$rep->hasReadAccess($path, false)) |
60 |
if (!$rep->hasReadAccess($path, false)) |
| 61 |
exit; |
61 |
exit; |
| 62 |
|
62 |
|
| 63 |
$url = $config->getURL($rep, $path, "log"); |
63 |
$url = $config->getURL($rep, $path, "log"); |
| 64 |
$listurl = $config->getURL($rep, $path, "dir"); |
64 |
$listurl = $config->getURL($rep, $path, "dir"); |
| 65 |
|
65 |
|
| 66 |
// If there's no revision info, go to the lastest revision for this path |
66 |
// If there's no revision info, go to the lastest revision for this path |
| 67 |
$history = $svnrep->getLog($path, $rev, "", false, 20); |
67 |
$history = $svnrep->getLog($path, $rev, "", false, 20); |
| 68 |
$youngest = $history->entries[0]->rev; |
68 |
$youngest = $history->entries[0]->rev; |
| 69 |
|
69 |
|
| 70 |
// Cachename reflecting full path to and rev for rssfeed. Must end with xml to work |
70 |
// Cachename reflecting full path to and rev for rssfeed. Must end with xml to work |
| 71 |
$cachename = strtr(getFullURL($listurl), ":/\\?", "____"); |
71 |
$cachename = strtr(getFullURL($listurl), ":/\\?", "____"); |
| 72 |
$cachename = $locwebsvnreal.DIRECTORY_SEPARATOR."cache".DIRECTORY_SEPARATOR.$cachename.@$_REQUEST["rev"]."_rssfeed.xml"; |
72 |
$cachename = $locwebsvnreal.DIRECTORY_SEPARATOR."cache".DIRECTORY_SEPARATOR.$cachename.@$_REQUEST["rev"]."_rssfeed.xml"; |
| 73 |
|
73 |
|
| 74 |
$rss = new UniversalFeedCreator(); |
74 |
$rss = new UniversalFeedCreator(); |
| 75 |
$rss->useCached("RSS2.0", $cachename); |
75 |
$rss->useCached("RSS2.0", $cachename); |
| 76 |
$rss->title = $rep->getDisplayName(); |
76 |
$rss->title = $rep->getDisplayName(); |
| 77 |
$rss->description = "${lang["RSSFEEDTITLE"]} - $repname"; |
77 |
$rss->description = "${lang["RSSFEEDTITLE"]} - $repname"; |
| 78 |
$rss->link = html_entity_decode(getFullURL($baseurl.$listurl)); |
78 |
$rss->link = html_entity_decode(getFullURL($baseurl.$listurl)); |
| 79 |
$rss->syndicationURL = $rss->link; |
79 |
$rss->syndicationURL = $rss->link; |
| 80 |
$rss->xslStyleSheet = ""; //required for UniversalFeedCreator since 1.7 |
80 |
$rss->xslStyleSheet = ""; //required for UniversalFeedCreator since 1.7 |
| 81 |
$rss->cssStyleSheet = ""; //required for UniversalFeedCreator since 1.7 |
81 |
$rss->cssStyleSheet = ""; //required for UniversalFeedCreator since 1.7 |
| 82 |
|
82 |
|
| 83 |
//$divbox = "<div>"; |
83 |
//$divbox = "<div>"; |
| 84 |
//$divfont = "<span>"; |
84 |
//$divfont = "<span>"; |
| 85 |
|
85 |
|
| 86 |
foreach ($history->entries as $r) |
86 |
foreach ($history->entries as $r) |
| 87 |
{ |
87 |
{ |
| 88 |
$thisrev = $r->rev; |
88 |
$thisrev = $r->rev; |
| 89 |
$changes = $r->mods; |
89 |
$changes = $r->mods; |
| 90 |
$files = count($changes); |
90 |
$files = count($changes); |
| 91 |
|
91 |
|
| 92 |
// Add the trailing slash if we need to (svnlook history doesn't return trailing slashes!) |
92 |
// Add the trailing slash if we need to (svnlook history doesn't return trailing slashes!) |
| 93 |
$rpath = $r->path; |
93 |
$rpath = $r->path; |
| 94 |
if ($isDir && $rpath{strlen($rpath) - 1} != "/") |
94 |
if ($isDir && $rpath{strlen($rpath) - 1} != "/") |
| 95 |
$rpath .= "/"; |
95 |
$rpath .= "/"; |
| 96 |
|
96 |
|
| 97 |
// Find the parent path (or the whole path if it's already a directory) |
97 |
// Find the parent path (or the whole path if it's already a directory) |
| 98 |
$pos = strrpos($rpath, "/"); |
98 |
$pos = strrpos($rpath, "/"); |
| 99 |
$parent = substr($rpath, 0, $pos + 1); |
99 |
$parent = substr($rpath, 0, $pos + 1); |
| 100 |
|
100 |
|
| 101 |
$url = $config->getURL($rep, $parent, "dir"); |
101 |
$url = $config->getURL($rep, $parent, "dir"); |
| 102 |
|
102 |
|
| 103 |
$desc = $r->msg; |
103 |
$desc = $r->msg; |
| 104 |
$item = new FeedItem(); |
104 |
$item = new FeedItem(); |
| 105 |
|
105 |
|
| 106 |
// For the title, we show the first 10 words of the description |
106 |
// For the title, we show the first 10 words of the description |
| 107 |
$pos = 0; |
107 |
$pos = 0; |
| 108 |
$len = strlen($desc); |
108 |
$len = strlen($desc); |
| 109 |
for ($i = 0; $i < 10; $i++) |
109 |
for ($i = 0; $i < 10; $i++) |
| 110 |
{ |
110 |
{ |
| 111 |
if ($pos >= $len) break; |
111 |
if ($pos >= $len) break; |
| 112 |
|
112 |
|
| 113 |
$pos = strpos($desc, " ", $pos); |
113 |
$pos = strpos($desc, " ", $pos); |
| 114 |
|
114 |
|
| 115 |
if ($pos === FALSE) break; |
115 |
if ($pos === FALSE) break; |
| 116 |
$pos++; |
116 |
$pos++; |
| 117 |
} |
117 |
} |
| 118 |
|
118 |
|
| 119 |
if ($pos !== FALSE) |
119 |
if ($pos !== FALSE) |
| 120 |
{ |
120 |
{ |
| 121 |
$sdesc = substr($desc, 0, $pos) . "..."; |
121 |
$sdesc = substr($desc, 0, $pos) . "..."; |
| 122 |
} |
122 |
} |
| 123 |
else |
123 |
else |
| 124 |
{ |
124 |
{ |
| 125 |
$sdesc = $desc; |
125 |
$sdesc = $desc; |
| 126 |
} |
126 |
} |
| 127 |
|
127 |
|
| 128 |
if ($desc == "") $sdesc = "${lang["REV"]} $thisrev"; |
128 |
if ($desc == "") $sdesc = "${lang["REV"]} $thisrev"; |
| 129 |
|
129 |
|
| 130 |
$item->title = "$sdesc"; |
130 |
$item->title = "$sdesc"; |
| 131 |
$item->link = html_entity_decode(getFullURL($baseurl."${url}rev=$thisrev&sc=$showchanged")); |
131 |
$item->link = html_entity_decode(getFullURL($baseurl."${url}rev=$thisrev&sc=$showchanged")); |
| 132 |
$item->description = "<div><strong>${lang["REV"]} $thisrev - ".$r->author."</strong> ($files ${lang["FILESMODIFIED"]})</div><div>".nl2br(create_anchors($desc))."</div>"; |
132 |
$item->description = "<div><strong>${lang["REV"]} $thisrev - ".$r->author."</strong> ($files ${lang["FILESMODIFIED"]})</div><div>".nl2br(create_anchors($desc))."</div>"; |
| 133 |
|
133 |
|
| 134 |
if ($showchanged) |
134 |
if ($showchanged) |
| 135 |
{ |
135 |
{ |
| 136 |
foreach ($changes as $file) |
136 |
foreach ($changes as $file) |
| 137 |
{ |
137 |
{ |
| 138 |
switch ($file->action) |
138 |
switch ($file->action) |
| 139 |
{ |
139 |
{ |
| 140 |
case "A": |
140 |
case "A": |
| 141 |
$item->description .= "+ ".$file->path."<br />"; |
141 |
$item->description .= "+ ".$file->path."<br />"; |
| 142 |
break; |
142 |
break; |
| 143 |
|
143 |
|
| 144 |
case "M": |
144 |
case "M": |
| 145 |
$item->description .= "~ ".$file->path."<br />"; |
145 |
$item->description .= "~ ".$file->path."<br />"; |
| 146 |
break; |
146 |
break; |
| 147 |
|
147 |
|
| 148 |
|
148 |
|
| 149 |
case "D": |
149 |
case "D": |
| 150 |
$item->description .= "-".$file->path."<br />"; |
150 |
$item->description .= "-".$file->path."<br />"; |
| 151 |
break; |
151 |
break; |
| 152 |
|
152 |
|
| 153 |
} |
153 |
} |
| 154 |
} |
154 |
} |
| 155 |
} |
155 |
} |
| 156 |
|
156 |
|
| 157 |
$item->date = $r->committime; |
157 |
$item->date = $r->committime; |
| 158 |
$item->author = $r->author; |
158 |
$item->author = $r->author; |
| 159 |
|
159 |
|
| 160 |
$rss->addItem($item); |
160 |
$rss->addItem($item); |
| 161 |
} |
161 |
} |
| 162 |
|
162 |
|
| 163 |
// valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1, MBOX, OPML |
163 |
// valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1, MBOX, OPML |
| 164 |
|
164 |
|
| 165 |
// Save the feed |
165 |
// Save the feed |
| 166 |
$rss->saveFeed("RSS2.0",$cachename, false); |
166 |
$rss->saveFeed("RSS2.0",$cachename, false); |
| 167 |
header("Content-Type: application/xml"); |
167 |
header("Content-Type: application/xml"); |
| 168 |
echo $rss->createFeed("RSS2.0"); |
168 |
echo $rss->createFeed("RSS2.0"); |
| 169 |
|
169 |
|
| 170 |
?> |
170 |
?> |