summaryrefslogtreecommitdiff
path: root/rss.php
blob: 113dbe27d2c9cc838559869a64fbc9fe1fc9703f (plain)
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
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/time.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/post.php';

$posts = get_posts();

header('Content-Type: application/xml');

echo "<?xml version='1.0' encoding='UTF-8'?>";
echo "<rss version='2.0' xmlns:content='http://purl.org/rss/1.0/modules/content/'>";
echo "<channel>";

echo "<title>ilt.su</title>";
echo "<link>https://ilt.su</link>";
echo "<description>ilotterytea's racist schizo thoughts. read and learn.</description>";
echo "<language>en-us</language>";

if (!empty($posts)) {
    echo "<lastBuildDate>";
    echo date("D, d M Y H:i:s O", $posts[0]['time']);
    echo "</lastBuildDate>";
}

foreach ($posts as $p) {
    echo "<item>";
    echo "<title>";
    echo $p['name'] ?: '-NO TITLE-';
    echo "</title>";

    echo '<guid isPermaLink="true">';
    echo "https://ilt.su/blog/" . urlencode($p['name']);
    echo "</guid>";

    echo "<pubDate>";
    echo date('D, d M Y H:i:s O', $p['time']);
    echo "</pubDate>";

    echo "<content:encoded><![CDATA[";
    echo $p['contents'] ?: '-NO CONTENT-';
    echo "]]></content:encoded>";
    echo "</item>";
}

echo "</channel></rss>";