diff options
Diffstat (limited to 'guestbook/feed.php')
| -rw-r--r-- | guestbook/feed.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/guestbook/feed.php b/guestbook/feed.php new file mode 100644 index 0000000..7cdb62e --- /dev/null +++ b/guestbook/feed.php @@ -0,0 +1,47 @@ +<?php + +header('Content-Type: text/xml'); + +echo '<rss version="2.0"><channel>'; +echo '<title>isopod.cool guestbook</title>'; +echo '<description>The guestbook on isopod.cool</description>'; +echo '<language>en-us</language>'; +echo '<link>https://isopod.cool/guestbook/</link>'; +echo '<generator>My crappy PHP code</generator>'; + +$postlist = json_decode(file_get_contents("posts.json")); +$index = 1; +$totaloutput = ""; +foreach($postlist as $post) { + $output = ""; + $date = date("D, d M Y H:m:s", $post->date) . " GMT"; + $name = $post->name; + $message = $post->message; + $found = $post->found; + $website = $post->website; + $cool = $post->cool; + $coolsanitized = htmlentities(preg_replace("/https?:\/\//i", "", $cool)); + $reply = htmlentities($post->reply); + + if($website) { $output = $output."<a href='$website'>$name</a>:<br><br>"; } + else { $output = $output.$name.":<br><br>"; } + + if($cool) { + $output = $output."<b>cool thing</b>: <a href='$cool'>$coolsanitized</a><br><br>"; + } + + if($found) { + $output = $output."<b>How did you find me?</b><br>$found<br><br>"; + } + + $output = $output.$message."<br><br>"; + + if($reply) { + $output = $output."<hr><b>Reply:</b><br>$reply"; + } + $totaloutput = "<item><title>Entry #" . $index . " - " . $name . "</title><link>https://isopod.cool/guestbook/</link><pubDate>" . $date . "</pubDate><description>".htmlentities($output)."</description><guid isPermaLink='false'>" . $index . $post->date . $name . "</guid></item>".$totaloutput; + $index++; +} + +echo $totaloutput; +echo "</channel></rss>";
\ No newline at end of file |
