summaryrefslogtreecommitdiff
path: root/rss.php
diff options
context:
space:
mode:
Diffstat (limited to 'rss.php')
-rw-r--r--rss.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/rss.php b/rss.php
new file mode 100644
index 0000000..5a7c78c
--- /dev/null
+++ b/rss.php
@@ -0,0 +1,49 @@
+<?php
+include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/time.php';
+$db = new PDO("sqlite:{$_SERVER['DOCUMENT_ROOT']}/database.db");
+$stmt = $db->query("SELECT * FROM statuses ORDER BY posted_at DESC");
+$statuses = $stmt->fetchAll(PDO::FETCH_ASSOC);
+
+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($statuses)) {
+ $date = new DateTime($statuses[0]['posted_at']);
+ echo "<lastBuildDate>";
+ echo $date->format('D, d M Y H:i:s O');
+ echo "</lastBuildDate>";
+}
+
+foreach ($statuses as $s) {
+ $date = new DateTime($s['posted_at']);
+
+ echo "<item>";
+ echo "<title>";
+ echo $s['title'] ?: '-NO TITLE-';
+ echo "</title>";
+
+ echo '<guid isPermaLink="true">';
+ echo "https://ilt.su/statuses/?id=" . $s['id'];
+ echo "</guid>";
+
+ echo "<pubDate>";
+ echo $date->format('D, d M Y H:i:s O');
+ echo "</pubDate>";
+
+ echo "<content:encoded><![CDATA[";
+ echo $s['contents'] ?: '-NO CONTENT-';
+ echo "]]></content:encoded>";
+ echo "</item>";
+}
+
+echo "</channel></rss>";
+?> \ No newline at end of file