diff options
| author | ilotterytea <me@ilotterytea.kz> | 2025-10-10 20:55:37 +0500 |
|---|---|---|
| committer | ilotterytea <me@ilotterytea.kz> | 2025-10-10 20:55:37 +0500 |
| commit | b1a885ac229892bac528e6fea4e011a1b240867b (patch) | |
| tree | 48152aa48c41defe7f850390ea1c99db2c725438 /rss.php | |
initial commit
Diffstat (limited to 'rss.php')
| -rw-r--r-- | rss.php | 49 |
1 files changed, 49 insertions, 0 deletions
@@ -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 |
