46 |
jpm |
1 |
<?php
|
|
|
2 |
/*
|
|
|
3 |
recentchangesrss.php
|
|
|
4 |
|
|
|
5 |
Copyright 2003 David DELON
|
|
|
6 |
Copyright 2005-2007 Didier LOISEAU
|
|
|
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; either version 2 of the License, or
|
|
|
10 |
(at your option) any later version.
|
|
|
11 |
|
|
|
12 |
This program is distributed in the hope that it will be useful,
|
|
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
15 |
GNU General Public License for more details.
|
|
|
16 |
|
|
|
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
|
|
|
19 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
20 |
*/
|
47 |
jpm |
21 |
if (!defined("WIKINI_VERSION"))
|
|
|
22 |
{
|
|
|
23 |
die ("accès direct interdit");
|
|
|
24 |
}
|
46 |
jpm |
25 |
|
|
|
26 |
if ($this->GetMethod() != 'xml') {
|
|
|
27 |
echo 'Pour obtenir le fil RSS des derniers changements, utilisez l\'adresse suivante: ';
|
|
|
28 |
echo $this->Link($this->Href('xml'));
|
|
|
29 |
return;
|
|
|
30 |
}
|
|
|
31 |
|
47 |
jpm |
32 |
|
|
|
33 |
if (!function_exists("rssdiff")) {
|
|
|
34 |
|
|
|
35 |
function rssdiff($tag,$idfirst,$idlast) {
|
|
|
36 |
|
|
|
37 |
require_once 'includes/diff/side.class.php';
|
|
|
38 |
require_once 'includes/diff/diff.class.php';
|
|
|
39 |
require_once 'includes/diff/diffformatter.class.php';
|
|
|
40 |
|
|
|
41 |
$output='';
|
|
|
42 |
global $wiki;
|
|
|
43 |
// TODO : cache ?
|
|
|
44 |
|
|
|
45 |
if ($idfirst==$idlast) {
|
|
|
46 |
$previousdiff=$wiki->LoadSingle("select id from ".$wiki->config["table_prefix"]."pages where tag = '".mysql_escape_string($tag)."' and id < $idfirst order by time desc limit 1");
|
|
|
47 |
if ($previousdiff) {
|
|
|
48 |
$idlast=$previousdiff['id'];
|
|
|
49 |
}
|
|
|
50 |
else {
|
|
|
51 |
return;
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
$pageA = $wiki->LoadPageById($idfirst);
|
|
|
57 |
$pageB = $wiki->LoadPageById($idlast);
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
$bodyA = explode("\n", $pageA["body"]);
|
|
|
61 |
$bodyB = explode("\n", $pageB["body"]);
|
|
|
62 |
|
|
|
63 |
$added = array_diff($bodyA, $bodyB);
|
|
|
64 |
$deleted = array_diff($bodyB, $bodyA);
|
|
|
65 |
if (!isset($output)) $output = '';
|
|
|
66 |
|
|
|
67 |
$output .= "<br />\n";
|
|
|
68 |
$output .= "<br />\n";
|
|
|
69 |
$output .= "<b>Comparaison de <a href=\"".$wiki->href("", "", "time=".urlencode($pageA["time"]))."\">".$pageA["time"]."</a> à <a href=\"".$wiki->href("", "", "time=".urlencode($pageB["time"]))."\">".$pageB["time"]."</a></b><br />\n";
|
|
|
70 |
|
|
|
71 |
$wiki->RegisterInclusion($tag);
|
|
|
72 |
if ($added)
|
|
|
73 |
{
|
|
|
74 |
// remove blank lines
|
|
|
75 |
$output .= "<br />\n<b>Ajouts:</b><br />\n";
|
|
|
76 |
$output .= "<div class=\"additions\">".(implode("\n", $added))."</div>";
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
if ($deleted)
|
|
|
80 |
{
|
|
|
81 |
$output .= "<br />\n<b>Suppressions:</b><br />\n";
|
|
|
82 |
$output .= "<div class=\"deletions\">".(implode("\n", $deleted))."</div>";
|
|
|
83 |
}
|
|
|
84 |
$wiki->UnregisterLastInclusion();
|
|
|
85 |
|
|
|
86 |
if (!$added && !$deleted)
|
|
|
87 |
{
|
|
|
88 |
$output .= "<br />\nPas de différences.";
|
|
|
89 |
}
|
|
|
90 |
return $output;
|
|
|
91 |
|
|
|
92 |
}
|
|
|
93 |
}
|
|
|
94 |
|
46 |
jpm |
95 |
if (isset($_GET['max']) && is_numeric($_GET['max'])) {
|
|
|
96 |
$max = ($_GET['max'] < 1000) ? $_GET['max'] : 1000;
|
|
|
97 |
} else if ($user = $this->GetUser()) {
|
|
|
98 |
$max = $user["changescount"];
|
|
|
99 |
} else {
|
|
|
100 |
$max = 50;
|
|
|
101 |
}
|
47 |
jpm |
102 |
$pages = $this->LoadAll("SELECT id, tag, time, user, owner FROM ".$this->config["table_prefix"]."pages WHERE comment_on = '' ORDER BY time DESC LIMIT $max");
|
46 |
jpm |
103 |
$last_users = $this->LoadAll('SELECT name, signuptime, motto FROM '.$this->GetConfigValue('table_prefix').'users ORDER BY signuptime DESC LIMIT '.$max);
|
47 |
jpm |
104 |
if ($pages || $last_users) {
|
|
|
105 |
|
46 |
jpm |
106 |
if (!($link = $this->GetParameter("link"))) $link=$this->GetConfigValue("root_page");
|
47 |
jpm |
107 |
$output = '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">' . "\n";
|
46 |
jpm |
108 |
$output .= "<channel>\n";
|
47 |
jpm |
109 |
$output .= "<atom:link href=\"".$this->Href("xml")."\" rel=\"self\" type=\"application/rss+xml\" />\n";
|
|
|
110 |
$output .= "<title> ". htmlspecialchars($this->GetConfigValue("wakka_name"), ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET) . "</title>\n";
|
46 |
jpm |
111 |
$output .= "<link>" . $this->Href(false, $link) . "</link>\n";
|
47 |
jpm |
112 |
$output .= "<description>$max derniers changements sur " . htmlspecialchars($this->GetConfigValue("wakka_name"), ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET) . "</description>\n";
|
46 |
jpm |
113 |
$output .= "<language>fr</language>\n";
|
|
|
114 |
$output .= '<generator>WikiNi ' . WIKINI_VERSION . "</generator>\n";
|
47 |
jpm |
115 |
|
46 |
jpm |
116 |
$items = array();
|
47 |
jpm |
117 |
if ($pages) {
|
|
|
118 |
foreach ($pages as $page) {
|
|
|
119 |
$page['diff'] = rssdiff($page["tag"], $page["id"], $page["id"]);
|
|
|
120 |
|
46 |
jpm |
121 |
$items[strtotime($page['time'])] = array('type' => 'page', 'content' => $page);
|
|
|
122 |
}
|
|
|
123 |
}
|
47 |
jpm |
124 |
|
|
|
125 |
if ($last_users) {
|
46 |
jpm |
126 |
foreach ($last_users as $user) {
|
|
|
127 |
$items[strtotime($user['signuptime'])] = array('type' => 'user', 'content' => $user);
|
|
|
128 |
}
|
|
|
129 |
}
|
|
|
130 |
krsort($items);
|
47 |
jpm |
131 |
|
46 |
jpm |
132 |
foreach ($items as $item) {
|
|
|
133 |
$type = $item['type'];
|
47 |
jpm |
134 |
if ($type == 'page') {
|
46 |
jpm |
135 |
$page = $item['content'];
|
47 |
jpm |
136 |
|
46 |
jpm |
137 |
$output .= "<item>\n";
|
47 |
jpm |
138 |
$output .= "<title>" . htmlspecialchars($page["tag"], ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET) . "</title>\n";
|
|
|
139 |
$output .= '<dc:creator>' . htmlspecialchars($page["user"], ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET) . "</dc:creator>\n";
|
46 |
jpm |
140 |
$output .= '<pubDate>' . gmdate('D, d M Y H:i:s \G\M\T', strtotime($page['time'])) . "</pubDate>\n";
|
|
|
141 |
$output .= "<description>" . htmlspecialchars(
|
47 |
jpm |
142 |
'Modification de ' . $this->ComposeLinkToPage($page["tag"]).
|
|
|
143 |
' (' . $this->ComposeLinkToPage($page["tag"], 'revisions', 'historique') . ')'.
|
|
|
144 |
' --- par ' . $page["user"].
|
|
|
145 |
$page['diff']).
|
|
|
146 |
"</description>\n";
|
|
|
147 |
$output .= "<dc:format>text/html</dc:format>";
|
|
|
148 |
|
|
|
149 |
$itemurl = $this->href(false, $page["tag"], "time=" . htmlspecialchars(rawurlencode($page["time"]), ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET));
|
46 |
jpm |
150 |
$output .= '<guid>' . $itemurl . "</guid>\n";
|
|
|
151 |
$output .= "</item>\n";
|
47 |
jpm |
152 |
} else if ($type == 'user') {
|
46 |
jpm |
153 |
$user = $item['content'];
|
|
|
154 |
$itemurl = $this->Href('', $user['name']);
|
47 |
jpm |
155 |
|
46 |
jpm |
156 |
$output .= '<item>'."\n";
|
|
|
157 |
$output .= '<title>'.'Utilisateur '.htmlspecialchars($user['name']).' - inscription le '.$user['signuptime'].'</title>'."\n";
|
|
|
158 |
$output .= '<link>'.$itemurl.'</link>'."\n";
|
|
|
159 |
$output .= '<pubDate>' . gmdate('D, d M Y H:i:s \G\M\T', strtotime($user['signuptime'])) . "</pubDate>\n";
|
|
|
160 |
$output .= '<description>'.'L\'utilisateur '.htmlspecialchars($user['name']).' s\'est inscrit le '.$user['signuptime'];
|
47 |
jpm |
161 |
if (!empty($user['motto'])) {
|
46 |
jpm |
162 |
$output .= ' avec pour devise "'.htmlspecialchars($user['motto']).'"';
|
|
|
163 |
}
|
|
|
164 |
$output .= '</description>'."\n";
|
|
|
165 |
$output .= '<guid>'.$itemurl.'</guid>'."\n";
|
|
|
166 |
$output .= '</item>'."\n";
|
|
|
167 |
}
|
|
|
168 |
}
|
|
|
169 |
$output .= "</channel>\n";
|
|
|
170 |
$output .= "</rss>\n";
|
47 |
jpm |
171 |
echo $output;
|
46 |
jpm |
172 |
}
|
47 |
jpm |
173 |
?>
|