1
0
Fork 0
isopod.cool/blog/comment/feed.php
2024-01-04 08:02:57 -07:00

26 lines
1 KiB
PHP

<?php
header('Content-Type: text/xml');
echo '<rss version="2.0"><channel>';
echo '<title>isopod.cool blog comments</title>';
echo '<description>Every comment posted on my blog in chronological order.</description>';
echo '<language>en-us</language>';
echo '<link>https://isopod.cool/blog/comment/</link>';
echo '<generator>My crappy PHP code</generator>';
$postlist = json_decode(file_get_contents("posts.json"));
$totaloutput = "";
foreach($postlist as $post) {
$output = "";
$date = date("D, d M Y H:m:s", $post->date) . " GMT";
$name = $post->name;
$message = $post->message;
$entry = $post->entry;
$output = $output."Comment from ".$name." on ".$entry.":<br><br>".$message."<br><br>";
$totaloutput = "<item><title>Comment on " . $entry . " from " . $name . "</title><link>https://isopod.cool/blog/posts/" . $entry . "/</link><pubDate>" . $date . "</pubDate><description>".htmlentities($output)."</description><guid isPermaLink='false'>" . $entry . $post->date . $name . "</guid></item>".$totaloutput;
}
echo $totaloutput;
echo "</channel></rss>";