-
Notifications
You must be signed in to change notification settings - Fork 0
/
feeds.php
65 lines (52 loc) · 1.61 KB
/
feeds.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
<?php
require 'config.php';
header('Content-type: application/rss+xml');
header('Cache-Control: public, max-age=3600');
echo '<?xml version="1.0" encoding="utf-8"?>';
?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:cc="http://web.resource.org/cc/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:media="http://search.yahoo.com/mrss/"
>
<channel>
<title><?=$title?></title>
<link><?=$baseURL?></link>
<atom:link href="<?=$SERVER['PHP_SELF']?>" rel="self" type="application/rss+xml" />
<description><?=$title?></description>
<language>en-us</language>
<generator>http://atom.geekhood.net</generator>
<?php
libxml_use_internal_errors(true);
$atom2rss = new DOMDocument();
$atom2rss->load('atom2rss.xsl');
$processor = new XSLTProcessor();
$processor->registerPHPFunctions();
$processor->importStylesheet($atom2rss);
foreach ($feeds as $feed) {
$read = new DOMDocument;
$read->preserveWhitespace = false;
if ($read->load($feed)) {
echo "<!-- $feed " . $read->documentElement->nodeName . " -->";
if ($read->documentElement->nodeName == 'feed') {
// this is an atom feed, so convert to rss
$read = $processor->transformToDoc($read);
}
$items = $read->getElementsByTagName('item');
foreach ($items as $item) {
echo $read->saveXML($item);
}
} else {
echo "<!-- error loading $feed: ";
foreach (libxml_get_errors() as $error) {
echo $error->line . ":" . $error->column . ": " . $error->message . "\n";
}
echo "-->";
libxml_clear_errors();
}
}
?>
</channel></rss>