1
0
Fork 0
isopod.cool/guestbook/feed.php
2023-01-09 14:30:45 -07:00

47 lines
No EOL
1.5 KiB
PHP

<?php
header('Content-Type: text/xml');
echo '<rss version="2.0"><channel>';
echo '<title>niceopod\'s 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>";