-
Notifications
You must be signed in to change notification settings - Fork 0
/
feed.php
56 lines (47 loc) · 2.01 KB
/
feed.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
<?php
// Auto-generated RSS feed
header('Content-Type: text/xml; charset="UTF-8"');
print('<?xml version="1.0" encoding="utf-8" standalone="yes" ?>');
include "config.php";
include "utils.php";
?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title><?= $site_title ?></title>
<description><?= strip_tags($site_description) ?></description>
<link><?= $site_url ?></link>
<language><?= strtolower($site_language) ?></language>
<atom:link href="<?= "$site_url/feed" ?>" rel="self" type="application/rss+xml" />
<?php
$current_year = date('Y');
$file = "content/$current_year.json";
if(file_exists($file) && filesize($file) > 0) {
$handle = fopen($file, "a+");
$posts_json = fread($handle, filesize($file));
$posts = json_decode($posts_json);
fclose($handle);
foreach ($posts as $post){
$date = date_create_from_format('Y-m-d H:i:s', $post->date);
$date = date_format($date, DateTime::RFC822);
$content = getRawContent($post)
?>
<item>
<description>
<?= strip_tags($content) ?>
</description>
<content:encoded>
<![CDATA[
<?= $content ?>
]]>
</content:encoded>
<link><?= $post->uri ?></link>
<guid><?= $post->uri ?></guid>
<comments><?= "$post->uri#webmentions" ?></comments>
<pubDate><?= $date ?></pubDate>
</item>
<?php
}
}
?>
</channel>
</rss>