This repository has been archived by the owner on Dec 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rss.php
68 lines (65 loc) · 2.42 KB
/
rss.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* RSS feed
*
* PHP Version 5.3.6
*
* @category Front
* @package Chaton
* @author Pierre Rudloff <rudloff@strasweb.fr>
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
* @link http://cms.strasweb.fr
*/
header("Content-Type: application/rss+xml; charset=utf-8");
require_once "classes/Config.php";
$config=new Config();
require "inc/version.php";
$dom=new DOMDocument("1.0", "utf-8");
require_once "classes/dom-enhancer/DOMElement.php";
$dom->registerNodeClass("DOMElement", "DOMenhancer_DOMElement");
$dom->rss=$dom->createElement("rss");
$dom->rss->setAttribute("xmlns:atom", "http://www.w3.org/2005/Atom");
$dom->rss->setAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
$dom->appendChild($dom->rss);
$dom->rss->setAttribute("version", "2.0");
$fullpath=(isset(
$_SERVER["HTTPS"]
)?"https://":"http://").$_SERVER["HTTP_HOST"].substr(
$_SERVER["SCRIPT_NAME"], 0, strrpos($_SERVER["SCRIPT_NAME"], "/")+1
);
$dom->rss->addElement("channel")->addElement(
"atom:link", null, array(
"href"=>$fullpath."rss.php", "rel"=>"self",
"type"=>"application/rss+xml"
)
);
$dom->rss->channel->addElement("title", $config->title);
$dom->rss->channel->addElement("description", htmlspecialchars($config->desc));
$dom->rss->channel->addElement("link", $fullpath."index.php");
$dom->rss->channel->addElement("generator", "Chaton CMS v".$config->chaton_ver);
$dom->rss->channel->addElement("docs", "http://www.rssboard.org/rss-specification");
$lang=isset($_GET["lang"])?$_GET["lang"]:$config->lang;
require_once "classes/Article.php";
if ($articles=Article::getAll($lang)) {
foreach ($articles as $article) {
$dom->rss->channel->addElement("item")->addElement(
"title", stripslashes($article->title)
);
$dom->rss->channel->item->addElement("dc:language", $article->lang);
$dom->rss->channel->item->addElement(
"link", $fullpath."index.php?page=news&news=".$article->id
);
$dom->rss->channel->item->addElement(
"pubDate", date(DATE_RSS, strtotime($article->date))
);
$dom->rss->channel->item->addElement(
"guid", $fullpath."index.php?page=news&news=".$article->id,
array("isPermaLink"=>"true")
);
$dom->rss->channel->item->addElement(
"description", stripslashes($article->content)
);
}
}
print($dom->saveXML());
?>